[Boost-bugs] [Boost C++ Libraries] #3585: Boost::thread + valgrind/drd possible false positive

Subject: [Boost-bugs] [Boost C++ Libraries] #3585: Boost::thread + valgrind/drd possible false positive
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-11-02 17:43:41


#3585: Boost::thread + valgrind/drd possible false positive
----------------------------------------------------+-----------------------
 Reporter: Mihail Strashun <m.strashun@…> | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.40.0 | Severity: Problem
 Keywords: thread, drd, valgrind |
----------------------------------------------------+-----------------------
 OS: Arch Linux

 Boost Library v 1.39

 Valgrind v 3.5

 Problem description:

 Running small degenerated piece of code under valgrind/drd produces
 "probably a race condition" error on call of "interrupt". I was adviced on
 #boost channel to make a ticket after short examination of code.

 Note:

 This [ https://svn.boost.org/trac/boost/ticket/3526 ] case was added to
 valgrind suppression file.

 Example code attached.

 Compilation:

 {{{
 make all
 Building file: ../src/test.cpp
 Invoking: GCC C++ Compiler
 g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d"
 -MT"src/test.d" -o"src/test.o" "../src/test.cpp"
 Finished building: ../src/test.cpp

 Building target: test
 Invoking: GCC C++ Linker
 g++ -o"test" ./src/test.o -lboost_thread-mt
 Finished building target: test
 }}}

 Output:

 {{{
 [mist_at_fog test]$ valgrind --tool=drd ./Debug/test
 ==2759== drd, a thread error detector
 ==2759== Copyright (C) 2006-2009, and GNU GPL'd, by Bart Van Assche.
 ==2759== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
 ==2759== Command: ./Debug/test
 ==2759==
 ==2759== Probably a race condition: condition variable 0x5f64180 has been
 signaled but the associated mutex 0x5f64158 is not locked by the
 signalling thread.
 ==2759== at 0x4C27BF9: pthread_cond_broadcast@* (in /usr/lib/valgrind
 /vgpreload_drd-amd64-linux.so)
 ==2759== by 0x4E3BC88: boost::thread::interrupt() (in /usr/lib
 /libboost_thread-mt.so.1.39.0)
 ==2759== by 0x405D42: stopThread(std::string const&) (test.cpp:45)
 ==2759== by 0x405E79: main (test.cpp:75)
 ==2759== cond 0x5f64180 was first observed at:
 ==2759== at 0x4C266D9: pthread_cond_init@* (in /usr/lib/valgrind
 /vgpreload_drd-amd64-linux.so)
 ==2759== by 0x406E0B: boost::condition_variable::condition_variable()
 (condition_variable_fwd.hpp:30)
 ==2759== by 0x406F39:
 boost::detail::thread_data_base::thread_data_base() (thread_data.hpp:54)
 ==2759== by 0x40BF1C:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>::thread_data(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >) (thread.hpp:48)
 ==2759== by 0x40B7F1:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > > >*
 boost::detail::heap_new_impl<boost::detail::thread_data<boost::_bi::bind_t<void,
 cTestRunner, boost::_bi::list1<boost::_bi::value<std::string> > > >,
 boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> >
>&>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >&)
 (thread_heap_alloc.hpp:47)
 ==2759== by 0x40AA8B:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > > >*
 boost::detail::heap_new<boost::detail::thread_data<boost::_bi::bind_t<void,
 cTestRunner, boost::_bi::list1<boost::_bi::value<std::string> > > >,
 boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >&)
 (thread_heap_alloc.hpp:73)
 ==2759== by 0x40A1C0:
 boost::shared_ptr<boost::detail::thread_data_base>
 boost::thread::make_thread_info<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >) (thread.hpp:136)
 ==2759== by 0x4092E1: boost::thread::thread<cTestRunner,
 std::string>(cTestRunner, std::string) (thread.hpp:227)
 ==2759== by 0x407D28: void startThread<cTestRunner>(std::string const&)
 (test.cpp:36)
 ==2759== by 0x405DDB: main (test.cpp:71)
 ==2759== mutex 0x5f64158 was first observed at:
 ==2759== at 0x4C2C04F: pthread_mutex_init (in /usr/lib/valgrind
 /vgpreload_drd-amd64-linux.so)
 ==2759== by 0x406D31: boost::mutex::mutex() (mutex.hpp:37)
 ==2759== by 0x406F27:
 boost::detail::thread_data_base::thread_data_base() (thread_data.hpp:54)
 ==2759== by 0x40BF1C:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>::thread_data(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >) (thread.hpp:48)
 ==2759== by 0x40B7F1:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > > >*
 boost::detail::heap_new_impl<boost::detail::thread_data<boost::_bi::bind_t<void,
 cTestRunner, boost::_bi::list1<boost::_bi::value<std::string> > > >,
 boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> >
>&>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >&)
 (thread_heap_alloc.hpp:47)
 ==2759== by 0x40AA8B:
 boost::detail::thread_data<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > > >*
 boost::detail::heap_new<boost::detail::thread_data<boost::_bi::bind_t<void,
 cTestRunner, boost::_bi::list1<boost::_bi::value<std::string> > > >,
 boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >&)
 (thread_heap_alloc.hpp:73)
 ==2759== by 0x40A1C0:
 boost::shared_ptr<boost::detail::thread_data_base>
 boost::thread::make_thread_info<boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >
>(boost::_bi::bind_t<void, cTestRunner,
 boost::_bi::list1<boost::_bi::value<std::string> > >) (thread.hpp:136)
 ==2759== by 0x4092E1: boost::thread::thread<cTestRunner,
 std::string>(cTestRunner, std::string) (thread.hpp:227)
 ==2759== by 0x407D28: void startThread<cTestRunner>(std::string const&)
 (test.cpp:36)
 ==2759== by 0x405DDB: main (test.cpp:71)
 ==2759==
 ==2759==
 ==2759== For counts of detected and suppressed errors, rerun with: -v
 ==2759== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 1956 from
 80)
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3585>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:01 UTC