Fatal C++ exceptions have missing stack trace
Platform
iOS
Environment
Production, Develop
Installed
Manually
Version
8.32.0
Xcode Version
15.4
Did it work on previous versions?
no
Steps to Reproduce
- Create mm file
- Throw C++ Exception (
throw std::runtime_error("A runtime error occurred");) - See Exception on Sentry
Expected Result
C++ exception details and stack trace should be included.
Actual Result
Not even the message is present in the exception; A runtime error occurred
Track for discord issue: https://discord.com/channels/621778831602221064/1268690651659112579
Are you willing to submit a PR?
No response
I can reproduce this issue with our macOS sample app by throwing a fatal CPP Exception https://github.com/getsentry/sentry-cocoa/blob/649d9405632d115712a1e4135287f311df713688/Samples/macOS-Swift/macOS-Swift/CppSample.cpp#L7
I went back to 8.22.0, but it didn't work back then. We have to investigate what the problem is.
See:
- https://github.com/kstenerud/KSCrash/issues/205#issuecomment-284391574
- https://github.com/getsentry/sentry-cocoa/issues/551
This issue seems to impact React Native (New Architecture) quite a bit, our app has a lot of errors with the string N8facebook3jsi7JSErrorE:
which seems to just be any instance of facebook::jsi::JSError and the lack of captured details makes things very difficult to investigate
Thanks for the update, @abejfehr. This helps us to prioritize this higher, but I can't give you an ETA yet.
another report with additional information is captured in this issue: https://github.com/getsentry/sentry-cocoa/issues/4577
from a RN-related crash where the missing thread/stack trace issue bubbled up:
- Sentry stack trace with the missing information
- Stack trace from CL with potentially more information
The C++Exceptions seem pretty broken. Luckily, we can copy fixes from KSCrash. I have a hacked-together solution with stacktraces and a proper error message here: https://github.com/getsentry/sentry-cocoa/compare/fix/cpp-exceptions?expand=1. I still need to polish the code a bit and make it ready for review. The good news is that we should have a fix for this soon.
Hey all, I just opened a hacked draft PR https://github.com/getsentry/sentry-cocoa/pull/5128. Unfortunately, I underestimated the effort a bit. I still need to write a few tests and do proper testing. I can't give an exact date, but we should be able to ship this behind an experimental feature flag in the beginning of May.
We just merged the PR to fix this. In the next release, you can enable options.experimental.enableUnhandledCPPExceptionsV2 = true to get proper stacktraces for fatal C++ exceptions. Please keep in mind that this feature is still experimental. We would welcome feedback so we can make the feature stable with https://github.com/getsentry/sentry-cocoa/issues/5309.