Skip to content

fix(macos): add hardened-runtime entitlements so the frozen app can start - #292

Open
lyysm wants to merge 1 commit into
OpenBMB:mainfrom
lyysm:fix/macos-signing-entitlements
Open

lyysm wants to merge 1 commit into
OpenBMB:mainfrom
lyysm:fix/macos-signing-entitlements

Conversation

@lyysm

@lyysm lyysm commented Oct 24, 2026

Copy link
Copy Markdown

问题

macOS 正式包在 Hardened Runtime 签名下启动即卡死:日志停在 Runtime started,不监听端口、不出现窗口;且首个卡死实例持有单实例锁,导致后续启动静默退出。详见 #291。

根因

sign_code() 用 --options runtime 签名但未传任何 entitlements。Hardened Runtime 阻止匿名可执行内存映射,pyobjc 导入时 libffi closure 分配失败,转入临时文件回退路径并无限重试(sample 可见主线程 100% 位于 PyObjC_RegisterStructType → dlmmap_locked → mmap/write/unlink 循环),应用永远无法到达服务器启动阶段。

改动

  • 新增 packaging/macos.entitlements:com.apple.security.cs.allow-unsigned-executable-memory + com.apple.security.cs.allow-jit(PyInstaller + pyobjc 应用的标准配置,与公证兼容)
  • sign_code() 签名时传入该 entitlements(sign_app_bundle 对每个 Mach-O 及主 bundle 的签名均生效);无 MAC_SIGN_ID 的 ad-hoc 分支行为不变

验证(macOS 13.7.8 / Intel iMac)

  • 原始发布签名:进程卡死,采样确认卡在 libffi 循环,数分钟无端口、无窗口
  • 相同流程 + entitlements 重签同一 app:45 秒内启动完成,日志推进到 Server starting host=127.0.0.1 port=5174,/chat/ 返回 HTTP 200
  • bash -n / plutil -lint 通过

Fixes #291

…tart

The macOS release is signed with --options runtime (hardened runtime)
but without any entitlements. Hardened runtime blocks anonymous
executable memory, so when pyobjc is imported during startup, libffi
cannot allocate closure memory and falls into an endless temp-file
retry loop. The app hangs after logging 'Runtime started': no server
port, no window, and the macOS single-instance lock makes every later
launch exit silently (issue OpenBMB#35).

Add packaging/macos.entitlements (allow-unsigned-executable-memory and
allow-jit) and pass it to codesign in sign_code(). Verified on
macOS 13.7.8 (Intel): re-signing the released 1.0.0-preview app with
these entitlements lets it start normally (server binds 127.0.0.1:5174,
UI returns HTTP 200), while the shipped signature hangs indefinitely.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] macOS 正式包启动即卡死:Hardened Runtime 签名缺少 libffi/JIT entitlements

1 participant