Seafile Client crashes on launch/shutdown with EXC_GUARD (GUARD_TYPE_MACH_PORT) on macOS with Hardened Runtime enabled
The result of a longer Claude-session. Claude thought, this could be of general interest. Of course I'm not expecting any efforts for this exotic configuration...
Environment
- Seafile Client version: 9.0.21
- macOS version: 15.7.9 (Sequoia)/OCLP 2.4.1
- Hardware: MacBookPro9,1 (2012, Intel, native Metal support)
- Notes: Reproduces reliably on this machine; other Intel Macs on the same macOS build (Metal-supported; e. g. MacBook Air 6,2 2013 or MacBook Pro 10,2 2012) do not show the issue. Installed via OpenCore Legacy Patcher (no graphics root patches applied on this model, since it has native Metal support — the crash is not tied to any OCLP graphics patch). Description seafile-applet crashes shortly after startup / during shutdown with a kernel EXC_GUARD (GUARD_TYPE_MACH_PORT) exception, terminating with SIGKILL. The crash disappears completely if the app is re-signed without Hardened Runtime (codesign --force --sign - "Seafile Client.app", dropping the runtime code signing option). This strongly suggests the crash is related to a Mach IPC guard violation that only the kernel enforces for Hardened-Runtime-signed processes. Crash report (relevant excerpt)
Exception Type: EXC_GUARD (SIGKILL) Exception Codes: GUARD_TYPE_MACH_PORT Exception Codes: 0x0000000000010b37, 0x0000000000000000 Termination Reason: Namespace GUARD, Code 2305845208237017911
Thread 10 Crashed: 0 libsystem_kernel.dylib _kernelrpc_mach_port_deallocate_trap + 10 1 libsystem_kernel.dylib mach_port_deallocate + 17 2 libsystem_kernel.dylib mach_msg_destroy + 34 3 seafile-applet 0x1036ca935 0x103612000 + 756021 4 Foundation __NSFireMachPort + 83 5 CoreFoundation __CFMachPortPerform + 280 6 CoreFoundation CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 41 7 CoreFoundation __CFRunLoopDoSource1 + 539 8 CoreFoundation __CFRunLoopRun + 2752 9 CoreFoundation CFRunLoopRunSpecific + 536 10 Foundation -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 216 11 seafile-applet 0x1036ca60b 0x103612000 + 755211 12 Foundation NSThread__start + 1014 13 libsystem_pthread.dylib _pthread_start + 115 14 libsystem_pthread.dylib thread_start + 15 The crashing register (rbx/rsi/r15 = 0x10b37) matches the guarded Mach port name in the exception codes exactly, confirming the app itself (frame 3, offset +756021 inside seafile-applet, no debug symbols available) is trying to deallocate a Mach port right that the kernel considers guarded/invalid at this point. The call path (NSRunLoop → __NSFireMachPort → app code) points to an NSMachPort/NSConnection-style IPC mechanism somewhere in the client's cross-process communication (possibly related to the Finder Sync extension / applet IPC), which appears to run afoul of the stricter Mach port guard enforcement macOS applies to Hardened-Runtime binaries.
Steps to reproduce
- Install the current Seafile Client build (properly signed, Hardened Runtime enabled) on the affected machine.
- Launch the app / let it run for a while / quit it.
- Observe the crash in Console.app or ~/Library/Logs/DiagnosticReports/.
Workaround Stripping Hardened Runtime while preserving each bundle component's original entitlements (frameworks, helper apps, the Finder Sync .appex, then the main app) avoids the crash entirely. A blanket codesign --deep --sign - on just the outer app also avoids the crash but breaks the Finder Sync extension, since it wipes the entitlements (e.g. App Group) that the extension needs to communicate with the main app — so the fix needs to be applied per-component with entitlements preserved, not just at the top level.
Request Would appreciate if someone with access to a build with debug symbols could resolve the exact function at offset +756021 in seafile-applet (or the corresponding source location for the NSMachPort-based IPC code), to identify which Mach port lifecycle is mishandled under Hardened Runtime
Source: haiwen/seafile