Repository navigation
fix: Add sentry_reset_backend API - #388
GenuineAster wants to merge 1 commit into
Conversation
Codecov Report
@@ Coverage Diff @@
## master #388 +/- ##
==========================================
- Coverage 87.49% 87.37% -0.13%
==========================================
Files 49 49
Lines 4142 4149 +7
==========================================
+ Hits 3624 3625 +1
- Misses 518 524 +6 |
We have a third-party dynamic library (.NET Core runtime) that is loaded far into our application's runtime which, on load, steals all signal handlers. On Linux this works out fine, they are responsible and call whatever signal handler was there before them. No such luck on Windows. Forking and patching the .NET Core runtime is quite a bit more work, and we may run into this kind of issue in the future, so our internal fix is to add this API, and hopefully we can get this upstreamed and avoid forking sentry-native altogether.
| int | ||
| sentry_reset_backend(void) | ||
| { | ||
| sentry_backend_t *backend = g_options->backend; |
There was a problem hiding this comment.
You have to wrap this in SENTRY_WITH_OPTIONS (options) {
Otherwise you are not thread safe, and another thread can just free g_options from under you.
Also note that you can’t early-return from that macro :-(
| SENTRY_EXPERIMENTAL_API void sentry_clear_modulecache(void); | ||
|
|
||
| /** | ||
| * Re-initializes the Sentry backend |
There was a problem hiding this comment.
| * Re-initializes the Sentry backend | |
| * Re-initializes the Sentry backend. |
| /** | ||
| * Re-initializes the Sentry backend | ||
| * | ||
| * This is mainly meant for if a third-party library hijacks Sentry's signal |
There was a problem hiding this comment.
I would maybe phrase this more positively:
This is needed if a third-party library overrides the previously installed signal handler, and reinstalls the Sentry handler.
| * | ||
| * Returns 0 on success. | ||
| */ | ||
| SENTRY_API int sentry_reset_backend(void); |
There was a problem hiding this comment.
| SENTRY_API int sentry_reset_backend(void); | |
| SENTRY_EXPERIMENTAL_API int sentry_reset_backend(void); |
|
I really like this! Also, I was running into this case recently, investigating why native crashes when using a .NET won’t be captured; instead .NET handles them somehow. Also, an e2e test would be nice, but I think its a bit too complex to integrate into our example (which we use for tests) |
|
Could this be achieved by the call to It's what we do in .NET: Ref swap the current thing with the new one, the close out the previous one once it's not bound anymore/ |
|
I am quite busy this week (worked on this as part of a hackathon project) but I will fix your comments early next week, as well as testing with crashpad and looking into testing this a bit more! |
@bruno-garcia Thats already what Not quite sure whats the case with .NET, what part of the code runs when, and who wins, with respect to which signal handlers are active. |
|
Fwiw I was able to capture minidumps on CoreCLR on all platforms: |
|
Rebased and merged in 2a55499 |
We have a third-party dynamic library (.NET Core runtime) that is loaded far into our application's runtime which, on load, steals all signal handlers. On Linux this works out fine, they are responsible and call whatever signal handler was there before them. No such luck on Windows. Forking and patching the .NET Core runtime is quite a bit more work, and we may run into this kind of issue in the future, so our internal fix is to add this API, and hopefully we can get this upstreamed and avoid forking sentry-native altogether.
I'm not really sure how to write tests for this, but I can definitely add tests for it with a bit of guidance!