nodejs / nodejs/node

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

Open
#61,483 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

arm linux single-executable stale
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure in the arm64 Node.js devcontainer using node --experimental-sea-config, postject, and readelf, then compare the .gnu.hash section before and after embedding the blob. Trace the SEA preparation and postject steps to identify why the section is zeroed only in this environment. Done means the embedded SEA binary preserves symbol lookup and can load addons with process.dlopen().

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript, linux
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.