Found via a node --experimental-strip-types differential sweep on main (macOS arm64).
The TypedArray returned by .map() and .subarray() is usable for direct element access but is structurally broken for the object/iteration paths: JSON.stringify of it segfaults, and Array.from(...) / spread read garbage. .slice() and .filter() results are fine.
Repro
const m = new Int32Array([1, 2, 3]).map(x => x * 2);
console.log(m[0], m[1], m.length); // 2 4 3 OK (direct access works)
console.log(JSON.stringify(m)); // SIGSEGV (node: {"0":2,"1":4,"2":6})
const sub = new Int32Array([1, 2, 3, 4]).subarray(1, 3);
console.log(JSON.stringify(sub)); // SIGSEGV (node: {"0":2,"1":3})
// Array.from corrupts instead of crashing:
console.log(Array.from(new Int32Array([1,2,3]).map(x=>x*2)));
// node: [ 2, 4, 6 ] perry: garbage (wrong element kind/offset)
console.log(Array.from(new Float64Array([1.5,2.5]).map(x=>x*2)));
// node: [ 3, 5 ] perry: garbage
What works vs. doesn't
| op |
result |
direct [i] / .length |
JSON.stringify |
Array.from / spread |
.map(cb) |
new TA |
works |
SIGSEGV |
garbage |
.subarray(a,b) |
view |
works |
SIGSEGV |
garbage |
.slice(a,b) |
new TA |
works |
works |
works |
.filter(cb) |
new TA |
works |
works |
works |
Notes
Severity: crash on a common operation (JSON.stringify(typedArray.map(...))).
Found via a
node --experimental-strip-typesdifferential sweep onmain(macOS arm64).The TypedArray returned by
.map()and.subarray()is usable for direct element access but is structurally broken for the object/iteration paths:JSON.stringifyof it segfaults, andArray.from(...)/ spread read garbage..slice()and.filter()results are fine.Repro
What works vs. doesn't
[i]/.lengthJSON.stringifyArray.from/ spread.map(cb).subarray(a,b).slice(a,b).filter(cb)Notes
map/filtershare the sametypedarray/species.rsspecies_create_length->typed_array_allocpath (which registers the result), and element values store correctly (direct access is right), so the corruption is in how themap/subarrayresult is registered/headered for the object-enumeration / iterator path, not in the element store. Theslice/filter(OK) vsmap/subarray(broken) split is the key clue.Severity: crash on a common operation (
JSON.stringify(typedArray.map(...))).