Menu

Fixing Sentry's Mach exception handler for Xcode's Enhanced Security
📰

Fixing Sentry's Mach exception handler for Xcode's Enhanced Security

DEV Community: swift·Darkø Tasevski·about 18 hours ago
#LmY2JOIt
#devtoswift#devto#dev#include#handler
Long article (2049 words) — no AI summary yet.
Reading 0:00
15s threshold

This is a follow-up to the post about adopting Xcode's Enhanced Security in an app with a Rust core , and it's about one entitlement from that bundle, platform restrictions, and what it does to crash reporters that catch Mach exceptions. With that key on, the app was killed as soon as the Sentry Cocoa SDK started, and the fix (which went upstream as getsentry/sentry-cocoa#9705 and shipped in Sentry Cocoa 9.36.0) is mostly about registering the exception handler differently and reading the different message the kernel then sends, plus a fallback for Rosetta, which doesn't accept the new registration.

What the kernel is enforcing

A Mach exception handler is how crash reporters on Apple platforms catch a crash before it turns into a signal. The SDK creates a port, asks the kernel to send exceptions like EXC_BAD_ACCESS for the whole task to it, and a dedicated thread waits on that port, writes the report, and replies "not handled" so that the kernel goes on to deliver the usual SIGSEGV .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.