sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

Fatal C++ exceptions have missing stack trace

Open barisyild opened this issue 1 year ago • 1 comments

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

  1. Create mm file
  2. Throw C++ Exception (throw std::runtime_error("A runtime error occurred");)
  3. See Exception on Sentry

Expected Result

C++ exception details and stack trace should be included.

Actual Result

Image Image

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

barisyild avatar Aug 02 '24 10:08 barisyild

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.

philipphofmann avatar Aug 02 '24 11:08 philipphofmann

See:

  • https://github.com/kstenerud/KSCrash/issues/205#issuecomment-284391574
  • https://github.com/getsentry/sentry-cocoa/issues/551

bruno-garcia avatar Nov 06 '24 13:11 bruno-garcia

This issue seems to impact React Native (New Architecture) quite a bit, our app has a lot of errors with the string N8facebook3jsi7JSErrorE:

Image

which seems to just be any instance of facebook::jsi::JSError and the lack of captured details makes things very difficult to investigate

abejfehr avatar Jan 20 '25 15:01 abejfehr

Thanks for the update, @abejfehr. This helps us to prioritize this higher, but I can't give you an ETA yet.

philipphofmann avatar Jan 21 '25 12:01 philipphofmann

another report with additional information is captured in this issue: https://github.com/getsentry/sentry-cocoa/issues/4577

kahest avatar Mar 19 '25 13:03 kahest

from a RN-related crash where the missing thread/stack trace issue bubbled up:

kahest avatar Mar 28 '25 14:03 kahest

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.

philipphofmann avatar Apr 16 '25 09:04 philipphofmann

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.

philipphofmann avatar Apr 24 '25 09:04 philipphofmann

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.

philipphofmann avatar Jun 06 '25 11:06 philipphofmann