Skip to content

fix: align __cxa_throw mprotect ranges#8221

Merged
supervacuus merged 5 commits into
mainfrom
supervacuus/fix/page_align_addresses_for_mprotect
Jun 26, 2026
Merged

fix: align __cxa_throw mprotect ranges#8221
supervacuus merged 5 commits into
mainfrom
supervacuus/fix/page_align_addresses_for_mprotect

Conversation

@supervacuus

Copy link
Copy Markdown
Collaborator

📜 Description

Page aligns Mach-O (down for start and up for end) section offsets before using them as address and size arguments with mprotect().

Also checked against KSCrash

Ergo: no need to align with upstream. We replace it with develop anyway (no need to introduce surrounding changes to fix this).

💡 Motivation and Context

Fixes #8156

mprotect() has always required page-aligned addresses, but only in xOS/Xcode 27 does it return EINVAL for unaligned addresses.

💚 How did you test it?

  • built with Xcode 27 beta and ran tests on iOS 27 simulator
  • verified that unaligned addresses failed and that aligned addresses successfully added protection on iOS 27 simulator
  • ran the iOS test suite against iOS 18.4 to counter-check

📝 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.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

@supervacuus supervacuus added the ready-to-merge Use this label to trigger all PR workflows label Jun 25, 2026
@sentry

sentry Bot commented Jun 25, 2026

Copy link
Copy Markdown

📲 Install Builds

iOS

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

⚙️ sentry-cocoa Build Distribution Settings

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1210.27 ms 1244.69 ms 34.42 ms
Size 24.14 KiB 1.22 MiB 1.20 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
9787f05 1233.67 ms 1269.00 ms 35.33 ms
119dc37 1217.64 ms 1250.44 ms 32.80 ms
31a83fd 1218.63 ms 1247.18 ms 28.55 ms
5cc1f4e 1223.49 ms 1258.69 ms 35.20 ms
92bcc8f 1233.43 ms 1270.20 ms 36.77 ms
943b250 1214.69 ms 1257.32 ms 42.63 ms
78aad96 1232.02 ms 1262.42 ms 30.40 ms
1caa212 1229.06 ms 1251.23 ms 22.17 ms
2446b3d 1218.36 ms 1253.98 ms 35.62 ms
6844d69 1228.25 ms 1265.20 ms 36.95 ms

App size

Revision Plain With Sentry Diff
9787f05 24.14 KiB 1.18 MiB 1.15 MiB
119dc37 24.14 KiB 1.16 MiB 1.13 MiB
31a83fd 24.14 KiB 1.17 MiB 1.15 MiB
5cc1f4e 24.14 KiB 1.18 MiB 1.16 MiB
92bcc8f 24.14 KiB 1.15 MiB 1.13 MiB
943b250 24.14 KiB 1.17 MiB 1.15 MiB
78aad96 24.14 KiB 1.18 MiB 1.16 MiB
1caa212 24.14 KiB 1.18 MiB 1.16 MiB
2446b3d 24.14 KiB 1.17 MiB 1.15 MiB
6844d69 24.14 KiB 1.20 MiB 1.17 MiB

Previous results on branch: supervacuus/fix/page_align_addresses_for_mprotect

Startup times

Revision Plain With Sentry Diff
3f2d039 1222.11 ms 1258.05 ms 35.93 ms

App size

Revision Plain With Sentry Diff
3f2d039 24.14 KiB 1.22 MiB 1.20 MiB

Comment thread Sources/SentryCrash/Recording/Tools/SentryCrashCxaThrowSwapper.c Outdated
Comment thread Sources/SentryCrash/Recording/Tools/SentryCrashCxaThrowSwapper.c Outdated
@supervacuus supervacuus enabled auto-merge (squash) June 26, 2026 08:58
@supervacuus supervacuus merged commit dde298d into main Jun 26, 2026
277 checks passed
@supervacuus supervacuus deleted the supervacuus/fix/page_align_addresses_for_mprotect branch June 26, 2026 09:53
itaybre pushed a commit that referenced this pull request Jun 26, 2026
* use sysconf(_SC_PAGESIZE) instead of getpagesize()
* wrap sysconf to adhere to POSIX in-band error contract
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

investigate: does SentryCrashCxaThrowSwapper need page-aligned mprotect for iOS 27 (EINVAL)?

2 participants