race conditions in libcurl under valgrind

Hello everyone!

I am executing the following libcurl example under valgrind(helgrind)

https://curl.haxx.se/libcurl/c/multithread.html

And I am getting race conditions. Because the valgrind output is huge, here I just put an example of a race condition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

==7693== Possible data race during read of size 4 at 0x54EC5E0 by thread #8
==7693== Locks held: none
==7693==    at 0x51C6128: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51C638C: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51C6F6F: ERR_remove_thread_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x4297B4: Curl_close (in /home/romerohe/proyects/cpp/libcurl/main)
==7693==    by 0x411A40: Curl_conncache_close_all_connections (in /home/romerohe/proyects/cpp/libcurl/main)
==7693==    by 0x40BCEE: curl_multi_cleanup (in /home/romerohe/proyects/cpp/libcurl/main)
==7693==    by 0x42974B: Curl_close (in /home/romerohe/proyects/cpp/libcurl/main)
==7693==    by 0x4079C4: curl_easy_cleanup (in /home/romerohe/proyects/cpp/libcurl/main)
==7693==    by 0x40732C: pull_one_url(void*) (main.cpp:30)
==7693==    by 0x4C34E85: mythread_wrapper (hg_intercepts.c:389)
==7693==    by 0x54F56B9: start_thread (pthread_create.c:333)
==7693== 
==7693== This conflicts with a previous write of size 4 by thread #6
==7693== Locks held: none
==7693==    at 0x51C6128: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51C661C: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51C7023: ERR_get_state (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51C715D: ERR_put_error (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51F8626: PEM_read_bio (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x51F69AD: PEM_X509_INFO_read_bio (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x5206396: X509_load_cert_crl_file (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==    by 0x52064B9: ??? (in /lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==7693==  Address 0x54ec5e0 is in the BSS segment of /lib/x86_64-linux-gnu/libcrypto.so.1.0.0


But there are many more. Does anyone know why? Or maybe the problem is with valgrind?

Thanks a lot!
these kinds of tools are known for false alarms, which can be mitigated by settings somewhat but if you get 0 false alarms you probably have erred the wrong way and missed issues, so best to set it so you get a few but not many. That said, there could well be issues in the library or in how you used it. These are well known libraries; do you have an example program that they provide, and does a check on their example give a ton of problems?

Race conditions can exist and never be triggered, as well. The algorithm to find them can't tell if the code ever gets into a bad state, just that it could possibly. Are you able to write an example that goes into thread snarl and locks up via any of the listed race condition problems?
Topic archived. No new replies allowed.