Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng Phù hợp với người mới
#6,822 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

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.

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-react-native

Tất cả issue của getsentry/sentry-react-native

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.