iOS: app crashes at launch (SIGSEGV in `+[SentrySDKInternal startWithOptions:]`) when the DSN is invalid — `RNSentryStart` starts the SDK with nil options
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- ios, objective-c, react-native, swift
- Lĩnh vực
- mobile
Hướng nghiên cứu
Bắt đầu trong RNSentryStart.m tại +startWithOptions:error: và kiểm tra nhánh lỗi của createOptionsWithDictionary:error: được mô tả trong issue. Tái hiện với DSN không hợp lệ trong bản build iOS Release, sau đó xác minh rằng initNativeSdk từ chối với lỗi parse và ứng dụng không còn bị crash; kiểm tra call site được trích dẫn trong RNSentry.mm để xác nhận hành vi kết quả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 369
- Merge trung bình
- 19 giờ 53 phút
- Pull request đã merge (30 ngày)
- 107
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-react-native
-
sendDefaultPii is reported as deprecated on ReactNativeOptions although dataCollection is hiddenCó thể đã có người làm @alwx đã nhận 6 ngày trước. Đang mởBug React-Native
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
getsentry/sentry-react-native#6830 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
React-Native Replays Task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
getsentry/sentry-react-native#6680 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improvement React-Native
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getsentry/sentry-react-native#6143 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
React-Native Task User Feedbacks
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
getsentry/sentry-react-native#5932 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
React-Native Replays Task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
getsentry/sentry-react-native#5882 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/sentry-react-native
Issue tương tự
-
area:deploy task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
wilanis/wilanis-js#1017 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
modelcontextprotocol/servers#5133 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
budget bug feature frontend good-issue medium needs-review OSCI'26 payments
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
SatyamPandey-07/WorkSphere#5990 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
lugassawan/swe-workbench#799 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue javascript
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
yukikotani231/sqlsift#326 ·
Maintainer thường phản hồi trong vòng 1 ngày