-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signal handler is unsafe #36
Comments
Yes. I have mentioned this in README. (oops, it seems not clear enough)
If the signal arrives while the program is getting backtrace (through libgcc) (for sampling, profiling, error handling...), the result is hard to predict (sometimes will crash directly). A possible solution (in my imagination 😸 ) is to scan and find the address of libgcc. In the signal handler, we can judge whether the context (register rip) is in libgcc's part. If it is, But it's also not 100% perfect because libgcc's unwind can call other libraries, it's hard to tell whether the current context is in a calling process of |
Thank you for the detailed response. I think the best solution is just to turn off other things that might be getting the backtrace (e.g. jemalloc) while using Pprof-rs. |
In
perf_signal_handler
,backtrace::trace_unsychronized
is called. This will not produce any bugs if the user is just using pprof-rs, since a lock is taken, so the main body ofperf_signal_handler
cannot be executed more than once at a time.However, if the user is calling
backtrace::trace
from any other part of the code at the same time, this will result in UB.I suspect (but I'm not sure) that this is why we are seeing deadlocks in https://github.com/MaterializeInc/materialize when using both jemalloc heap profiling and pprof-rs profiling at the same time.
The text was updated successfully, but these errors were encountered: