iOS: app crashes at launch (SIGSEGV in `+[SentrySDKInternal startWithOptions:]`) when the DSN is invalid — `RNSentryStart` starts the SDK with nil options
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- ios, objective-c, react-native, swift
- Ambito
- mobile
Direzione di ricerca
Inizia in RNSentryStart.m in corrispondenza di +startWithOptions:error: e analizza il percorso di errore di createOptionsWithDictionary:error: descritto nell’issue. Riproduci il problema con il DSN non valido in una build iOS Release, quindi verifica che initNativeSdk rifiuti l’errore di parsing e che l’app non vada più in crash; controlla il call site citato in RNSentry.mm per il comportamento risultante.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 1.8k
- Fork
- 369
- Merge medio
- 23h 19m
- PR unite (30g)
- 113
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di getsentry/sentry-react-native
-
React-Native Replays Task
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
getsentry/sentry-react-native#6680 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Improvement React-Native
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
getsentry/sentry-react-native#6143 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
React-Native Task User Feedbacks
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
getsentry/sentry-react-native#5932 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
React-Native Replays Task
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
getsentry/sentry-react-native#5882 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Good First Issue React-Native Task
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
getsentry/sentry-react-native#5771 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/sentry-react-native
Issue simili
-
e2e-failure ready-to-code
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
redhat-developer/rhdh-plugin-export-overlays#4391 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
Luligu/matterbridge#655 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
software-mansion/argent#1457 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
schmayterling/hibi#245 ·
I maintainer di solito rispondono entro 1 giorno
-
After a failed save, the red error banner stays on every page until the app is reloadedForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertaai-driven-qa bug claude Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
linagora/twake-contacts-frontend#241 ·
I maintainer di solito rispondono entro 1 giorno