nodejs / nodejs/node

SEA building in a Linux arm64 docker container can corrupt the .gnu.hash section of the binary

未关闭
#61,483 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

arm linux single-executable stale
主要语言
JavaScript
星标
122k
派生
37.3k
平均合并
4 天 2 小时
30 天内合并 PR
283

描述

Noticed in https://github.com/nodejs/node/pull/59582, I can only reproduce it locally using docker. The Node.js devcontainer image is enough to reproduce this when run on an arm64 host:

docker pull nodejs/devcontainer:nightly
docker run -it nodejs/devcontainer:nightly

In the container:

echo 'console.log("hello")' > hello.js
echo '{"main":"./hello.js", "output":"./sea-prep.blob"}' > sea-config.json
node --experimental-sea-config sea-config.json
cp `which node` ./hello
readelf -x .gnu.hash ./hello | head -n 100 # shows the section filled with the symbol lookup table
npx postject hello NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
readelf -x .gnu.hash ./hello | head -n 100 # shows a bunch of zeros

This does not reproduce on a bare-metal Linux arm64 server, or Linux x64 (bare-metal or in docker), which I think is why in the Node.js pull request it only fails in the GitHub action on Linux arm64.

The result of this is that the produced Node.js SEA cannot load any addons using process.dlopen(), because it cannot look up the napi_* symbols from itself (the same can be said about any other non-napi addons, which rely on the same mechanism to look up symbols from the binary to load the addons).

贡献指南

打开贡献指南

从这里开始

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

调研方向

使用 node --experimental-sea-config、postject 和 readelf 在 arm64 Node.js devcontainer 中重现该故障,然后比较嵌入 blob 前后的 .gnu.hash 节。跟踪 SEA 准备和 postject 步骤,以确定为什么只有在此环境中该节会被清零。完成的标准是,嵌入后的 SEA 二进制文件能够保留符号查找功能,并可以使用 process.dlopen() 加载 addon。

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

评估

技术栈
docker, javascript, linux
领域
build-system, operating-systems
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

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