
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I'm having some trouble with the thread library. When I interrupt a thread it is causing my application to crash. Here is a simple test file: #include <boost/thread.hpp> #include <iostream> #ifdef _WIN32 #include <windows.h> #endif using namespace boost; using namespace boost::posix_time; using namespace std; void threadFunction() { try { boost::this_thread::sleep(seconds(10)); } catch (thread_interrupted&) { cerr << "interrupted" << endl; } } int main() { thread myThread(threadFunction); #ifdef _WIN32 Sleep(1000); #else sleep(1); #endif myThread.interrupt(); myThread.join(); return 0; } If I compile this on Linux, or on Windows with MSVC it works perfectly every time, but if I compile with mingw it *usually* crashes after printing 'interrupted'. If I put a sleep in between the interrupt and join though it never crashes, so there appears to be a race condition somewhere.. Compiled with: i386-pc-mingw32-g++ -mthreads thread_test.cpp - -lboost_thread -o thread_test.exe $ i386-pc-mingw32-g++ --version i386-pc-mingw32-g++ (GCC) 4.4.3 Boost version 1.42 Any help would be appreciated. Chris. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAktp+iAACgkQ6iqRtkAADZiiWwCgrd3R/G2yCstU0ruuipCPbISo IAcAoOCE93g+alGcSUf7ZedHYC7Mwq3u =BHbA -----END PGP SIGNATURE-----
participants (1)
-
Chris Spencer