Skip to content

Preserve shared mappings across fork for PHP PHPTs#717

Closed
brandonpayton wants to merge 66 commits into
Automattic:mainfrom
brandonpayton:kd-nx3-php-phpt-port
Closed

Preserve shared mappings across fork for PHP PHPTs#717
brandonpayton wants to merge 66 commits into
Automattic:mainfrom
brandonpayton:kd-nx3-php-phpt-port

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

Summary

Port of source PR #2 from brandonpayton/kandelo-agentic-dev onto current Automattic/kandelo.

  • Preserve centralized host MAP_SHARED and SysV shared-memory state across fork, wait, detach, and exit boundaries.
  • Wire shared mapping inheritance through Node, browser, and centralized test-helper fork paths.
  • Grow exec-state serialization instead of failing at a fixed 64 KiB buffer under large inherited environments.
  • Refresh ABI evidence for ABI 16 and keep generated host/libc constants aligned.
  • Carry focused integration fixes from the port: select/pselect retry deadlines, IPv6 loopback host-transport fallback, munmap page rounding, Node fs error construction, and host test fixture corrections.

Root Cause

PHP PHPT fork/shared-memory cases exposed platform-level state bugs in the centralized host runtime. Child workers did not inherit enough shared mapping metadata before launch, and the host did not publish process-owned shared-memory writes before wait/exit boundaries, so parent and child processes could observe stale MAP_SHARED or SysV SHM contents.

A separate exec boundary failed because kernel_exec_setup serialized exec state into a fixed 64 KiB buffer. Large inherited dev-shell environments could make execle/vfork paths return ENOMEM before the host replaced envp.

ABI

ABI bumped from 15 to 16. The snapshot records removal of the obsolete kernel_mark_process_exited export and the split kernel_preadv/kernel_pwritev offset signatures into explicit lo/hi i32 args.

Validation

  • bash scripts/dev-shell.sh cargo test -p kandelo --target aarch64-apple-darwin --lib: PASS, 996 passed.
  • bash scripts/dev-shell.sh bash -lc 'cd host && npm run build': PASS, existing CJS import.meta warnings only.
  • Focused host Vitest subset: PASS, 10 files, 121 passed, 3 skipped.
  • Direct mmap shared anonymous fork fixture: PASS, output included PASS.
  • Direct libc regressions via examples/run-example.ts: PASS for functional/popen, functional/vfork, and regression/execle-env.
  • bash scripts/dev-shell.sh scripts/build-musl.sh: PASS.
  • bash scripts/dev-shell.sh scripts/run-libc-tests.sh: PASS, 302 pass, 0 fail, 20 xfail, 1 flaky, 1 timeout, total 324.
  • bash scripts/dev-shell.sh scripts/run-posix-tests.sh: PASS, 174 pass, 0 fail, 3 xfail, 2 skip, total 179.
  • bash scripts/dev-shell.sh bash scripts/check-abi-version.sh: PASS.
  • Full host Vitest: FAIL due missing local artifacts only: 644 passed, 87 failed, 162 skipped/pending. Failure causes were 85 tests missing rootfs.vfs and 2 tests missing programs/wasm64/hello64.wasm.
  • bash scripts/dev-shell.sh bash build.sh: attempted earlier; interrupted at the rootfs/coreutils source fallback with exit 130, so this is not a pass claim.

Browser PHPT validation is intentionally left to follow-up bead kd-dmm after this PR exists.

brandonpayton and others added 30 commits June 19, 2026 01:34
Port the PHP-specific harness, browser VFS/page wiring, PHP 8.3.15 package recipe, libiconv dependency package, and support fixtures from source PR #2 as a scoped checkpoint. General platform fixes and current validation evidence follow in later commits.
(cherry picked from commit 02deaca)
Port the PR #2 shared-memory/fork fixes onto current Automattic/kandelo. Centralized host workers now inherit and synchronize MAP_SHARED and SysV shared memory across fork, wait, detach, and exit boundaries so parent/child processes observe real shared state.

Grow exec-state serialization instead of failing at a fixed 64 KiB buffer, keep Node/browser fork paths in parity, refresh the ABI snapshot for ABI 16, and update focused host/kernel fixtures and tests for the port.
@brandonpayton

Copy link
Copy Markdown
Member Author

Closing this as superseded by the split PHP PHPT PR set.

This PR was the original mixed integration branch for the PHP PHPT port, and its current title understates the branch contents. The harness-only work is now in #736, and the non-harness kernel/runtime/platform fixes have been split into dedicated non-draft [PHP] PRs: #721-#735 and #737-#739. I rechecked coverage before closing: every commit subject currently in #717 is represented across the split PRs.

The specific fix named by this PR title, "Preserve shared mappings across fork for PHP PHPTs", is represented in #737.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant