Host: Reuse saved GOT indices during fork replay - #1308
Open
brandonpayton wants to merge 1 commit into
Open
Conversation
A fork child re-instantiates dynamic libraries before restoring the parent function table. Resolving GOT.func imports through that incomplete table could append duplicate entries, so module-state restoration later trapped on indices that no longer matched the parent. Recover each loader-owned mutable GOT function value from the existing fork module-state snapshot. Reconstruct any saved pre-export table gap, reject missing or conflicting values, and verify that replayed exports publish at the saved table slots. This is an ABI 43 host reconstruction correction. It does not change the fork snapshot wire format or require rebuilt guest artifacts. Regenerate the package program index because the affected host sources participate in package cache identities. Source-commit: 1833bec04161038e76a0d2ca39990ea1c15ad29a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A forked process can restore dynamic libraries before the parent's function
table has been reconstructed. The loader then searched that incomplete table
for
GOT.funcimports and could append duplicate functions at new indices.PHP-FPM exposed the result in the WordPress/MariaDB browser image: the child
reached
wpk_fork_module_state_finish_restorewith table indices that nolonger matched its saved module state and trapped with
unreachable.What changed
GOT.funcvalues from the existing forkmodule-state snapshots during replay.
appending duplicate functions.
export, then let the normal sparse table restore replace the table graph.
replayed exports publish at the saved slots.
The implementation is shared by Node.js and browser process workers. It does
not change the ABI 43 wire format, so no ABI bump or guest artifact rebuild is
required.
Validation
bash scripts/dev-shell.sh bash -lc 'cd host && npx vitest run test/dylink.test.ts test/fork-imported-globals.test.ts test/fork-dlopen-replay-e2e.test.ts'(91 tests passed, including all four real
dlopen/fork end-to-end cases)bash scripts/dev-shell.sh bash build.shprogram-index-checkandprogram-index-context-checkbash scripts/dev-shell.sh bash scripts/check-abi-version.shgit diff --check origin/main..HEADBroader-suite notes
The repository CI wrapper rejected the current
packages/registry/ruby/test/posix-spawn.test.tsinventory before startingVitest. A direct all-host run was also attempted but was not used as passing
evidence because unrelated tests failed. That run exposed the relevant C++
exception/TLS replay case; it is now part of the focused passing group above.
The complete browser WordPress/MariaDB reproduction was not rerun because no
corrected full service VFS artifact was produced after the local package build
was stopped.