Commit 40214c5
* fix(gc): root the iterator drain's live values across `.next()` (#7475)
`js_iterator_to_array` — the `[...iterable]` / `Array.from(iterable)` drain —
held the iterator object, the accumulator array, the `next` closure and the
two property keys in bare Rust locals across a `.next()` call that allocates
the `{ value, done }` result. Any of those allocations can trigger the copying
minor, which moves the values and rewrites only the slots it can see. A moved
iterator leaves its pre-move copy in retired from-space; the next dispatch
reads that copy's STALE field 0 and `dispatch_array_iterator_method` calls
`js_array_length` on a from-space address.
`make_iter_result` / `make_sqlite_iter_result` had the same shape one level
down: the caller-supplied `value` (usually a heap element) and the freshly
allocated result object were live across four more allocations before being
stored. And `dispatch_array_iterator_method` re-used a backing-array pointer
read BEFORE its cursor store, which can allocate.
Root them all in a `RuntimeHandleScope` and re-read every address at its point
of use. All handles are NaN-boxed rather than `root_raw_*_ptr`, so
`scripts/raw_handle_debt.py` stays at 999.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* test(gc): witness + auto-optimize gate for the iterator-drain rooting bug (#7475)
`test_gap_gc_iterator_drain_rooting.ts` mirrors the app-pattern kernel the bug
was found in. Measured: `TypeError: next is not a function` before the fix
under BOTH the default and the auto-optimize link, a from-space FAULT under
`PERRY_GC_PROTECT_FROMSPACE=1`, byte-exact with the oracle after. Registered in
`test-parity/gc_repsel_corpus.txt`, so `gc-moving-witnesses` runs it and
rejects a cell where nothing moved.
`scripts/auto_opt_app_patterns.sh` + `auto-opt-app-patterns.yml` close the
blind spot that let this ship: every other gate sets `PERRY_NO_AUTO_OPTIMIZE=1`
for a deterministic link, so the default path — which rebuilds the runtime with
a per-app feature set and links it over PERRY_RUNTIME_DIR — was tested by
nothing. The gate asserts its subject was live: it reads the linker command
line out of `perry -v` and requires a `perry-auto-*/libperry_runtime.a` that
exists on disk, because the auto-optimizer falls back to the prebuilt archives
by design and a fallback run would pass every output comparison while
exercising the wrong binary.
Also fixes a handle-kind mismatch in the iterator drain: `across_const` panics
on a NaN-boxed handle, so the `.done` read uses `across_nanbox`.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* docs(changelog): fragment for #7495
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* test(ci): prove the auto-optimize gate's liveness matcher can fail (#7475)
`--self-test` feeds `archive_from_log` three canned compile logs and asserts it
accepts a real auto-optimize link line, rejects a run that printed
`auto-optimize: built …` and then linked the PREBUILT archive (the driver's
documented fallback when its cargo rebuild fails), and rejects an empty log.
The middle case is not hypothetical: the first matcher grepped the whole log
and accepted it, so the gate would have passed a run that exercised the wrong
binary — the exact hazard the liveness assertion exists for. The matcher now
reads only the `[link] invoking:` command line, and CI runs the self-test
before the kernels.
Also validated all twelve app-pattern kernels through the auto-optimize link on
this branch: eleven PASS (each linking a freshly built `perry-auto-*` archive
and matching the node oracle byte for byte), `promise_all_chains` is the one
documented skip.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* docs: point the two residual #7475 defects at their own issues
`promise_all_chains` (#7497) and the `array_from_spread_value` symbol-lookup
stale deref (#7498) are separate defects from the iterator-drain rooting bug,
and both are unchanged by it. Naming them individually keeps them out of a
vague remainder on #7475.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* fix(gc): root the iterator receiver before the first allocation (#7475)
Four review findings, all accepted.
`js_iterator_to_array` rooted `iter_f64` AFTER `js_array_alloc(8)` — an
allocation, so a copying minor could move the iterator while it existed only in
the raw argument and the handle would then root a pre-move address. `iter_h` is
now the first thing created in the scope; the null check and the `next` lookup
read back through it.
`dispatch_array_iterator_method` re-derived `arr_ptr` from field 0 after its
cursor store but kept using the raw `iter_obj` PARAMETER to do so, which the
same store could have invalidated. It now roots the receiver at entry and reads
the current address at every use through a shadowing `iter_obj()` closure, so
the pre-collection address is not nameable after that line.
`scripts/auto_opt_app_patterns.sh` refuses to run when the node oracle disagrees
with `.node-version`. The oracle version is a correctness input — every kernel
is diffed byte for byte against it and node patch releases change observable
output — and `gc_repsel_matrix.sh` refuses on the same grounds.
The workflow's relevance filter now also matches `.github/actions/setup-llvm22/`:
it configures the LLVM the gate's compiler is built against, so a change there
can move generated code without touching a line under `crates/`.
Claude-Session: https://claude.ai/code/session_019EHcmXKArA7m42SihYCcgH
* chore: bump version to 0.5.1287
---------
Co-authored-by: Ralph Küpper <ralph@skelpo.com>
1 parent eb8a9ac commit 40214c5
10 files changed
Lines changed: 886 additions & 133 deletions
File tree
- .github/workflows
- changelog.d
- crates/perry-runtime/src/array
- scripts
- test-files
- test-parity
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 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 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments