Skip to content
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

Pass EXCEPTION_POINTERS to before_send_func for crashpad backend (on_crash candidate) #592

Closed
espkk opened this issue Sep 11, 2021 · 4 comments

Comments

@espkk
Copy link
Contributor

espkk commented Sep 11, 2021

Hi,

I'm wondering why ExceptionInfo is not passed to before_send_func as a second (hint) argument here:

event, NULL, options->before_send_data);

This could be useful for example to choose a cleanup strategy depending on the exception code when before_send_func is called.
Is this by design or can be changed?

@Swatinem
Copy link
Member

As this callback is being invoked for every event (not only crashes), that wouldn’t easily be possible.

I think the best solution here would be to implement a dedicated on_crash hook, which does get the exception info, and signal info on unix platforms.

@espkk
Copy link
Contributor Author

espkk commented Sep 28, 2021

As this callback is being invoked for every event (not only crashes), that wouldn’t easily be possible.

As far as I can see sentry__prepare_event and sentry__crashpad_handler always set hint to NULL.
Since crashpad guarantees ExceptionInfo to contain exception pointers, testing the hint pointer could be used to differentiate the context.
So I'm still thinking of it as the "cheapest" solution as it's just 1 line change.
Also, that parameter can be used for holding some structure representing Unix signal data following the same considerations. The advantage of this approach is also that the context could be deduced with nullptr check using the same callback signature regardless of the platform.

Though, I agree that on_crash would be probably semantically cleaner.

Anyway, thank you for your answer! I will stick to my patched solution for now and wait for updates.

@ashwoods
Copy link

We are currently investigating implementing a "before_crash"/"on_crash" hook.

@ashwoods ashwoods changed the title Pass EXCEPTION_POINTERS to before_send_func for crashpad backend Pass EXCEPTION_POINTERS to before_send_func for crashpad backend (on_crash candidate) Nov 10, 2023
@supervacuus
Copy link
Collaborator

This was completed with https://github.com/getsentry/sentry-native/releases/tag/0.5.0.

The author of this issue (@espkk) implemented a considerable part of this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants