faulthandler not (really) implemented

Issue #2294 resolved
Armin Rigo created an issue

The faulthandler module is "implemented" right now, as in, it probably passes the tests. But it doesn't actually set any signal handler, and the test-passing traceback-printing logic is written in RPython, which is not usable at all from a signal handler. So most of pypy/module/faulthandler seems useless to me for the real purpose of this module: catching real segfaults.

Comments (5)

  1. Amaury Forgeot d'Arc

    Sure, the module is incomplete, but it is required to run the test suite (see regrtest.py)

    What is the best way to implement it? Does CPython really use only signal-safe functions in the signal handlers?

  2. Armin Rigo reporter

    If a dummy version is needed, it could have been written at app-level in lib_pypy.

    Yes, you have to use only signal-safe functions in signal handlers. CPython's faulthandler.c calls parts of traceback.c that was put there specifically for signal-safe contexts: they only call the write() system call, and don't touch the GIL, hoping they don't get another thread modifying the frame objects under their feets. See for example the comment "This function is signal safe" before dump_frame().

    A way to implement it would be to piggyback on the rpython.rlib.rvmprof module, which has signal-safe C code to fetch some limited form of tracebacks. It is missing a way to figure out the name of the code objects in signal-safe C code (these names are all dumped to the vmprof log file by RPython code when we enable it, and the full tracebacks are reconstructed when we later parse the log file). We probably need something like copying or moving the names into rffi-allocated strings and storing them in a global array.

  3. Log in to comment