iOS: app crashes at launch (SIGSEGV in `+[SentrySDKInternal startWithOptions:]`) when the DSN is invalid — `RNSentryStart` starts the SDK with nil options
维护者通常 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 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 1.8k
- 派生
- 369
- 平均合并
- 23 小时 19 分钟
- 30 天内合并 PR
- 113
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
getsentry/sentry-react-native 的其他 Issue
-
React-Native Replays Task
难度 2/5 1-3 小时 新手友好度 88/100
getsentry/sentry-react-native#6680 · 1 条评论 ·
维护者通常 1 天内回复
-
Improvement React-Native
难度 2/5 1-3 小时 新手友好度 68/100
getsentry/sentry-react-native#6143 · 2 条评论 ·
维护者通常 1 天内回复
-
React-Native Task User Feedbacks
难度 2/5 1-3 小时 新手友好度 84/100
getsentry/sentry-react-native#5932 · 2 条评论 ·
维护者通常 1 天内回复
-
React-Native Replays Task
难度 2/5 1-3 小时 新手友好度 65/100
getsentry/sentry-react-native#5882 · 1 条评论 ·
维护者通常 1 天内回复
-
Good First Issue React-Native Task
难度 1/5 1 小时以内 新手友好度 65/100
getsentry/sentry-react-native#5771 · 1 条评论 ·
维护者通常 1 天内回复
查看 getsentry/sentry-react-native 的全部 Issue
相似的 Issue
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
OWASP/cve-lite-cli#1335 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 66/100
code-yeongyu/senpi#3353 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Channels status: needs triage
难度 2/5 1-3 小时 新手友好度 70/100
mastra-ai/mastra#27093 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement needs-triage ui
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复