Intel Mac (x64) app hangs on launch, stuck in libffi in cua_driver_node_runtime.node

未关闭
#27 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
73/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
macos, typescript
领域
desktop

调研方向

Start by reading build/entitlements.mac.plist and the macOS packaging and signing configuration that applies its entitlements. Reproduce the launch hang with the Intel x64 build and check whether the proposed entitlement fixes it; the report includes steps, a sample stack, and a successful ad-hoc re-signing test. Done when the Intel app launches and its window appears, with the chosen fix verified.

由索引模型根据 Issue 内容生成。

描述

What happened

I downloaded the x64 build on my Intel Mac and opened it, expecting the app window to show up. It never does. The app just beachballs with the main process sitting at around 60% CPU. The server child does start and listens on 8799, but no window ever appears.

I sampled the main process to see what it was doing (stack is in the logs below). The main thread is stuck in libffi inside cua_driver_node_runtime.node, which gets loaded at startup.

My guess at what's going on: on x86_64, libffi needs writable + executable memory for its closures. The app has the hardened runtime on but only has com.apple.security.cs.allow-jit, and that only covers MAP_JIT mappings, which libffi doesn't use. So the mmap fails, the temp file fallback fails too, and it just keeps looping. That would also explain why arm64 is fine, since libffi uses static trampolines there.

Adding this to build/entitlements.mac.plist fixed it for me:

<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>

To test it, I took the released x64 app, added that entitlement to its existing ones and ad-hoc re-signed it with the same hardened runtime options. After that it launched fine: the server came up, the window showed after about 17s, and ffi_closure_alloc no longer appeared when I sampled the main thread. If you'd rather not widen the entitlements, building libffi in the CUA runtime with static trampolines or MAP_JIT on x86_64 should also work. Happy to open a PR with the entitlement change if that's the approach you want.

Steps to reproduce
  1. Download DuskBot-0.2.15-x64.zip (or DuskBot-intel.dmg) on an Intel Mac
  2. Open it
  3. No window, app stops responding. sample <pid> on the main process shows the stack below
Version

0.2.15 (x64)

Platform

macOS

Engine

No response

Logs or screenshots
macOS 15.7.9 (24G830), Intel MacBookPro16,1

Main thread, from `sample`:

ModuleWrap::Evaluate
  napi trampoline                      (cua_driver_node_runtime.node)
    uniffi_runtime_napi::call::call_ffi_function
      uniffi_runtime_napi::callback::vtable::build_vtable_struct
        uniffi_runtime_core::callback::Module::make_callback_trampoline
          libffi::middle::Closure::try_new
            ffi_closure_alloc
              dlmalloc
                dlmmap
                  mmap                 <- fails
                  open_temp_exec_file_dir
                    mkstemp / openat / fstatat   <- keeps retrying forever

server.log (startup gets as far as forking the server, then nothing):
move to applications: moved, relaunching
startup HTTP cache cleared (no-persisted-version: unknown -> 0.2.15)
fork /Applications/Dusk Bot.app/Contents/Resources/server/desktop-entry.mjs port=8799
主要语言
TypeScript
星标
277
派生
27
平均合并
2 小时 47 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DuskBotAI/duskbot 的其他 Issue

查看 DuskBotAI/duskbot 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。