Repository navigation
fix(android): symbolicate managed exceptions from NativeAOT apps - #5916
jamescrosswell merged 4 commits into
Conversation
Managed exceptions from NativeAOT apps on Android carried image_addr and instruction_addr but no debug_meta, so Sentry could not symbolicate them. Load the module list sentry-native already builds, through the bound NDK NativeModuleListLoader, keyed by image address like the Cocoa path. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Also skip modules whose address can't be parsed instead of discarding the whole list, and call the static module list loader directly. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Thanks for the PR @charlesroddie and for account of what you observed. Generally the PR looks good. As some general context: Native AOT on Android is still experimental and we haven’t tested Sentry with it, so no guarantees anything works (or what the priority will be for future issues in this space)... That said, this change looks contained and I think it's worth trying to get some basics like this working (they're hopefully unlikely to break as Microsoft stabilises the foundations in this area). It only runs for frames that have no managed method info, so it shouldn't affect apps on CoreCLR or Mono... so happy to work with you to get it merged on that basis. Two things would help us get there, since the Android-only tests haven't run yet and the fix depends on an exact address match:
|
|
Thanks @jamescrosswell . I ran a build with this change on a real device with a .NET 11 NativeAOT app, using packages built from this branch, and triggered a managed exception.
(Frames show the raw symbol name and Event JSON (IDs and keys redacted) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR risk: mediumFor commit Main concerns: reach, data sent to Sentry, host performance. This label is a hint for reviewers, not an approval. |
*.verify.cs files are excluded from platform TFMs, so the Android-only tests in DebugStackTraceTests.verify.cs were never compiled. Split the class into a partial, leaving only the snapshot test in the .verify.cs file, as with SentryStackTraceFactoryTests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jamescrosswell
left a comment
There was a problem hiding this comment.
Thanks @charlesroddie, nice work on this, and thanks for the device testing!
I pushed two small commits before approving:
- Merged
main. The threebuildfailures came from the branch being behindmain. - Split
DebugStackTraceTestsinto a partial class.*.verify.csfiles are excluded from platform TFMs, so the two#if ANDROIDtests weren't being compiled. Everything except the snapshot test now lives inDebugStackTraceTests.cs, the same pattern asSentryStackTraceFactoryTests, and both of your tests now run and pass in the Android device tests.
Problem
Managed exceptions from NativeAOT apps on Android can't be symbolicated.
DebugStackTrace.TryCreateNativeAOTFrameleft_nativeDebugImagesempty on Android, so frames carryimage_addrandinstruction_addrbut the event has nodebug_meta. Sentry marks every frameunknown_image, even when the matching debug file is uploaded.Observed with Sentry .NET 6.12.1, .NET 11, NativeAOT, arm64 Android 10:
debug_metais null on the managed event, while the same app's native crash event (from sentry-native) lists the app's.sowith its GNU build-id ascode_idanddebug_status: found. Resolving the managed frames' offsets against the uploaded debug file locally gives correct functions with file and line.Fix
On Android, fill
_nativeDebugImagesfrom the module list sentry-native already builds, via the boundio.sentry.ndk.NativeModuleListLoader. Entries are keyed by image address and used exactly like the Cocoa andSentry.Nativepaths, and carrytype(elf),image_addr,image_size,code_id,debug_id,code_fileanddebug_fileas sentry-native reports them.Sentry.Native.C.LoadDebugImages(the NDK caches its module list too).options.Native.EnableNdkis false, since the NDK libraries aren't loaded then.Testing
NativeDebugImagesTests: conversion from the NDK'sDebugImage(Android only).DebugStackTraceTests: a NativeAOT frame inside a loaded native image adds that image to the event; none is added with the NDK disabled (Android only).The Android targets of
SentryandSentry.Testsbuild, andDebugStackTraceTestspass onnet10.0. The Android-only tests have not been run: I had no emulator available, so they rely on the CI device tests.🤖 Generated with Claude Code