Skip to content

SIGSEGV: garbage key reaches set_field_by_name_object_tail when a strict arm holds a frozen class instance with a field named caller #9542

Description

@proggeramlug

A .cts whose strict arm contains a frozen class instance with a field named
caller, written with +=, segfaults — and the fault lands on an earlier
statement in the same function, so it is a module-shape effect rather than a bad
statement.

* thread #1, stop reason = EXC_BAD_ACCESS (code=1, address=0x23c88c00000)
  frame #0: perry_runtime::object::field_set_by_name::tail::set_field_by_name_object_tail + 812
->  ldrb   w11, [x9], #0x1        ; key_bytes_hash reading the key
    eor    x11, x1, x11
    mul    x1, x11, x10

set_field_by_name_object_tail is hashing a garbage key pointer: the
receiver/key reached the by-name setter with the key naming unmapped memory.

Repro

Attached repro (also reproducible from
test-files/test_gap_9459_property_set_strictness.cts with a frozen
class CallerCell { caller: number } instance added to its strict arm). Output
stops after

strict frozen for-of head computed: TypeError 1

so the crashing statement is the NEXT one — computedPlus[computedKey] += 1, a
strict compound assignment through the Expr::IndexSet runtime-string-key arm —
even though the trigger is the caller-named class field later in the
function. Removing only the class-field case makes the whole file pass; removing
any other case does not.

What is known

Where to start

The key operand for the strict o[k] += v lane is rooted by
with_operands_rooted_across(ctx, &[object, index], &[value], …) in
expr/index_set.rs, so this is more likely a stale interned-key handle or a
dispatch-id/string-pool index collision than a missing root — the #7201/#7640
family, but the guard is present, so the pointer is probably wrong rather than
merely moved. Dumping --trace llvm for the crashing function and comparing the
key global against the string pool is the first step.

Found while adding caller/arguments receiver-path coverage to
test_gap_9459_property_set_strictness.cts (PR #9519). That fixture omits the
frozen-class-field-named-caller case with a comment pointing here; it belongs
back in the file once this is fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions