Skip to content

build: clamp PT_LOAD p_align to 4 KiB on linux-x64 node binary#319355

Merged
deepak1556 merged 1 commit into
mainfrom
robo/fix_wsl1_electron_42
Jun 1, 2026
Merged

build: clamp PT_LOAD p_align to 4 KiB on linux-x64 node binary#319355
deepak1556 merged 1 commit into
mainfrom
robo/fix_wsl1_electron_42

Conversation

@deepak1556
Copy link
Copy Markdown
Collaborator

@deepak1556 deepak1556 commented Jun 1, 2026

Node.js 23/24 linux x64 build ships a dedicated lpstub PT_LOAD segment aligned to 2 MiB (0x200000) so that, at startup the binary can remap its .text region onto Linux hugepages for an iTLB win --use-largepages=mode.

WSL1 binfmt_elf strictly rejects any PT_LOAD whose p_align exceeds the system page size (0x1000); the kernel returns ENOEXEC before user space ever runs. This breaks launching the bundled Node from the VS Code server under WSL1 starting with Node 24.

The fix does not change runtime behavior:

  • Node is a non-PIE EXEC binary with fixed virtual addresses (p_vaddr, p_paddr); the loader maps each PT_LOAD at its hard-coded address regardless of p_align, which on EXEC is metadata describing alignment in memory rather than a request to relocate.
  • No shared libraries, native addons, or dynamic linker paths are touched — only PT_LOAD segments inside the node executable itself.

Fixes #318494

Node.js 23/24 linux-x64 build ships a dedicated `lpstub` PT_LOAD segment
aligned to 2 MiB (0x200000) so that, at startup the binary can remap its
.text region onto Linux hugepages for an iTLB win `--use-largepages=mode`.

WSL1 `binfmt_elf` strictly rejects any PT_LOAD whose `p_align`
exceeds the system page size (0x1000); the kernel returns ENOEXEC and the
shell reports "exec format error" before user space ever runs. This breaks
launching the bundled Node from the VS Code server under WSL1 starting
with Node 24.

The fix does not change runtime behavior:

  - Node is a non-PIE EXEC binary with fixed virtual addresses
    (`p_vaddr`, `p_paddr`); the loader maps each PT_LOAD at its
    hard-coded address regardless of `p_align`, which on EXEC is
    metadata describing alignment in memory rather than a request to
    relocate.
  - The hugepage optimization itself is performed at runtime
    against the live mapping; it does not consult `p_align` and
    is unaffected by this change.
  - No shared libraries, native addons, or dynamic linker paths are
    touched — only PT_LOAD segments inside the node executable itself.
@deepak1556 deepak1556 added this to the 1.124.0 milestone Jun 1, 2026
@deepak1556 deepak1556 self-assigned this Jun 1, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 14:59
@deepak1556 deepak1556 added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Jun 1, 2026
@vs-code-engineering
Copy link
Copy Markdown
Contributor

This PR will be automatically cherry-picked to release/1.123 when merged.

@vs-code-engineering
Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@dmitrivMS

Matched files:

  • test/sanity/src/context.ts
  • test/sanity/src/wsl.test.ts

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Remote Extension Host (REH) build pipeline to patch the bundled linux-x64 Node.js ELF so it can be executed under WSL1 (which rejects PT_LOAD segments whose p_align exceeds the system page size), and removes the now-unnecessary WSL1-only runtime patching from sanity tests.

Changes:

  • Patch linux-x64 Node binaries during REH builds by clamping PT_LOAD p_align to 4 KiB.
  • Remove the WSL1 Node 24 workaround hook from WSL sanity tests.
  • Remove the associated WSL1 patching helper/state from the sanity test context.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
build/gulpfile.reh.ts Adds an ELF program-header patch step and wires it into the linux-x64 Node download pipeline.
test/sanity/src/wsl.test.ts Removes calls to the WSL1 Node workaround before launching the WSL server.
test/sanity/src/context.ts Deletes the WSL1 Node 24 workaround implementation and tracking set.

Comment thread build/gulpfile.reh.ts
@deepak1556 deepak1556 enabled auto-merge (squash) June 1, 2026 15:13
@deepak1556 deepak1556 merged commit f9c62da into main Jun 1, 2026
26 checks passed
@deepak1556 deepak1556 deleted the robo/fix_wsl1_electron_42 branch June 1, 2026 17:38
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node v24 exec format error in WSL 1

3 participants