Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

iOS: app crashes at launch (SIGSEGV in `+[SentrySDKInternal startWithOptions:]`) when the DSN is invalid — `RNSentryStart` starts the SDK with nil options

已关闭 适合新手
#6,822 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
ios, objective-c, react-native, swift
领域
mobile

调研方向

从 RNSentryStart.m 中的 +startWithOptions:error: 开始,检查 issue 中描述的 createOptionsWithDictionary:error: 失败路径。使用无效 DSN 在 Release iOS 构建中重现,然后验证 initNativeSdk 是否因解析错误而拒绝,并确认应用不再崩溃;检查 RNSentry.mm 中引用的调用点以确认由此产生的行为。

由索引模型根据 Issue 内容生成。

描述

React-Native Waiting for: Product Owner

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

  1. In a Release iOS build, call Sentry.init({ dsn: "$NOT_A_DSN", enableNative: true }).
  2. Launch the app. It crashes as shown above.
  3. 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.

主要语言
TypeScript
星标
1.8k
派生
369
平均合并
23 小时 19 分钟
30 天内合并 PR
113

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

getsentry/sentry-react-native 的其他 Issue

查看 getsentry/sentry-react-native 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。