Goal
Audit and migrate remaining direct Object.elements storage reads/writes that can become reachable from shared-realm no-GIL JavaScript, so element-backed arrays, Maps/Sets, iterator helper state, and engine tuples consistently go through Object.elements_lock or a narrower documented synchronization path.
Why this deserves its own tracker
The memory-model docs already say residual direct element side doors are tracked, but the current codebase still has many direct elements.items / elements.append / clear/shrink sites across builtins.zig, interpreter.zig, structured_clone.zig, vm.zig, C API helpers, and tests. Some are private construction or single-owner paths; others may be reachable from shared-realm parallel JS. That classification is too broad for drive-by edits and should be made explicit.
Evidence from the current audit:
rg -n "\.elements\.items|\.elements\.append|\.elements\.clear|\.elements\.deinit|\.elements\.orderedRemove|\.elements\.swapRemove|\.elements\.shrink|\.elements\.insert|\.elements\.replaceRange" src -g'*.zig'The audit includes direct users in:
src/builtins.zigsrc/interpreter.zigsrc/structured_clone.zigsrc/vm.zigsrc/c_api.zigsrc/context.zigtest/witness code
Acceptance criteria
- Classify each direct
Object.elementsaccess as one of:- private construction before publication,
- single-owner host/C API path,
- GC/finalization trace/finalize path with its own stop-the-world or lock rule,
- shared-realm reachable and requiring
Object.elements_lock, - test-only witness that should be rewritten or documented.
- Migrate shared-realm reachable reads/writes to existing helpers (
elementAt,setElementAt,appendElement, dense helpers, snapshots) or add a narrower helper with documented lock scope. - Never hold
Object.elements_lockacross JS callbacks. - Add focused no-GIL/TSan witnesses for any migrated public path.
- Update
docs/threads/bindings.mdafter the residual side-door list shrinks, so #12 stays honest.
Notes
This is not claiming all direct uses are bugs. The first deliverable is classification; code changes should be small and evidence-backed.