[POSIX] Keep directory streams usable when rewind fails - #1063
Open
brandonpayton wants to merge 1 commit into
Open
[POSIX] Keep directory streams usable when rewind fails#1063brandonpayton wants to merge 1 commit into
brandonpayton wants to merge 1 commit into
Conversation
Open the replacement iterator before retiring the active stream, and keep the old state authoritative if opening or closing the replacement sequence fails. Add direct host-bridge coverage for throwing close calls, numeric handle reuse, and partial Wasm marshalling so pending entries cannot leak or disappear across retries.
Contributor
Phase B-1 matrix build status —
|
| Package | Arch | Status | Sha |
|---|---|---|---|
| kandelo-sdk | wasm32 | built | e2df6499 |
| rootfs | wasm32 | built | a0d29e15 |
| shell | wasm32 | built | 7a287cb2 |
| lamp | wasm32 | built | f7c8d643 |
| node-vfs | wasm32 | built | 92c72b70 |
| wordpress | wasm32 | built | 2373060b |
Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.
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 sometimes recreates a host directory iterator to move a directory stream back to the beginning. The legacy
rewinddirpath closed the live iterator before opening its replacement. If opening the replacement failed, the kernel still pointed at a handle that was already closed, so the caller could no longer continue reading from its previous position.The directory-entry retry cache added in #1060 is cleaned up in every reachable production lifecycle path, but its failure edges were not directly tested. A later change could accidentally retain an entry after a failed close or replay an entry that belongs to an older use of the same numeric handle.
What changed
PlatformIOdirectory handle is opaque and cannot identify two live iterators at once.rewinddirbehavior in the POSIX status reference.Platform contracts
This protects POSIX directory-stream state and the shared host bridge used by both Node.js and browsers. It does not change the Wasm ABI, package artifacts, or VFS image format.
A
WeakMapis intentionally not used. Directory handles cross the Wasm boundary as numbers, whileWeakMaprequires object keys and garbage collection cannot own POSIX resource lifetime. A future ownership consolidation, if needed, should be a strongly owned directory-record registry or the planned machine-wide open-file-description table.Validation
./scripts/dev-shell.sh bash scripts/ci-run-test-suite.sh cargo-kernel— 1,246 passed.host/test/readdir-atomicity.test.tsVitest run without unrelated guest-fixture setup — 5 passed../scripts/dev-shell.sh bash -lc "cd host && npm run typecheck"— passed.git diff --check— passed.The standard full Vitest setup was not used as local evidence because this clean worktree has no current musl sysroot. Repository CI will build matching guest fixtures and run the complete host suite.