host: make pthread launch publication atomic - #892
Open
brandonpayton wants to merge 3 commits into
Open
Conversation
This was referenced Jul 11, 2026
Require every clone host callback to return an abortable ready-state handle. Validate parent-TID writes before provisional allocation, tie cleanup to process generations and memory identity, and keep all rollback before CH_COMPLETE. Retire pending launches during exec/exit on both Node and browser hosts, preserve custom PlatformIO and MariaDB runners, and cover invalid pointers, stale generations, publication failure, reused coordinators, and the P-10 custom-host path.
Member
Author
|
CI update for |
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.
Purpose
Make pthread creation truthful and atomic across Node and browser hosts, including when a fork child starts a new thread from an atfork callback.
This unblocks Tcl's normal notifier-thread restart after fork and protects every guest that creates pthreads after process transitions. It is a shared host-runtime fix, not a Tcl compatibility path.
Root cause
Two host defects combined in the failing path:
patchWasmForThread()could infer__wasm_call_ctorsfrom a debug name-section entry when no semantic linker/export evidence existed. Neutralizing that unrelated function produced an invalid thread module, so the Worker failed before running guest code.clonepublished success andCLONE_PARENT_SETTIDbefore the backing Worker had instantiated and initialized TLS, stack, and channel state. A setup failure could therefore leave a provisional kernel thread, channel, control slot, or Worker behind after the guest had observed success. Late cleanup could also collide with reused TIDs or channels after exec.Tcl exposes this normally: its fork-child atfork callback restarts the notifier pthread. The failure belongs to Kandelo's shared thread lifecycle rather than the package.
Fix
__wasm_call_ctorsonly from semantic export/linker-wrapper evidence, validate its() -> ()signature, and never treat debug names as rewrite authority.start()and prepublicationabort()operations.EFAULTfor invalid ones.CH_COMPLETEthe publication boundary: all fallible setup and rollback precede it;thread_startfollows it and a postpublication start failure becomes ordinary thread death rather than a second clone completion.PlatformIOharness, and the MariaDB package test runner.Validation
All commands ran through
scripts/dev-shell.shon current ABI 18 main.PlatformIOpaths.f678e098e: all passed. A separate test-gap audit reran 27 lifecycle/patch tests: all passed. Both reviews accepted the head with no blocking finding.wasm64/hello64.wasmfixture; after building the wasm64 musl sysroot and program fixtures, the exactwasm64.test.tssuite passed 3/3.fork-child-thread.spec.ts: passed with the locally built P-10 fixture and local kernel.git diff --check: passed; worktree clean.The initial browser attempt stopped during Vite dependency scanning because ABI 18
node.wasmandnode-vfs.vfs.zstwere absent. After resolving those declared demo prerequisites, the exact Chromium test passed. Those registry artifacts are test-runner setup only and are not Homebrew bottle evidence.CI should run the complete kernel, fork-instrument, Vitest, browser, libc, POSIX, and Sortix gates on the pushed head. No package archive, Homebrew bottle, VFS release artifact, or ABI contract changes in this PR.