Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Oct 27, 2025

Opt-in, Android-only solution for:

According to our newly introduced Android integration tests, getsentry/sentry-native#1392 works on android-arm64 and android-x64 in both Release and Debug configurations, but we'd like to validate the fix further in real-world conditions. To that end, we're making it opt-in initially so customers can try it on more devices, platforms, and configurations before considering it as the new default.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 27, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b64b284

@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.87%. Comparing base (863ee6a) to head (b64b284).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4676      +/-   ##
==========================================
+ Coverage   73.85%   73.87%   +0.02%     
==========================================
  Files         483      494      +11     
  Lines       17578    17868     +290     
  Branches     3464     3509      +45     
==========================================
+ Hits        12982    13200     +218     
- Misses       3742     3808      +66     
- Partials      854      860       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Nov 4, 2025

@jamescrosswell This is marked as a draft because it's still waiting for dependencies, but we could already kick off the review process if you have time. :)

Do you have a preferred approach for exposing this as an opt-in API? The current proposal mirrors the sentry-native enum.

#if ANDROID
    options.Native.SignalHandlerStrategy = Sentry.Android.SignalHandlerStrategy.ChainAtStart;
#endif

With only two values, a simple boolean flag could also work for the time being, but I'm unsure if potential Android Tombstone support could change things in the future.

Base automatically changed from version6 to main November 14, 2025 02:30
@jpnurmi jpnurmi force-pushed the feat/android-signal-handler-strategy branch from af57caa to 4486918 Compare November 20, 2025 10:31
@jpnurmi jpnurmi force-pushed the feat/android-signal-handler-strategy branch from 4486918 to 7a489eb Compare January 2, 2026 08:02
@jpnurmi jpnurmi force-pushed the feat/android-signal-handler-strategy branch from 7a489eb to 543b3e3 Compare January 2, 2026 14:57
@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Jan 26, 2026

Update: I'll get back to this after #4750 to make sure this works with .NET 10

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features ✨

  • feat: native signal handler strategy on Android by jpnurmi in #4676

🤖 This preview updates automatically when you update the PR.

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 9, 2026

While the signal handler strategy fixes the redundant SIGSEGV vs. NullReferenceException issue, the native exception test case breaks with .NET 10 on Android X86_64. 😢 All tests pass locally in an ARM64 Android emulator.

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 9, 2026

.NET 10 on ARM64 and .NET 9.0 on both ARM64 and X86_64 behave as desired when sentry-native calls the runtime's signal handler. It returns to sentry-native which then captures the crash.

.NET 10 on X86_64, however, crashes trying to lock a destroyed mutex? No crash captured.

.NET 9.0 (Android ARM64 & X86_64) 👍

02-09 15:38:46.029  9141  9141 I DOTNET  :   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 15:38:46.029  9141  9141 D app_process64:   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 15:38:46.030  9141  9141 I sentry-native: entering signal handler
02-09 15:38:46.030  9141  9141 D sentry-native: defer to runtime signal handler at start
02-09 15:38:46.031  9141  9141 F libc    : Fatal signal 4 (SIGILL), code 0 (SI_USER) in tid 9141 (egrationtestapp), pid 9141 (egrationtestapp)
02-09 15:38:46.916  9176  9176 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-09 15:38:46.916  9176  9176 F DEBUG   : Build fingerprint: 'google/sdk_gphone64_x86_64/emu64xa:16/BE2A.250530.026.F3/13894323:userdebug/dev-keys'
02-09 15:38:46.916  9176  9176 F DEBUG   : Revision: '0'
02-09 15:38:46.916  9176  9176 F DEBUG   : ABI: 'x86_64'
02-09 15:38:46.916  9176  9176 F DEBUG   : Timestamp: 2026-02-09 15:38:46.136533669+0100
02-09 15:38:46.916  9176  9176 F DEBUG   : Process uptime: 2s
02-09 15:38:46.916  9176  9176 F DEBUG   : Cmdline: io.sentry.dotnet.maui.device.integrationtestapp
02-09 15:38:46.916  9176  9176 F DEBUG   : pid: 9141, tid: 9141, name: egrationtestapp  >>> io.sentry.dotnet.maui.device.integrationtestapp <<<
02-09 15:38:46.916  9176  9176 F DEBUG   : uid: 10235
02-09 15:38:46.916  9176  9176 F DEBUG   : signal 4 (SIGILL), code 0 (SI_USER), fault addr --------
02-09 15:38:46.916  9176  9176 F DEBUG   :     rax 0000000000000000  rbx 00006fff13d88298  rcx 000070002be8ac70  rdx 0000000000000200
02-09 15:38:46.916  9176  9176 F DEBUG   :     r8  0000000000000002  r9  00007fff348293f0  r10 0000000000000005  r11 00006ffe94ecf9d0
02-09 15:38:46.916  9176  9176 F DEBUG   :     r12 000070008c9f9fb0  r13 000070002be8ac80  r14 00006ffe8a9f35f0  r15 000070011be91d80
02-09 15:38:46.916  9176  9176 F DEBUG   :     rdi 000070011be91d80  rsi 0000000000000006
02-09 15:38:46.916  9176  9176 F DEBUG   :     rbp 00006fff13d88298  rsp 00007fff348293c8  rip 00006ffe8a9f35f0
02-09 15:38:46.916  9176  9176 F DEBUG   : 2 total frames
02-09 15:38:46.916  9176  9176 F DEBUG   : backtrace:
02-09 15:38:46.916  9176  9176 F DEBUG   :       #00 pc 00000000000005f0  /data/app/~~Z3VBUbKXonuWeLlN4W2eXQ==/io.sentry.dotnet.maui.device.integrationtestapp-gqdBX9FklKvyqOkUvbN8Zw==/lib/x86_64/libsentrysupplemental.so (crash+0) (BuildId: c2d6e5ae745143957e682d1b4fd73eac1d41a339)
02-09 15:38:46.916  9176  9176 F DEBUG   :       #01 pc 00000000000f4cc8  <anonymous:4a5c6000>
02-09 15:38:46.931  9141  9141 D sentry-native: return from runtime signal handler, we handle the signal
02-09 15:38:46.937  9141  9141 D sentry-native: captured backtrace from ucontext with 2 frames
02-09 15:38:46.937  9141  9141 D sentry-native: captured backtrace with 2 frames
02-09 15:38:46.938  9141  9141 D sentry-native: merging global scope into event
02-09 15:38:46.938  9141  9141 D sentry-native: trying to read modules from /proc/self/maps
02-09 15:38:46.975  9141  9141 D sentry-native: read 443 modules from /proc/self/maps
02-09 15:38:46.975  9141  9141 D sentry-native: sending envelope
02-09 15:38:46.976  9141  9141 I sentry-native: crash has been captured

NET 10.0 (Android ARM64) 👍

