curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder Daniel himself.

Re: valgrind drd shows potential data race in curl_easy_init

From: Jeffrey Walton via curl-library <curl-library_at_lists.haxx.se>
Date: Fri, 21 Nov 2025 15:09:51 -0500

On Wed, Nov 19, 2025 at 6:36 PM Aman Grewal via curl-library
<curl-library_at_lists.haxx.se> 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.
>
> Command: `valgrind --tool=drd --read-var-info=yes --check-stack-var=yes --free-is-write=yes -s --gen-suppressions=all /test`
>
> Truncated Output:
> ==8== Thread 3:
> ==8== Conflicting load by thread 3 at 0x04949724 size 4
> ==8== at 0x48B8FA2: curl_easy_init (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x40014C1: thread_func (test.c:33)
> ==8== by 0x485B948: vgDrd_thread_wrapper (drd_pthread_intercepts.c:512)
> ==8== by 0x49E6AA3: start_thread (pthread_create.c:447)
> ==8== by 0x4A73A63: clone (clone.S:100)
> ==8== Allocation context: BSS section of /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0
> ==8== Other segment start (thread 2)
> ==8== at 0x4A73A56: clone (clone.S:83)
> ==8== by 0x49E671F: ??? (allocatestack.c:605)
> ==8== by 0x67036BF: ???
> ==8== Other segment end (thread 2)
> ==8== at 0x4A759DB: connect (connect.c:26)
> ==8== by 0x48A7DEC: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48B42E7: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48B517F: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48A8FC5: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48EAED7: ??? (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48ED5D9: curl_multi_perform (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x48BBE3A: curl_easy_perform (in /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.8.0)
> ==8== by 0x4001553: thread_func (test.c:38)
> ==8== by 0x485B948: vgDrd_thread_wrapper (drd_pthread_intercepts.c:512)
> ==8== by 0x49E6AA3: start_thread (pthread_create.c:447)
> ==8== by 0x4A73A63: clone (clone.S:100)
> ==8==
>
> When I run the same valgrind command on the sample code in https://curl.se/libcurl/c/threaded-ssl.html, I see similar warnings, so I'm hoping this is a spurious warning. Has anyone seen this before? Is it safe to add it to my suppressions file?
>
> I'm running this on Ubuntu 24.04 (LTS), and I'm using the libcurl3t64-gnutls package.

You should test your library and curl under Valgrind after building
the components -g and -O1. -O2 and above can lead to false positives
on uninitialised values. From the Valgrind Quick Start Guide,
<https://valgrind.org/docs/manual/quick-start.html>:

    Compile your program with -g to include debugging information so that
    Memcheck's error messages include exact line numbers. Using -O0 is also
    a good idea, if you can tolerate the slowdown. With -O1 line numbers in
    error messages can be inaccurate, although generally speaking running
    Memcheck on code compiled at -O1 works fairly well, and the speed
    improvement compared to running -O0 is quite significant. Use of -O2
    and above is not recommended as Memcheck occasionally reports
    uninitialised-value errors which don't really exist.

Jeff
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2025-11-21