Repository navigation
fix(ios): send debug images with native exception frames so Sentry symbolicates them - #36
Conversation
…mbolicates them The throw-site stack chained from `nativeException` was built from `callStackSymbols` only: names resolved on the device and no `debug_meta` images, so Sentry could not symbolicate those frames against dSYMs. Release app executables are fully stripped, so their frames already showed wrong or missing names, and NativeScript runtimes that strip local symbols (NativeScript/ios#556) do the same for the runtime's internal functions. * Read `callStackReturnAddresses` alongside `callStackSymbols` and attach `image_addr`/`package` from sentry-cocoa's binary image cache to each frame. * Add one `macho` debug image per binary to `event.debug_meta.images`. * Mark the stack with `instruction_addr_adjustment: all`, since every address is a return address. * Keep the device names as the fallback when the image cache is empty (native SDK not started) or no dSYM is uploaded.
|
@edusperoni did you actually test this? the Pr says it was not tested |
`callStackSymbols` lines end in "symbol + offset". Sentry trims a frame's
`function` to a bare symbol name, so frames it could not symbolicate showed
only the offset ("172" instead of "__exceptionPreprocess").
* Split the device name into `function` and `symbol_addr` (the line's own
address minus the offset).
|
@farfromrefug It's tested now, end to end, on the simulator and on an iPad. I used a scratch NativeScript iOS app with the runtime from NativeScript/ios#556's CI build of 80e868332 (local symbols stripped). Plugin 5.0.0 was the control and this branch was the change. The app throws an iPad Pro, iOS 27.2.1, release device build (app executable and runtime both stripped):
The simulator gave the same result for the runtime and app frames. The test also caught an existing bug, which I fixed in cf935ef: frames Sentry can't symbolicate showed only the offset ( |
What
The
NativeExceptionintegration chains the native throw-site stack of a JS error that carries anativeException(anNSExceptionraised under a JS call). On iOS it now:callStackReturnAddressesalongsidecallStackSymbols(both index-aligned, newest frame first);SentryDependencies.binaryImageCache.imageByAddress) and setsimage_addrandpackageon the frame;machodebug image (debug_id,image_addr,image_size,code_file) per binary toevent.debug_meta.images, skipping images already listed;instruction_addr_adjustment: "all", since every address incallStackReturnAddressesis a return address, the newest frame included;__exceptionPreprocess + 172) intofunctionandsymbol_addr. Sentry trimsfunctionto a bare symbol name, so sending the combined string showed only the offset (172) on frames it couldn't symbolicate.The names parsed from
callStackSymbolsstay on each frame as a fallback for when the image cache is empty (native SDK not started) or no dSYM was uploaded.Why
These frames were resolved on the device only. Without
debug_metaimages, Sentry can't match the addresses to any dSYM, so the event shows whateverdladdrreturned on the device:STRIP_STYLE = all), so app frames in this stack show the image name plus an offset (MyApp + 16788).D79F14D9-F948-… + 620780for CoreFoundation).v8::CppHeap::CollectGarbageInYoungGenerationForTesting + 1132812forv8::internal::Execution::Call). That PR's docs call this out: raw addresses need their image list to be resolvable.With the image list, Sentry resolves these frames server-side, the same way it already does for native crashes captured by SentryCrash. Apps need the runtime's
NativeScript.framework.dSYMuploaded next to their own. When the runtime comes from the SwiftPM xcframework, Xcode copies that dSYM next to the app's own dSYM, so uploading the build's dSYMs covers it.This mirrors what
@sentry/react-nativedoes inRNSentry+fetchNativeStack.m(image cache lookup, then debug images).SentryInternalDebugApiwould be the cleaner entry point, but it is a Swift struct and not reachable from JS.SentryDependenciesandSentryBinaryImageCacheare@objcand appear in the NativeScript metadata generated for sentry-cocoa 9.19.1.SentryDependencyContainer.binaryImageCachedefaults to that same instance, so it is the cache the SDK starts.Testing
End to end, as an A/B: plugin 5.0.0 against this branch. The test app is a scratch NativeScript app that throws an
NSExceptionfrom a JS→native call (objectAtIndexpast the end of anNSArray), catches it in JS and callscaptureException. The runtime is the CI build of NativeScript/ios#556 (local symbols stripped). dSYMs and sourcemaps were uploaded before each run, and results were read from the raw event JSON.iPad Pro, iOS 27.2.1, release device build (app executable and runtime both stripped):
D79F14D9-F948-… + 1905360__boundsFailD79F14D9-… + 540584-[__NSArrayI objectAtIndex:]v8::CppHeap::CollectGarbageInYoungGenerationForTesting + 1034724v8::internal::Execution::Call_register_isolate_timers + 792tns::TimerState::RunIfEarliest (Timers.cpp:220)sentrysym + 16788main (main.m:62)With 5.0.0 every native frame is
unknown_image. With this branch all 43 frames are symbolicated: system frames by Sentry's iOS symbol server, the runtime and the app from their dSYMs.debug_metacarries the device's image UUIDs, and there are no processing errors.iOS 26.3 simulator, release build: same result for the runtime and app frames. System frames stay unsymbolicated there (Sentry has no simulator system symbols) and fall back to the device names, which the
symbol_addrchange keeps readable.Other checks:
atosagainst the runtime's dSYM gives the same names and lines as Sentry. Withinstruction_addr_adjustment: "all"they are call-site lines; unadjusted return addresses would give the line after the call (Interop.mm:1887instead of:1844).tscreports no new diagnostics; Prettier clean.