Commit d8be3dd
fix(runtime): js_get_iterator must reject a handle-band near-null pointer as non-iterable (#5549)
* fix(runtime): js_get_iterator rejects handle-band pointer as not-iterable
A pointer-tagged value whose payload lies in the small-handle band (e.g. a
near-null POINTER_TAG|1) is not a dereferenceable heap object. js_get_iterator
previously read [Symbol.iterator] off it, found nothing, and returned the bogus
value UNCHANGED as its own iterator; the lazy for-of then called .next() on it,
got undefined, and threw a misleading late 'Iterator result is not an object'
far from the real fault. Throw the correct 'is not iterable' at the point of
iteration instead, and stop manufacturing a bogus iterator from a non-object.
This clears a corpus wall where a deep async config-resolution chain feeds a
corrupted .errors value (POINTER_TAG|1) into a for-of: the binary now advances
past that iterator wall to the sibling WeakMap-key wall (same upstream
value-wiring corruption, separate manifestation). 1072 runtime lib tests pass.
* fix(runtime): move handle-band iterator rejection after @@iterator lookup
The initial guard ran before the `[Symbol.iterator]` lookup and used
is_handle_band (`addr < 0x100000`), which also covers the Web Fetch band
[0x40000, 0xE0000) (Headers/Request/Response), the zlib band, and the
revocable-Proxy band. Those are genuinely iterable handle-backed values
that resolve @@iterator via the small-handle dispatch in
js_object_get_symbol_property, so the early guard threw "not iterable"
before that dispatch ran — breaking `for (const [k,v] of headers)`,
`[...headers]`, and the addr_class_handle_bands integration test.
Move the rejection to the no-method fallthrough, just before
`return val_f64`: iterable handles resolve @@iterator and return early;
only a handle-band pointer that resolved no iterator method (a corrupt
near-null reference) now throws, instead of being returned as its own
bogus iterator. Addresses CodeRabbit review feedback.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H689Q1ongNpQmg9HdYQayS
---------
Co-authored-by: Ralph Küpper <ralph2@skelpo.com>
Co-authored-by: Claude <noreply@anthropic.com>1 parent 981b324 commit d8be3dd
1 file changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
| 2318 | + | |
| 2319 | + | |
| 2320 | + | |
| 2321 | + | |
| 2322 | + | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
2314 | 2334 | | |
2315 | 2335 | | |
2316 | 2336 | | |
| |||
0 commit comments