[thread] why crash launching a thread?

i'm launching a new thread from an existing background thread, BUT it is crashing. i don't know if it happens often yet, but was wondering what could possibly cause this? Thread 10 Crashed: 0 libSystem.B.dylib 0x96ce435d usleep$NOCANCEL$UNIX2003 + 0 1 libSystem.B.dylib 0x96d05a50 abort + 105 2 libstdc++.6.dylib 0x96bb2fda __gnu_cxx::__verbose_terminate_handler() + 433 3 libstdc++.6.dylib 0x96bb117a __cxxabiv1::__terminate(void (*)()) + 10 4 libstdc++.6.dylib 0x96bb11ba __cxxabiv1::__unexpected(void (*)()) + 0 5 libstdc++.6.dylib 0x96bb12b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0 6 libboost_thread.dylib 0x006af933 boost::thread::start_thread() + 195 7 com.kjams.kjams 0x001281d1 CThreads::Fork(APP_ThreadType, long (*)(void*, long), long (*)(void*, long), void*, char const*) + 1521 8 com.kjams.kjams 0x0012858b CT_Preemptive::call(char const*) + 91 9 com.kjams.kjams 0x00139fc2 CSpooler::Fork_Spool(CSpooler*, bool) + 290 10 com.kjams.kjams 0x0027fd05 CSongImporter::EncodeSong(CSI_PersistantQueData*, CSpooler*) + 1109

On 01/30/2010 11:01 PM, David M. Cotter wrote:
i'm launching a new thread from an existing background thread, BUT it is crashing. i don't know if it happens often yet, but was wondering what could possibly cause this?
Thread 10 Crashed: 0 libSystem.B.dylib 0x96ce435d usleep$NOCANCEL$UNIX2003 + 0 1 libSystem.B.dylib 0x96d05a50 abort + 105 2 libstdc++.6.dylib 0x96bb2fda __gnu_cxx::__verbose_terminate_handler() + 433 3 libstdc++.6.dylib 0x96bb117a __cxxabiv1::__terminate(void (*)()) + 10 4 libstdc++.6.dylib 0x96bb11ba __cxxabiv1::__unexpected(void (*)()) + 0 5 libstdc++.6.dylib 0x96bb12b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0 6 libboost_thread.dylib 0x006af933 boost::thread::start_thread() + 195 7 com.kjams.kjams 0x001281d1 CThreads::Fork(APP_ThreadType, long (*)(void*, long), long (*)(void*, long), void*, char const*) + 1521 8 com.kjams.kjams 0x0012858b CT_Preemptive::call(char const*) + 91 9 com.kjams.kjams 0x00139fc2 CSpooler::Fork_Spool(CSpooler*, bool) + 290 10 com.kjams.kjams 0x0027fd05 CSongImporter::EncodeSong(CSI_PersistantQueData*, CSpooler*) + 1109
Looks like you have an uncaught exception in that thread.

i'm launching a new thread from an existing background thread, BUT it is crashing. i don't know if it happens often yet, but was wondering what could possibly cause this?
Thread 10 Crashed: 0 libSystem.B.dylib 0x96ce435d usleep$NOCANCEL$UNIX2003 + 0 1 libSystem.B.dylib 0x96d05a50 abort + 105 2 libstdc++.6.dylib 0x96bb2fda __gnu_cxx::__verbose_terminate_handler() + 433 3 libstdc++.6.dylib 0x96bb117a __cxxabiv1::__terminate(void (*)()) + 10 4 libstdc++.6.dylib 0x96bb11ba __cxxabiv1::__unexpected(void (*)()) + 0 5 libstdc++.6.dylib 0x96bb12b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0 6 libboost_thread.dylib 0x006af933 boost::thread::start_thread() + 195 7 com.kjams.kjams 0x001281d1 CThreads::Fork(APP_ThreadType, long (*)(void*, long), long (*)(void*, long), void*, char const*) + 1521 8 com.kjams.kjams 0x0012858b CT_Preemptive::call(char const*) + 91 9 com.kjams.kjams 0x00139fc2 CSpooler::Fork_Spool(CSpooler*, bool) + 290 10 com.kjams.kjams 0x0027fd05 CSongImporter::EncodeSong(CSI_PersistantQueData*, CSpooler*) + 1109
Looks like you have an uncaught exception in that thread.
i do in fact have a general exception handler surrounding this code, so that can't be the problem. also, it is not my code which is throwing, it is boost. why does boost throw?

