Skip to content

fix: Guard CoreTelephony radio technology read - #9332

Merged
alwx merged 5 commits into
mainfrom
alwx/feature/9330
Oct 13, 2026
Merged

alwx merged 5 commits into
mainfrom
alwx/feature/9330

Conversation

@alwx

@alwx alwx commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

The SDK no longer bridges serviceCurrentRadioAccessTechnology to a Swift dictionary. It reads the raw NSDictionary and copies it under the same @synchronized lock that CoreTelephony uses when it changes the dictionary. connection_effective_type stays enabled by default.

💡 Motivation and Context

Fixes #9312 and #9330. CTTelephonyNetworkInfo returns its internal NSMutableDictionary without a copy and changes it on a private queue. Thus, the Swift bridge read values that CoreTelephony released at the same time. The disassembly of CoreTelephony in the iOS 18.6 and iOS 26.1 simulator runtimes shows this behavior. This PR replaces #9318, which removes the feature.

💚 How did you test it?

The provider, reachability, extra context, and SDK unit tests pass on iOS 18.6. A new test holds the lock in place of CoreTelephony and makes sure that the copy waits for the change. Without the lock, this test failed in two of three runs. The crash cannot occur in tests, because the simulator has no cellular data. The fix still needs a test on a device with a SIM card.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

alwx added 3 commits October 13, 2026 09:43
CTTelephonyNetworkInfo returns its internal NSMutableDictionary from
serviceCurrentRadioAccessTechnology and changes it on a private queue
inside @synchronized on that dictionary. Bridging the result to a
Swift dictionary walked it without the lock, so a concurrent change
released values during the walk and crashed with EXC_BAD_ACCESS.

Read the getter without bridging and copy the dictionary under the
same lock. Move the provider behind the experimental option
enableConnectionEffectiveType, which installs an integration that
registers the provider with SentryReachability.

Fixes #9312
Fixes #9330
With the read guarded by the CoreTelephony lock, the provider stays
enabled by default, so the experimental option, its integration and
the SentryReachability changes are not needed. Restore them to main.
@alwx
alwx marked this pull request as ready for review October 13, 2026 07:53
Add a test that fails when CTTelephonyNetworkInfo stops locking on the
dictionary it returns, or stops returning its internal dictionary.

Move the objc_sync helper from SentryPerformanceTracker to Locks.swift
and use it for the copy.

@philprime philprime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% happy with using the selector based access of a property, but as it is a public one LGTM.

If possible please verify that it also works properly with a real test device as I could imaging CoreTelephony being a partially mock framework in the simulator

@alwx alwx added the run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request label Oct 13, 2026
@sentry

sentry Bot commented Oct 13, 2026

Copy link
Copy Markdown

Size Analysis

1 component analyzed

iOS Builds

Name Configuration Version Download Size Install Size
SDK-Size (iOS)
io.sentry.sample.SDK-Size
Release 9.30.1 (1) 1.3 MB (-8 B) 3.2 MB (0 B)

Configure sentry-cocoa status check rules

@sentry

sentry Bot commented Oct 13, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.30.1 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1224.51 ms 1254.13 ms 29.62 ms
Size 24.14 KiB 1.39 MiB 1.36 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
c8c3374 1232.96 ms 1263.46 ms 30.50 ms
d9571ee 1225.67 ms 1259.02 ms 33.35 ms
88e0b6e 1212.93 ms 1251.27 ms 38.33 ms
02b997a 1224.77 ms 1263.96 ms 39.19 ms
732f9d0 1226.15 ms 1270.74 ms 44.60 ms
b0aa013 1208.48 ms 1244.00 ms 35.52 ms
545ca7e 1233.89 ms 1269.30 ms 35.41 ms
065705e 1217.35 ms 1253.04 ms 35.69 ms
f6e658b 1203.39 ms 1238.34 ms 34.95 ms
89ccfc2 1210.78 ms 1245.02 ms 34.24 ms

App size

Revision Plain With Sentry Diff
c8c3374 24.14 KiB 1.38 MiB 1.36 MiB
d9571ee 24.14 KiB 1.39 MiB 1.36 MiB
88e0b6e 24.14 KiB 1.38 MiB 1.36 MiB
02b997a 24.14 KiB 1.39 MiB 1.36 MiB
732f9d0 24.14 KiB 1.38 MiB 1.36 MiB
b0aa013 24.14 KiB 1.38 MiB 1.36 MiB
545ca7e 24.14 KiB 1.39 MiB 1.36 MiB
065705e 24.14 KiB 1.38 MiB 1.35 MiB
f6e658b 24.14 KiB 1.38 MiB 1.35 MiB
89ccfc2 24.14 KiB 1.38 MiB 1.36 MiB

@alwx
alwx merged commit f0e2408 into main Oct 13, 2026
286 of 354 checks passed
@alwx
alwx deleted the alwx/feature/9330 branch October 13, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved run-full-ci Allows gated GitHub Action workflows to run for a labelled pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EXC_BAD_ACCESS in SentryCellularNetworkTechnologyProvider.technology(from:) bridging serviceCurrentRadioAccessTechnology (9.30.0)

2 participants