Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Description
Bug report
The_Py_DumpStack() should be signal-safe, because we typically call it from signal handlers.
This shows up as an error "signal-unsafe call inside of a signal" if you run./python -m test test_faulthandler -m test_enable_fd -v with TSan enabled.
From theman page:
backtrace() and backtrace_symbols_fd() don't call malloc()
explicitly,but they are part of libgcc, which gets loaded
dynamically when first used. Dynamic loading usually triggers
a call to malloc(3). If you need certain calls to these two
functions to not allocate memory (in signal handlers, for
example), you need to make sure libgcc is loaded beforehand.
(I thinkbacktrace() is inlibc, but it calls__libc_unwind_link_get(), which is inlibgcc)
If we are going to callbacktrace() from a signal handler, we should ensure thatlibgcc is loadedwhen we install the signal handler. We can do this by callingbacktrace() early, at signal handler installation time, to forcelibgcc to be loaded.