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

Improve C++ Exception Handling with Fishhook #4517

Open
philipphofmann opened this issue Nov 7, 2024 · 0 comments
Open

Improve C++ Exception Handling with Fishhook #4517

philipphofmann opened this issue Nov 7, 2024 · 0 comments

Comments

@philipphofmann
Copy link
Member

We could use fishhook to enhance C++ exception. Currently, the Sentry SDK uses dlsym to look up __cxa_throw.

orig_cxa_throw = (cxa_throw_type)dlsym(RTLD_NEXT, "__cxa_throw");

This approach falls short in applications with multiple dynamic libraries, as exceptions thrown in those separate modules aren’t caught by the main exception handler, but it works fine when Sentry is linked statically into the same module.

By using fishhook, which allows functions to be “hooked” by name as they are loaded across various modules, we could dynamically find and intercept all instances of __cxa_throw, even in different dynamic libraries. This would provide more comprehensive and consistent exception handling across an app’s runtime, regardless of the number of C++ modules or how they’re linked.

We used fishhook in the past for trying to get async stacktraces (#998), but we removed it again because it was not working reliably. The problem wasn't fishhook, but how we used it. We now use backtrace_async for async stacktrace in Swift.

This could maybe help with:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Discussion
Development

No branches or pull requests

1 participant