i would greatly appreciate it if anyone could shed some light on this. On Jan 30, 2010, at 2:04 PM, David M. Cotter wrote:
i'm launching a new thread from an existing background thread, BUT it is crashing. i don't know if it happens often yet, but was wondering what could possibly cause this?
Thread 10 Crashed: 0 libSystem.B.dylib 0x96ce435d usleep$NOCANCEL$UNIX2003 + 0 1 libSystem.B.dylib 0x96d05a50 abort + 105 2 libstdc++.6.dylib 0x96bb2fda __gnu_cxx::__verbose_terminate_handler() + 433 3 libstdc++.6.dylib 0x96bb117a __cxxabiv1::__terminate(void (*)()) + 10 4 libstdc++.6.dylib 0x96bb11ba __cxxabiv1::__unexpected(void (*)()) + 0 5 libstdc++.6.dylib 0x96bb12b8 __gxx_exception_cleanup(_Unwind_Reason_Code, _Unwind_Exception*) + 0 6 libboost_thread.dylib 0x006af933 boost::thread::start_thread() + 195 7 com.kjams.kjams 0x001281d1 CThreads::Fork(APP_ThreadType, long (*)(void*, long), long (*)(void*, long), void*, char const*) + 1521 8 com.kjams.kjams 0x0012858b CT_Preemptive::call(char const*) + 91 9 com.kjams.kjams 0x00139fc2 CSpooler::Fork_Spool(CSpooler*, bool) + 290 10 com.kjams.kjams 0x0027fd05 CSongImporter::EncodeSong(CSI_PersistantQueData*, CSpooler*) + 1109
Looks like you have an uncaught exception in that thread.
i do in fact have a general exception handler surrounding this code, so that can't be the problem.
also, it is not my code which is throwing, it is boost. why does boost throw?

On 1 Feb 2010, at 19:26, David M. Cotter wrote:
i would greatly appreciate it if anyone could shed some light on this.
Can you provide a small (< 50 lines) example which shows your problem? If so, then I'm sure someone would help you with your bug, but your backtrace is not enough information. Chris

i simply call: foo = new boost::thread(CFork_Preemptive(infoP)); then somewhere INSIDE BOOST, it throws. i have not looked at the boost source about this, i was under the impression that it would never throw to create a thread. it is intermittant. i can be running for a half hour making new threads left and right, no problem.

On 02/02/2010, at 7:18 AM, David M. Cotter wrote:
i simply call:
foo = new boost::thread(CFork_Preemptive(infoP));
then somewhere INSIDE BOOST, it throws. i have not looked at the boost source about this, i was under the impression that it would never throw to create a thread.
it is intermittant. i can be running for a half hour making new threads left and right, no problem.
boost can throw a thread_resource_error if too many threads are spawned. maybe that's too many threads, maybe the threads are "zombies" (haven't been reclaimed) etc etc. http://svn.boost.org/svn/boost/tags/release/Boost_1_41_0/libs/thread/src/pth... strace -f your program to see if pthread_create returns an error in this intermittent case. i suspect the thread is not returning resources when it joins due to a pthread_create option not being set -- check the options you can set on the thread. also look at the arguments boost uses to create the thread in the strace output and cross reference against the man page for pthread_create to see if they are what you want. If you don't need to go cross platform, you could just talk to the pthreads library directly -- looks like you're wrapping it in a CThreads library anyway to isolate your app. Less layers to deal with... There was a race condition a long time ago with threads that were created and then immediately joined in 1.31, but that blew up differently. hth, Matthew

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 01 February 2010, David M. Cotter wrote:
i would greatly appreciate it if anyone could shed some light on this.
On Jan 30, 2010, at 2:04 PM, David M. Cotter wrote:
i'm launching a new thread from an existing background thread, BUT it is crashing. i don't know if it happens often yet, but was wondering what could possibly cause this?
Thread 10 Crashed: 0 libSystem.B.dylib 0x96ce435d usleep$NOCANCEL$UNIX2003 + 0 1 libSystem.B.dylib 0x96d05a50 abort + 105 2 libstdc++.6.dylib 0x96bb2fda __gnu_cxx::__verbose_terminate_handler() + 433 3 libstdc++.6.dylib 0x96bb117a __cxxabiv1::__terminate(void (*)()) + 10 4 libstdc++.6.dylib 0x96bb11ba __cxxabiv1::__unexpected(void
I see "unexpected" in the call trace, maybe something is violating its throw specification? The default unexpected handler probably terminates. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAktnMScACgkQ5vihyNWuA4UzFgCdEp6zH1yKjYp7GDeK70qYrAt0 uQcAn3W7PmJPGHo2YgDKDiVvGBpAJglM =AnQH -----END PGP SIGNATURE-----
participants (5)
-
Andrey Semashev
-
Christopher Jefferson
-
David M. Cotter
-
Frank Mori Hess
-
Matthew Herrmann