fix(build): make post-install ELF interpreter patching relocatable - #5
fix(build): make post-install ELF interpreter patching relocatable#5dohernandez wants to merge 1 commit into
Conversation
post-install baked an absolute in-tree PT_INTERP at the directory it ran in, so moving the tree afterwards left a stale interpreter and the binaries failed to exec (kernel reports ENOENT for the loader, which misleadingly implicates the executable itself). Manual tarball installs that stage then move hit this; automated deploys that run post-install in place do not. Two self-contained fixes in post-install: - Re-point the interpreter whenever it differs from the wanted absolute path, instead of only when the current one is missing. This makes the patch idempotent and lets a re-run in the final location always correct a stale PT_INTERP, even if the old path still exists. - Add --install-root so a staged install can bake the FINAL location's lib/libc.so into PT_INTERP in one pass (PT_INTERP must be absolute, so it cannot be made relative; targeting the final path is the fix). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
GenVM PR actionsTick a box to run it (the box unticks itself when handled). Actions only run while the PR has the
Full GenVM CI runs only when |
The bug (reported via NOD-1026, node rollout of v0.6.1)
post-install.py's lief bin-patch rewrites each binary's ELF program interpreter (PT_INTERP) to an absolute in-tree path —<install-dir>/lib/libc.so— computed at whatever directory post-install runs in. If the tree is moved after post-install, that path is stale and the kernel fails to exec the binary:Hit on 2 boxes during rollout; only manual tarball installs that stage-then-move are affected (automated deploys run post-install in place). Verified on
genvm v0.6.0-rc0.Fix (self-contained, post-install only)
patch_executableskipped patching whenever the current interpreter path merely existed. It now re-points whenever the interpreter isn't already the wanted absolute path. So re-running post-install in the final location always corrects a stalePT_INTERP— even if the old path still lingers (copied, not moved).--install-rootoverride. A staged installer that builds in dir A but deploys to dir B can now runpost-install.py --install-root /final/pathto bake B's loader in one pass, no re-run needed. Validated to be absolute (PT_INTERPrequires it).Scope / what this does NOT do
PT_INTERPmust be absolute — the kernel does not honor$ORIGIN/relative interpreters — so a binary cannot be made freely relocatable after install by this change alone. Full "move the installed tree anywhere, anytime, no action" would require a launcher that re-execs via the loader plus changing how genvm resolves its own dir (it usesstd::env::current_exe()→/proc/self/exe, which a loader-launcher would break), and the executor binary lives in thegenvm-executorsubmodule — i.e. a cross-repo change. That's out of scope here; this PR makes the in-place / staged-install path robust, which covers the reported failure.Testing
py_compileclean;--helpshows--install-root; relative--install-rootis rejected.Node side: NOD-1026 (https://linear.app/genlayer-labs/issue/NOD-1026) tracks the node's doctor/self-heal mitigation.
🤖 Generated with Claude Code