fork: grow continuations dynamically and recover allocation failures#1043
Open
brandonpayton wants to merge 2 commits into
Open
fork: grow continuations dynamically and recover allocation failures#1043brandonpayton wants to merge 2 commits into
brandonpayton wants to merge 2 commits into
Conversation
Replace the fixed fork continuation capacity with ABI 42 linked, page-backed frame chunks shared across main-process, pthread, browser, Node, and dynamic-linker paths. Preserve truthful fatal cleanup on allocation failure for now and document recoverable ABORT_UNWINDING as the next POSIX-correct step.
Add ABI 42 ABORT_UNWINDING replay so a failed linked-frame allocation reconstructs committed inner frames, releases continuation ownership, and returns the original errno without terminating the process. Negative SYS_FORK results now use the complete parent rewind path as well. Main, pthread, and supported dynamic-side-module paths share the recovery contract; integrity and cleanup failures remain fatal.\n\nThe P-10 stress fixture grows from 52,052 to 58,370 instrumented bytes (+6,318, +12.14%); runtime performance was not measured. The instrumenter suite, focused host/V8 suite, host build, and ABI consistency check pass. Browser validation was attempted but blocked by 35 missing package assets; the broader host suite also remains blocked by missing wasm64/sysroot and stale package artifacts.
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
Kandelo currently stores an instrumented WebAssembly call stack in a fixed 60 KiB continuation buffer while
fork()unwinds. Real fork-heavy programs can exceed that limit, and the resulting write can corrupt adjacent host control memory. Tuning a larger fixed buffer per package only moves the failure point and makes correctness depend on the software being run.An earlier proposal, PR #862, selected a fixed 128 KiB layout for opted-in binaries. It was closed because it was not truly dynamic and still left a hard ceiling. This PR makes continuation capacity follow the actual live call stack instead.
Allocation failure must also obey the POSIX contract. If Kandelo runs out of continuation memory, or the kernel rejects
SYS_FORK, the parent must receivefork() == -1witherrno; the failure must not kill the parent or create a child.What changed
ABORT_UNWINDING, a fourth instrumented state that reconstructs committed inner frames after a later allocation fails.SYS_FORKresults through the complete parent continuation.ENOMEMafter an inner frame commits, verifies preserved locals and cleanup, then proves a negative complete fork and a later successful retry.ABI and artifacts
This completes the unpublished ABI 42 fork contract, so
ABI_VERSIONremains 42. ABI 42 requires:wpk_fork_*control exports, includingwpk_fork_abort_beginandwpk_fork_abort_end.ABI 41 and intermediate ABI 42 programs must be rebuilt with the instrumenter in this PR. Package and VFS binary publication is a rollout step and is not included in this source commit.
Instrumented size
These rows use the identical 27,608-byte raw P-10 Wasm fixture and the same dev-shell compiler invocation. P-10 is a deliberately deep conservative-closure stress fixture, not a package-wide estimate.
a4789e2c6)ABORT_UNWINDINGRuntime performance was not measured, so this PR makes no latency or throughput claim.
Validation
Passed:
scripts/dev-shell.sh bash scripts/ci-run-test-suite.sh fork-instrumentscripts/dev-shell.sh bash -lc 'cd host && npm run build'scripts/dev-shell.sh bash scripts/check-abi-version.shscripts/dev-shell.sh bash scripts/build-programs.shAttempted but not fully runnable in this worktree: