Skip to content

runtime: SIGSEGV setting (arr as any).length to an invalid value (should throw RangeError) #4175

@proggeramlug

Description

@proggeramlug

Summary

Setting a regular array's length to an invalid value through an any-typed
binding segfaults (SIGSEGV, exit 139) instead of throwing RangeError.

Repro

const a = [1, 2, 3];
try { (a as any).length = -1; } catch (e: any) { console.log("threw", e.name); }
console.log("done");
  • Node: threw RangeError / done
  • Perry: segfaults during the assignment (no output past the array literal)

The statically-typed form likely differs; the as any set routes through the
generic dynamic property-set path.

Crash detail

EXC_BAD_ACCESS (address=0x3ffffffffffffff8) — a raw f64 (2.0 =
0x4000000000000000) is treated as an object pointer and its GC header is read
at [ptr-8]. The faulting frame is a GC_TYPE_SET type check reached from the
array-length set path. So a numeric value is being threaded into a routine that
dereferences it as a heap object.

Scope / provenance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions