Commit c92071c
committed
fix: task_state stuck-slot bug on init failure; vm_defuse leak; document api.Runtime.init() staleness invariant
Follow-up deep audit (3 parallel passes: narrow-int @intcast overflow,
the stale-setActive bug class elsewhere, leaks/stale-slices in this
session's own new code) after the ipv6InCidr and activate() bugs.
- task_state.zig claimSlot: slot.status was set to .ready BEFORE
vs.create()/vs.init() ran. On failure (realistically OutOfMemory),
the slot was left stuck .ready with vs == null -- permanently
removed from the pool, since only .empty/.dead slots are reclaimed.
Under sustained memory pressure with repeated spawn attempts, this
could exhaust the task table and produce spurious TooManyTasks well
before 64 live tasks exist. Fixed by only setting .ready after vs is
fully initialized.
- vm_defuse.zig buildDefusedCode: `out` (up to chunk.MaxCode) leaked
if decodeAt (Pass 2) or remapConstFuncIps (Pass 3) failed after the
alloc succeeded -- reachable on every gbc_writer.write() call under
memory pressure. Fixed with errdefer.
- api.Runtime.init() has the identical "returned by value, internal
self-pointers go stale" shape as the activate() bug just fixed, but
is currently safe because every real entry point (run, runPath,
call, etc.) re-activates on its own final address before touching
global state. Documented the invariant so a future method doesn't
silently break it.
Verified clean under standard, -Dpreset=stress, and -Dgc_stress=true.1 parent 50dfa33 commit c92071c
3 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
133 | 143 | | |
134 | 144 | | |
135 | 145 | | |
136 | 146 | | |
| 147 | + | |
137 | 148 | | |
138 | 149 | | |
139 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
596 | 603 | | |
597 | 604 | | |
598 | 605 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
135 | 151 | | |
136 | 152 | | |
137 | 153 | | |
| |||
0 commit comments