Skip to content

FDTables Test Grate/Tests#64

Open
rennergade wants to merge 6 commits intomainfrom
test-rust-fdtables
Open

FDTables Test Grate/Tests#64
rennergade wants to merge 6 commits intomainfrom
test-rust-fdtables

Conversation

@rennergade
Copy link
Copy Markdown
Contributor

Summary

  • Adds examples/fdtables-test-grate/ — a minimal grate that exercises fdtables operations in isolation, with no IPC/pipe/socket logic
  • 24 C tests covering single-cage ops, fork inheritance, concurrent parent+child fd access, deep fork chains, and a mutex/atomic contention probe
  • Identified that the root cause of issue Non-deterministic output by IPC-Grate #59 (non-deterministic IPC grate crashes) is WASM allocator corruption when the Lind runtime dispatches forked cage syscalls to the grate from multiple threads

Isolates fdtables/DashMap behavior in Lind-WASM from grate-specific
logic (pipes, sockets, IPC). Intercepts open/close/dup/dup2/fork/exec
with pure fdtables bookkeeping + forwarding. 11 C tests covering
single-cage ops, rapid cycling, and cross-fork fd inheritance.
- Grate: removed all println output (only prints on errors)
- Added 12 new tests (23 total) focused on fork/exec stress:
  - rapid fork+close (50 iterations)
  - child fd churn (open/dup/write/close loops after fork)
  - concurrent parent+child fd ops
  - fork chain (2 levels), deep fork chain (4 levels)
  - dup2 storm (in-process and post-fork)
  - fork bomb (20 sequential forks)
  - child closes all 15 inherited fds
  - multiple children from one parent (5 concurrent)
  - rapid double-fork (child immediately forks again, 10x)
  - concurrent opens from parent and child simultaneously
Runs before all other tests. Parent and child each write 500 times
concurrently. Grate counts writes with three methods:
- std::sync::Mutex
- AtomicU64::fetch_add
- unsynchronised load+store (control)

Read from magic fd 99 reports all three counters.
If mutex < 1000: Mutex doesn't work cross-thread.
If atomic < 1000: atomics don't work cross-thread.
If unsync == 1000: no real concurrency (single-threaded dispatch).
Init the child cage's fdtable with fds 0-2 in the preexec hook
instead of lazily in each handler. Fork copies parent fdtable
to child directly without checking existence first.
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