-
Notifications
You must be signed in to change notification settings - Fork 82
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
Incompatible with JNI on Windows: use unique handle for SymInitialize #204
Comments
Hi, |
Hi! I am running into the same issue because Tracy does the same as JNI. In the official Microsoft example, the handle is duplicated as well (https://learn.microsoft.com/en-us/windows/win32/debug/initializing-the-symbol-handler). Perhaps it is the best practice? |
Thanks for the link, if microsoft shows this as an example that helps give me confidence in the approach. I can take a look at making changes in cpptrace here or I'd welcome a PR |
I have created a PR, and in my own project, it works as intended, but the integration tests are failing. In Windows, CMake doesn't create the integration tests (at least I dont see them in the VS solution), so I don't know how to debug it. |
Thanks so much for taking the time to make a PR. I'm looking now and I'll give it a test locally. |
I have edited most of the comments and also added that the duplicate handles will be closed at the end now. |
…204 (#206) WinDbg: Duplicate the process handle before using it in SymInitialize, because other libraries may have already called SymInitialize for the process (https://learn.microsoft.com/en-us/windows/win32/debug/initializing-the-symbol-handler) Fixes #204 --------- Co-authored-by: Jeremy <[email protected]>
Resolved on |
When trying to use cpptrace in a JNI library, it only gives empty traces, or with
absorb_trace_exceptions(false)
, it gives an exceptionCpptrace internal error: SymInitialize failed 87
(87 is ERROR_INVALID_PARAMETER). This appears to be caused by doing SymInitialize on the same handle twice, since openjdk also does that.This can be solved by duplicating the handle, so that cpptrace initializes its own unique copy. The following diff (in
{unwind,symbols}_with_dbghelp.cpp
), in conjunction withcpptrace::experimental::set_cache_mode(cpptrace::cache_mode::prioritize_memory)
, allows capturing traces when GetCurrentProcess() is already initialized.This is only a sketch for a fix: a real one would need to close the handle and to support other cache modes. I don't currently have the time nor expertise to make a PR for a real fix, so a bug report will have to suffice.
The text was updated successfully, but these errors were encountered: