iOS: SentryEvent.Exception is null for native crashes, so a BeforeSend callback that dereferences it throws
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- csharp, ios
調査の方向性
Look at src/Sentry/Platforms/Cocoa/SentrySdk.cs line 101 and the ToSentryEvent conversion in CocoaExtensions.cs. Examine how SentryEvent.Exception is populated from sentryEvent.Error. Check if SentryExceptions from the native payload can be used. Review test/Sentry.Tests/Platforms/iOS/SentrySdkTests.cs for existing coverage. Also check the Android bridge for a similar issue. Determine if the fix is to populate Exception or document the null behavior.
索引モデルが issue の本文から書いたものです。
説明
Summary
On iOS, a user's managed BeforeSend callback is invoked for native crashes, and on that path SentryEvent.Exception is always null. A callback that dereferences Exception — entirely correct on every other path — throws a NullReferenceException for native crashes only.
This needs investigating rather than an obvious fix, hence a separate issue. Found while reviewing #5610, which changes what happens after the callback throws but does not introduce the null.
Why the callback runs at all
We deliberately hook the Cocoa SDK's own BeforeSend so that managed event processors and the user's BeforeSend also apply to native events — otherwise a native crash would bypass both:
ProcessOnBeforeSend converts the native event into a managed SentryEvent, runs managed processors, then calls SentryEventHelper.DoBeforeSend.
Why Exception is null
The conversion populates Exception only from an NSError:
var exception = sentryEvent.Error == null ? null : new NSErrorException(sentryEvent.Error);
A signal or Mach-exception crash (SIGSEGV, EXC_BAD_ACCESS, …) carries no NSError, so Error is null and Exception stays null. The native crash detail is still present on the event — it's in SentryExceptions from the deserialized wire-format payload — it just never reaches the Exception property.
The path
flowchart TD
A["Native crash<br/><i>SIGSEGV, no NSError</i>"] --> B["Crash report written to disk<br/><i>process is dead</i>"]
B --> C["Next app launch<br/><i>Cocoa SDK reads the report</i>"]
C --> D["ToSentryEvent()<br/><i>Exception stays null</i>"]
D --> E["User BeforeSend runs<br/><i>e.Exception.Message</i>"]
E --> F["NullReferenceException"]
F --> G["Before #5610<br/><i>crash still reported,<br/>breadcrumb attached</i>"]
F --> H["After #5610<br/><i>crash report dropped</i>"]
Why it's easy to miss
Exception is populated on every managed path, so if (e.Exception.Message.Contains("token")) is correct everywhere an author would test it, and throws only here. Because it throws only here, managed errors keep arriving normally and just the native crashes are affected — the symptom is "we stopped getting iOS crash reports", with nothing pointing at BeforeSend.
Relationship to #5610
#5610 aligns BeforeSend failures with the callback error isolation spec (#5535): the item is dropped rather than sent with the exception stapled on as a breadcrumb. That is the right behaviour in general, and on this path it turns a degraded crash report into no crash report. It is logged at error level and counted in client reports, so it isn't silent, but neither is visible unless you go looking.
So #5610 changes the consequence; this issue is about the cause. ProcessOnBeforeSend gained test coverage for the throwing-callback case in #5610 (test/Sentry.Tests/Platforms/iOS/SentrySdkTests.cs).
Worth deciding
- Should
Exceptionbe populated for native crashes — e.g. synthesised fromSentryExceptions— or is null correct because there is no managed exception object? - If null is correct, is it documented anywhere a user writing
BeforeSendwould see it?SetBeforeSend's XML docs don't mention that the callback also runs for native events. - Does the same gap exist on the Android bridge, where
Native.EnableBeforeSendroutes native events through the managed callback too?
- 主要言語
- C#
- スター
- 775
- フォーク
- 262
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 118
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-dotnet のほかの issue
-
chore: remove stale IL3050/IL3053 workaround from the iOS sample対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6071 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Heap dumps: every SDK shutdown logs "Error waiting for GarbageCollectionMonitor task to complete"対応中かも @pcbeingused33 が今日担当しました。 オープンState: Needs Discussion
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-dotnet#6039 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
.NET Platform: Android Task
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-dotnet#6020 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Move the Blazor WebAssembly sample off the deprecated DevServer対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン.NET Framework: Blazor
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
getsentry/sentry-dotnet#5906 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Docs MSBuild Needs Docs Update
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-dotnet#5691 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
getsentry/sentry-dotnet の issue をすべて見る
似ている issue
-
In-car displays show 0 km/h and P while the AV drives対応中かも @bazilinskyy が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bazilinskyy/coupled-sim#366 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
BaryoDev/umbraco-pwa#196 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
microsoft/fluentui-blazor#5688 ·
メンテナーはふだん 1 日以内に返信
-
bug flaky lsp-transport small
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信