Commit 7cf49bf
committed
fix: stale tasks_mod.g_state pointer in manually-driven VMContext tests; add GBC/task/compiler coverage
Runtime.activate() re-pins 8 process-global setActive pointers because
Runtime is returned by value from test helpers and Zig does not
guarantee that copy is elided -- every real run/call entry point calls
activate() on its own final, stable address for exactly this reason.
compiler_test.zig's ~28 tests that build a vm.VMContext by hand and
call vm.run()/vm.callGlobal() directly (needed to drive
gbc_reader.read() before there's a compiled program the normal entry
points could run) instead re-pinned only 3 of those 8 pointers by hand
-- chunk/globals/heap -- leaving tasks_mod.g_state (among others)
pointed at a test helper's now-defunct stack frame.
Undetected because nothing dereferenced the stale pointer under normal
test runs; found when a coverage-audit test happened to trigger a GC
while running through this exact path (vmAllocObject under
-Dgc_stress=true, a CI-only lane the local pre-push hook never runs):
collectGarbage's task-table walk read 0xAA-poisoned freed memory as
temp_root_top and panicked. Fixed by replacing the manual 3-pointer
triplet with rt3.activate() everywhere it occurred, and documented the
hazard on activate() itself. Verified clean under both -Dgc_stress=true
and -Dheap_paranoia=true (both CI-only, never run locally before now).
Also closes three coverage gaps found in the same audit:
- GBC reader malformed-wire header/section-table error paths
(HeaderTooSmall, UnsupportedHeaderVersion, FormatMajorMismatch,
NonZeroReserved, OptionsMismatch, VMFingerprintMismatch,
TruncatedHeader, TruncatedBody, MalformedSectionTable,
SectionOutOfBounds, MissingRequiredSection, BadConstantTag,
FuncRefOutOfRange, TypeRefOutOfRange) via checksum-recomputing
corruption tests on real round-tripped artifacts.
- Task scheduler: MaxTasks=64 ceiling (TooManyTasks), a task spawning
another task, and 5 concurrently-ready tasks' FIFO reply order --
previously only ever tested with <=2 tasks.
- Compiler: MaxTypes=1024 ceiling (TooManyTypes). DuplicateField
turned out to already be thoroughly covered by tests/spec/fail/
{009,017,216,217,218,219,220,221,222}, contrary to the audit's
initial (grep-based, and wrong) claim of zero coverage.1 parent c768d69 commit 7cf49bf
3 files changed
Lines changed: 543 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
5 | 49 | | |
6 | 50 | | |
7 | 51 | | |
| |||
0 commit comments