Re: valgrind drd shows potential data race in curl_easy_init

Aman Grewal via curl-library <[email protected]> Fri, 21 Nov 2025 15:03:04 -0500
Newsgroups gmane.comp.web.curl.library
Message-ID <CANkERQpjJDaduVZfbmsRJxT3cxz6Pdp20=Bbjd4iNhDNh_NzVw@mail.gmail.com>
On Thu, Nov 20, 2025 at 11:16 AM Daniel Stenberg <[email protected]> wrote:

> > I'm running my library under valgrind to try to find any bugs. I'm seeing
> > this warning stemming from `curl_easy_init` when running drd.
>
> I don't understand what that output means.


drd was complaining about a data race between threads.

This is curl_easy_init code and as you can see, there is a lock for the
> part
> that is not thread-safe:
>
>
> https://github.com/curl/curl/blob/7e8f36bf8e56e632e4f8be54b584f758e3aaa086/lib/easy.c#L349-L376
>
> This lock has existed like this for a while.


I built curl with debug symbols and noticed it was actually
complaining about a data race on the lock itself.

==8== Location 0x4a12278 is 0 bytes inside global var "s_lock"


It appears that drd doesn't understand that the atomic is being used as a
locking mechanism, so I can just add it to my suppressions file.


Thanks,
Aman

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html