
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors. The program does nothing but start two threads and serialize them via the semaphore and I am unsure whether a) I did some error I am not aware of b) helgrind reports false positives I would be glad if someone could look at my code (attached) and give me a hint. Frederick Roth PS: Software versions are boost-1.47.0, valgrind-3.6.1, gcc 4.6.2, c++0x

Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
The program does nothing but start two threads and serialize them via the semaphore and I am unsure whether a) I did some error I am not aware of b) helgrind reports false positives
I would be glad if someone could look at my code (attached) and give me a hint.
Hi, could you add the reported "possible data race"? Vicente

On Wed, 04 Jan 2012 22:01:01 +0100, Vicente J. Botet Escriba wrote:
Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
could you add the reported "possible data race"?
Sure: ==2743== Possible data race during read of size 4 at 0x46c6d32c by thread #3 ==2743== at 0x46C5FE93: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== This conflicts with a previous write of size 4 by thread #2 ==2743== at 0x46C5FFA1: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x46C601A4: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== ==2743== Possible data race during read of size 4 at 0x46c6d328 by thread #3 ==2743== at 0x46C5FE99: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== This conflicts with a previous write of size 4 by thread #2 ==2743== at 0x46C5FF8C: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x46C601A4: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== ==2743== Possible data race during read of size 4 at 0x46c6d38c by thread #3 ==2743== at 0x46C680CF: boost::detail::get_once_per_thread_epoch() (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== This conflicts with a previous write of size 4 by thread #2 ==2743== at 0x467FD6F9: pthread_key_create (in /lib/libpthread-2.14.90.so) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so)

On Thu, 05 Jan 2012 09:04:46 +0100, Frederick Roth wrote:
On Wed, 04 Jan 2012 22:01:01 +0100, Vicente J. Botet Escriba wrote:
Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
could you add the reported "possible data race"?
Sure:
==2743== Possible data race during read of size 4 at 0x46c6d32c by thread #3 ==2743== at 0x46C5FE93: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== This conflicts with a previous write of size 4 by thread #2 ==2743== at 0x46C5FFA1: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x46C601A4:
boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so)
As no one called me a fool after posting my code I will assume that there is no obvious error in my code. I would still be interested if the problem is on my side or another. Does it make sense to repost this on the boost.threads development list or open a bug. I don't want to steal anybodies time but I am really interested in information about my problem. Fred

Frederick Roth wrote
On Thu, 05 Jan 2012 09:04:46 +0100, Frederick Roth wrote:
On Wed, 04 Jan 2012 22:01:01 +0100, Vicente J. Botet Escriba wrote:
Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
could you add the reported "possible data race"?
Sure:
==2743== Possible data race during read of size 4 at 0x46c6d32c by thread #3 ==2743== at 0x46C5FE93: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so) ==2743== This conflicts with a previous write of size 4 by thread #2 ==2743== at 0x46C5FFA1: ??? (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x46C601A4:
boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (in /usr/lib/libboost_thread-mt.so.1.47.0) ==2743== by 0x467F8CD2: start_thread (in /lib/libpthread-2.14.90.so) ==2743== by 0x4670283D: clone (in /lib/libc-2.14.90.so)
As no one called me a fool after posting my code I will assume that there is no obvious error in my code. I would still be interested if the problem is on my side or another. Does it make sense to repost this on the boost.threads development list or open a bug. I don't want to steal anybodies time but I am really interested in information about my problem.
Hi, I missed you last post. Anyway, the trace "Possible data race during read of size 4 at 0x46c6d32c by thread #3" doesn't help me too much. Is there any way helring can give the c++ variable names? Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/boost-thread-and-helgrind-tp4261378p42886... Sent from the Boost - Users mailing list archive at Nabble.com.

On Thu, 12 Jan 2012 03:13:38 -0800 (PST), Vicente Botet wrote:
Frederick Roth wrote
On Thu, 05 Jan 2012 09:04:46 +0100, Frederick Roth wrote:
On Wed, 04 Jan 2012 22:01:01 +0100, Vicente J. Botet Escriba wrote:
Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
Hi, I missed you last post.
Anyway, the trace "Possible data race during read of size 4 at 0x46c6d32c by thread #3" doesn't help me too much. Is there any way helring can give the c++ variable names?
I got it to show the line-numbers in the boost library (once.hpp and once.cpp) i give you the output below. I hope it helps. ==11280== Possible data race during read of size 4 at 0x403c1ec by thread #3 ==11280== at 0x402E873: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.constprop.111 (once.hpp:50) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so) ==11280== This conflicts with a previous write of size 4 by thread #2 ==11280== at 0x402E981: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.constprop.111 (once.hpp:77) ==11280== by 0x402EB84: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:105) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so) ==11280== ==11280== Possible data race during read of size 4 at 0x403c1e8 by thread #3 ==11280== at 0x402E879: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.constprop.111 (once.hpp:50) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so) ==11280== This conflicts with a previous write of size 4 by thread #2 ==11280== at 0x402E96C: _ZN5boost9call_onceIPFvvEEEvRNS_9once_flagET_.constprop.111 (once.hpp:77) ==11280== by 0x402EB84: boost::detail::set_current_thread_data(boost::detail::thread_data_base*) (thread.cpp:105) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so) ==11280== ==11280== Possible data race during read of size 4 at 0x403c24c by thread #3 ==11280== at 0x4036AAF: boost::detail::get_once_per_thread_epoch() (once.cpp:42) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so) ==11280== This conflicts with a previous write of size 4 by thread #2 ==11280== at 0x48D926F9: pthread_key_create (in /lib/libpthread-2.14.90.so) ==11280== by 0x48D8DCD2: start_thread (in /lib/libpthread-2.14.90.so) ==11280== by 0x48C9E83D: clone (in /lib/libc-2.14.90.so)

On Mon, 16 Jan 2012 10:48:28 +0100, Frederick Roth wrote:
On Thu, 12 Jan 2012 03:13:38 -0800 (PST), Vicente Botet wrote:
Frederick Roth wrote
On Thu, 05 Jan 2012 09:04:46 +0100, Frederick Roth wrote:
On Wed, 04 Jan 2012 22:01:01 +0100, Vicente J. Botet Escriba wrote:
Le 04/01/12 09:46, Frederick Roth a écrit :
I am currently fooling around with boost::thread. After writing a short example program (featuring boost::thread and boost::interprocess::interprocess_semaphore), I ran helgrind against it and got some "Possible data race" errors.
Hi, I missed you last post.
Anyway, the trace "Possible data race during read of size 4 at 0x46c6d32c by thread #3" doesn't help me too much. Is there any way helring can give the c++ variable names?
I got it to show the line-numbers in the boost library (once.hpp and once.cpp) i give you the output below. I hope it helps.
I did some googling and found the following boost trac entry which sounds similar to this. https://svn.boost.org/trac/boost/ticket/3526 The last comment states: "although every read of current_thread_tls_key happens after its initialization, this ordering is invisible to data race detection tools. That's why DRD complains about it. A suppression pattern for this access pattern will be added in Valgrind 3.6.0. " I did compile and test the main.cpp from the trac issue and valgrind-3.6.1 still reports the data race. I therefore assume, that the suppression pattern did not get into valgrind 3.6.0. -- Ich entschuldige mich nicht für Kunst!
participants (3)
-
Frederick Roth
-
Vicente Botet
-
Vicente J. Botet Escriba