iOS: app crashes at launch (SIGSEGV in `+[SentrySDKInternal startWithOptions:]`) when the DSN is invalid — `RNSentryStart` starts the SDK with nil options
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 84/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- ios, objective-c, react-native, swift
- Bereich
- mobile
Rechercherichtung
Beginnen Sie in RNSentryStart.m bei +startWithOptions:error: und untersuchen Sie den im Issue beschriebenen Fehlerpfad von createOptionsWithDictionary:error:. Reproduzieren Sie das Problem mit der ungültigen DSN in einem Release-iOS-Build und überprüfen Sie anschließend, dass initNativeSdk den Parse-Fehler ablehnt und die App nicht mehr abstürzt; prüfen Sie die zitierte RNSentry.mm-Aufrufstelle auf das daraus resultierende Verhalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Versions: @sentry/react-native 8.17.2, Sentry (Cocoa) 9.19.1, React Native 0.83.6 (New Architecture, prebuilt), Expo SDK 55, iOS 26.6.2 (device) and the iOS Simulator.
What happens
If Sentry.init({ dsn }) receives a string that the native SentryDsn parser rejects (in our case an unexpanded build variable, "$SOME_ENV_VAR"), the app crashes with EXC_BAD_ACCESS / KERN_INVALID_ADDRESS at 0x10 about 0.4 s after launch. The crash happens on the main thread, inside the initNativeSdk TurboModule call. Nothing reaches Sentry, because the crash happens while Sentry itself is starting.
Symbolicated stack (local Release build, lldb)
#0 +[SentrySDKInternal startWithOptions:] options=0x0 SentrySDKInternal.m:246
options.initialScope([[SentryScope alloc] initWithMaxBreadcrumbs:options.maxBreadcrumbs])
#1 SentrySDK.start(options: nil) SentrySDK.swift:121
#4 +[RNSentryStart startWithOptions:jsSdkVersion:] options=0x0 RNSentryStart.m:44
#5 +[RNSentryStart startWithOptions:error:] RNSentryStart.m:24
#6 -[RNSentry initNativeSdk:resolve:rejecter:] RNSentry.mm:188
Cause
In RNSentryStart.m, +startWithOptions:error: calls createOptionsWithDictionary:error:. When PrivateSentrySDKOnly optionsWithDictionary:didFailWithError: fails (for example, on an invalid DSN), that returns nil and sets *errorPointer. +startWithOptions:error: doesn't check for this. It goes on to updateWithReactDefaults: and updateWithReactFinals: (both no-ops on nil), then calls [self startWithOptions:nil jsSdkVersion:…], which calls [SentrySDK startWithOptions:nil]. SentrySDKInternal then calls the nil options.initialScope block. initNativeSdk checks error only after this, and by then the app has already crashed.
Repro
- In a Release iOS build, call
Sentry.init({ dsn: "$NOT_A_DSN", enableNative: true }). - Launch the app. It crashes as shown above.
- With a well-formed DSN, it launches normally.
Expected
RNSentryStart startWithOptions:error: should return early when createOptionsWithDictionary fails, so initNativeSdk rejects with the parse error (SentryReactNative) and the app keeps running without native Sentry. Separately, SentrySDKInternal startWithOptions: could guard against nil options, since its Objective-C signature doesn't prevent nil.
Workaround we shipped: validate the DSN shape in JS before Sentry.init, and fail our build when the configured DSN is invalid.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 1.8k
- Forks
- 371
- Ø Merge
- 1 T. 6 Std.
- Gemergte PRs (30 T.)
- 115
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-react-native
-
React-Native Replays Task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
getsentry/sentry-react-native#6680 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Improvement React-Native
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getsentry/sentry-react-native#6143 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
React-Native Task User Feedbacks
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
getsentry/sentry-react-native#5932 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
React-Native Replays Task
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-react-native#5882 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Good First Issue React-Native Task
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
getsentry/sentry-react-native#5771 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in getsentry/sentry-react-native
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
VictoriaMetrics/victorialogs-datasource#747 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug from-studio
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
esengine/DeepSeek-Reasonix#14608 ·
Maintainer antworten meist innerhalb von 1 Tag
-
triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
getarcaneapp/arcane#4590 ·
Maintainer antworten meist innerhalb von 1 Tag
-
支持对已取消(cancelled)任务生成报告Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Clouditera/VulnHunter#57 ·