www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21066] New: Druntime SIGSEGV / SIGBUS unittest signal handler


          Issue ID: 21066
           Summary: Druntime SIGSEGV / SIGBUS unittest signal handler
                    should emit the stack trace for all threads
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

The current segfault handler in -unittest mode is implemented as:


However in the current implementation if there was a segfault then only one of
the threads will emit its stack trace. If multiple threads are used then this
may not be enough information - a random thread will be selected which may not
be the thread which caused the segfault. It's also possible for external
processes to send such a signal (for example `timeout -s SEGV 5m ./test` for
timeouts with stack traces).

It /is/ possible to force all threads to dump their stack trace. First this
should be changed:


And `SA_RESETHAND` removed (so we can reuse the signal handler). And then the
thread which received the signal should dispatch the signal to all other
threads (being careful those threads don't try to send the signal back). 


I have a working prototype for MacOS, but not for Posix / Windows / other
platforms yet.

Jul 23 2020