diff --git a/checkin_notes b/checkin_notes index dbdf3d5f96..fbe4b38f82 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7361,3 +7361,12 @@ David 31 Aug 2009 sched_send.cpp,h sched_shmem.h wu_check.cpp + +Eric K 31 Aug 2009 + - Fixed problem that prevented backtrace from being printed after many + types of signal. + + lib/ + diagnostics.cpp + + diff --git a/lib/diagnostics.cpp b/lib/diagnostics.cpp index c615e6c6a5..72f75909c3 100644 --- a/lib/diagnostics.cpp +++ b/lib/diagnostics.cpp @@ -616,7 +616,21 @@ void boinc_catch_signal(int signal) { void *array[64]; size_t size; size = backtrace (array, 64); - fprintf(stderr, "Stack trace (%d frames):\n", size); +// Anything that calls malloc here (i.e *printf()) will probably fail +// so we'll do it the hard way. + write(fileno(stderr),"Stack trace (",strlen("Stack trace (")); + char mbuf[10]; + char *p=mbuf+9; + int i=size; + *(p--)=0; + while (i) { + *(p--)=i%10+'0'; + i/=10; + } + write(fileno(stderr),p+1,strlen(p+1)); + write(fileno(stderr)," frames):",strlen(" frames):")); + mbuf[0]=10; + write(fileno(stderr),mbuf,1); backtrace_symbols_fd(array, size, fileno(stderr)); #endif