-
Notifications
You must be signed in to change notification settings - Fork 253
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
Cleanup dbghelp so that stdlib can print backtraces on panic again #172
Conversation
I noticed that there's a Creating an unresolved backtrace with
The challenge is that resolving the symbols in the callback becomes just as slow as resolving them separately because it's having to initialize dbghelp per frame again. I've solved that with some thread-local shenanigans to detect when resolving inside of a trace and then delay the cleanup until the end of the trace. I'd like to add the
|
Thanks for this! If I understand it, the intention is to create a recursive lock here effectively (aka one that can be safely acquire recursively) and only on the first acquisition and last release do we initialize/cleanup symbols? That way it should always be paired on entering/leaving this library but we also don't attempt to reinitialize on each symbol by "locking" at a higher level. If that's true, could this perhaps be organized a bit differently? Instead of automatically enabling the As for |
Sure, I can take a look at re-organizing it. I think what you're getting at is that this PR makes
I was also wondering if we could eliminate the kernel32 feature and just always use I was initially thinking that adding in |
I think this is getting close now. I went ahead and added in the I'm not sure what's going on with the build. GitHub is reporting a 404 on the a file that exists and wasn't modified. The commit that it's complaining about doesn't exist though which is odd. Could you re-trigger the build? |
This has inspired me to take a look again at directly including I'd prefer that documentation where found to either choose RtlCaptureStackBackTrace or StackWalk64, I don't think it makes sense to support both. I"ll try to find time later today, but I don't currently have time to finish review of this, but wanted to jot these thoughts down! |
This PR adds cleanup for
DbgHelp
so that the standard library can print backtraces on panic again. It now keeps count of the number of internal requests for initialization within a single API call in order to minimize the number of init/cleanup cycles. This helps to mitigate the additional overhead of pairing cleanup and initialization. In addition, dbghelp is now initialized with theSYMOPT_DEFERRED_LOADS
to further reduce the cost of initialization.Fixes #165