02-09 16:44:27.396  8471  8471 I DOTNET  :   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 16:44:27.396  8471  8471 D app_process64:   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 16:44:27.398  8471  8471 I sentry-native: entering signal handler
02-09 16:44:27.398  8471  8471 D sentry-native: defer to runtime signal handler at start
02-09 16:44:27.398  8471  8471 F libc    : Fatal signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x79af81d5a8 in tid 8471 (egrationtestapp), pid 8471 (egrationtestapp)
02-09 16:44:27.875  8508  8508 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-09 16:44:27.875  8508  8508 F DEBUG   : Build fingerprint: 'google/sdk_gphone64_arm64/emu64a:16/BE2A.250530.026.D1/13818094:user/release-keys'
02-09 16:44:27.875  8508  8508 F DEBUG   : Revision: '0'
02-09 16:44:27.875  8508  8508 F DEBUG   : ABI: 'arm64'
02-09 16:44:27.875  8508  8508 F DEBUG   : Timestamp: 2026-02-09 16:44:27.434533683+0100
02-09 16:44:27.875  8508  8508 F DEBUG   : Process uptime: 2s
02-09 16:44:27.875  8508  8508 F DEBUG   : Cmdline: io.sentry.dotnet.maui.device.integrationtestapp
02-09 16:44:27.875  8508  8508 F DEBUG   : pid: 8471, tid: 8471, name: egrationtestapp  >>> io.sentry.dotnet.maui.device.integrationtestapp <<<
02-09 16:44:27.875  8508  8508 F DEBUG   : uid: 10339
02-09 16:44:27.875  8508  8508 F DEBUG   : tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
02-09 16:44:27.875  8508  8508 F DEBUG   : pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
02-09 16:44:27.875  8508  8508 F DEBUG   : signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x00000079af81d5a8
02-09 16:44:27.875  8508  8508 F DEBUG   :     x0  00000079af81d5a8  x1  0000000000000006  x2  b400007bc1c84138  x3  b400007c51c1d888
02-09 16:44:27.875  8508  8508 F DEBUG   :     x4  0000007fdebc1238  x5  b400007c51c1d8e0  x6  6f732e6c61746e65  x7  b400007b91d58798
02-09 16:44:27.875  8508  8508 F DEBUG   :     x8  0000000000000200  x9  0000000000000002  x10 0000000000000001  x11 00000000b74f8fcb
02-09 16:44:27.875  8508  8508 F DEBUG   :     x12 0000000000019002  x13 b6f2fcf39918a7a7  x14 0000000000000008  x15 b400007b020651e8
02-09 16:44:27.875  8508  8508 F DEBUG   :     x16 0000000000000001  x17 0000007d7a904fd0  x18 0000007da9ef4000  x19 0000000000000001
02-09 16:44:27.875  8508  8508 F DEBUG   :     x20 0000007fdebc1400  x21 0000007ada32c298  x22 0000007ada32c298  x23 b400007b0276a2f8
02-09 16:44:27.875  8508  8508 F DEBUG   :     x24 b400007c91c07650  x25 0000007a49a5b590  x26 b400007bc1c84120  x27 0000000000000000
02-09 16:44:27.875  8508  8508 F DEBUG   :     x28 0000007fdebc1860  x29 0000007fdebc1220
02-09 16:44:27.875  8508  8508 F DEBUG   :     lr  0000007d99c724dc  sp  0000007fdebc1220  pc  00000079af81d5a8  pst 0000000080001000
02-09 16:44:27.875  8508  8508 F DEBUG   : 2 total frames
02-09 16:44:27.875  8508  8508 F DEBUG   : backtrace:
02-09 16:44:27.875  8508  8508 F DEBUG   :       #00 pc 00000000000005a8  /data/app/~~s1hgF6ZtWJQ9vnEajeatvA==/io.sentry.dotnet.maui.device.integrationtestapp-uNphE0qc7n7bR5e8MYGTxg==/lib/arm64/libsentrysupplemental.so (crash+0) (BuildId: f20ec64b4897db5a4517ffb4f61067017ceb3b87)
02-09 16:44:27.875  8508  8508 F DEBUG   :       #01 pc 000000000000b4d8  <anonymous:7d99c67000>
02-09 16:44:27.887  8471  8471 D sentry-native: return from runtime signal handler, we handle the signal
02-09 16:44:27.898  8471  8471 D sentry-native: captured backtrace from ucontext with 2 frames
02-09 16:44:27.898  8471  8471 D sentry-native: captured backtrace with 2 frames
02-09 16:44:27.898  8471  8471 D sentry-native: merging global scope into event
02-09 16:44:27.898  8471  8471 D sentry-native: trying to read modules from /proc/self/maps
02-09 16:44:27.944  8471  8471 D sentry-native: read 443 modules from /proc/self/maps
02-09 16:44:27.945  8471  8471 D sentry-native: sending envelope
02-09 16:44:27.945  8471  8471 I sentry-native: crash has been captured

NET 10.0 (Android X86_64) 👎

02-09 15:41:14.428  9380  9380 I DOTNET  :   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 15:41:14.428  9380  9380 D app_process64:   Debug: Triggering a deliberate exception because SentrySdk.CauseCrash(CrashType.Native) was called
02-09 15:41:14.429  9380  9380 I sentry-native: entering signal handler
02-09 15:41:14.429  9380  9380 D sentry-native: defer to runtime signal handler at start
02-09 15:41:14.429  9380  9411 F libc    : FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7001ba602c38)
02-09 15:41:14.429  9380  9410 F libc    : FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x7001ba602c38)
02-09 15:41:14.458   711  2169 I ActivityManager: Process io.sentry.dotnet.maui.device.integrationtestapp (pid 9380) has died: fg  TOP
02-09 15:41:14.459   485   485 I Zygote  : Process 9380 exited due to signal 6 (Aborted)

@jpnurmi
Copy link
Collaborator Author

jpnurmi commented Feb 10, 2026

Claude confidently claims the issue was fixed by:

The fix was backported to release/10.0. We can give it a try later with the next .NET 10 release.

Investigation: .NET 10 x86_64 native crash test failure

Traced the root cause via strace on the Android emulator.

What happens

When sentry-native defers to Mono's signal handler (CHAIN_AT_START), Mono's mono_handle_native_crash walks the managed stack. On .NET 10, this walk uses the MONO_UNWIND_SIGNAL_SAFE flag (added in d34ef7e), which causes AOT method JIT info to be loaded in async-safe mode with ji->async = TRUE. The stack walk callback print_stack_frame_signal_safe was not updated to check !ji->async before calling mono_jit_info_get_method(), which hits:

  • Assertion at jit-info.c:918, condition !ji->async not met

The assertion triggers abort(), and since mono_handle_native_crash already reset SIGABRT to SIG_DFL, the process is killed immediately — before control returns to sentry-native.

Fix

Already merged upstream:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant