Board index » cppbuilder » Boost users please confirm (compiler bug?)
Vaclav Cechura
![]() CBuilder Developer |
Boost users please confirm (compiler bug?)2007-11-26 10:50:56 PM cppbuilder34 Can anybody using boost 1.34 (or lower) with BCB2006(2007?) confirm this error? Uncommenting line B in the posted example triggers Access violation exception when the program is run. When run in IDE the de{*word*81} stops in mutex::do_unlock(). See caller stack and other context bellow. This is strange as the function thr() containing that line does not get called anywhere in the example. Only the fact that it has been compiled triggers a runtime error. Setup: - boost 1.34.1 with bcbboost - Mulithreaded console application without VCL - Static linking with 'LIBBOOST_THREAD-BCB-MT-SD-1_34_1.LIB' (BOOST_THREAD_USE_LIB defined) - RTL static linking The AV exception is thrown from boost's thread constructor: thread::thread() calls thread_param::wait() and it creates a scoped_lock object that upon destruction calls do_unlock upon a thread_param internal mutex that got strangely NULL. caller stack: :7c812a5b kernel32.RaiseException + 0x52 :0041271a ___raiseDe{*word*81}Exception + 0x1A :004127f4 ; ___raiseDe{*word*81}Exception :7c9037bf ntdll.RtlConvertUlongToLargeInteger + 0x7a :7c90378b ntdll.RtlConvertUlongToLargeInteger + 0x46 :7c90eafa ntdll.KiUserExceptionDispatcher + 0xe :0041F5A7 boost::mutex::do_unlock(this=NULL, =:0012FDE0) :0041DFC6 boost::detail::thread::lock_ops<boost::mutex>::unlock(m=NULL, state=:0012FDE0) :0041DD51 boost::condition::do_wait<boost::mutex>(this=:0012FE9C, mutex=NULL) :0041DA52 boost::condition::wait<boost::detail::thread::scoped_lock<boost::mutex>>(this=:0012FE9C, lock=:0012FE54) :0041D19F __UNNS__thread_01c827c2c2c9169a::thread_param::wait(this=:0012FE94) :0041D001 boost::thread::thread(this=:00000FCC, threadfunc=:00000FC8) :0012fe01 //--------------------------------------------------------------------------- #include <iostream> #include <boost/thread.hpp> #include <memory> //--------------------------------------------------------------------------- boost::mutex *console = 0; // line A void thr() // int n, boost::mutex & display { if (console == 0) return; for (int i = 0; i < 10; i++) { //boost::mutex::scoped_lock l(*console); // line B std::cout << "thr" << 1 << ":" << i << std::endl; } // end for } void dummy_thr() // int n, boost::mutex & display { } int main(int argc, char* argv[]) { boost::thread_group tg; std::auto_ptr<boost::mutex>(console = new boost::mutex); tg.create_thread(&dummy_thr); char c; std::cin>>c ; return 0; } //--------------------------------------------------------------------------- |