Skip to content

GC shadow stack pollution from opaque handle parameters #347

@aallan

Description

@aallan

Map, Set, and Decimal parameters are pushed to the GC shadow stack (vera/codegen/functions.py line 120) even though they are i32 handle values, not heap pointers. This wastes shadow stack space and could cause false-positive retention if a handle value accidentally passes the heap-pointer heuristic (>= gc_heap_start + 4, aligned to 8 bytes).

Impact

  • Shadow stack space is wasted on non-pointer values
  • A handle value that happens to match the heap range and alignment would cause the GC to mark a random heap object as live, preventing its collection (memory leak, not corruption)

Possible fix

Exclude opaque handle types from the shadow stack push, similar to how Bool/Byte are handled. The compiler knows which parameters are opaque handles at codegen time.

Affects: Map, Set, Decimal, and any future opaque handle types (Json).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodegenCode generation backend

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions