Skip to content

Runtime: make heap-limit allocation failures catchable at JS allocation sites #27

Description

@chrisbbreuer

Parent: #24, #11.

The PR-249 semantics/oom-one-thread.js witness now exercises zig-js's real Context.Options.heap_limit_bytes cap instead of relying on the vendored JSC RAM-cap directive. That makes the remaining failure shape much sharper: the cap fires, but the allocation pressure escapes as a whole-Thread completion OutOfMemoryError instead of being caught by the allocating JS frame's local try/catch.

Current probe evidence:

FAIL semantics/oom-one-thread.js: OutOfMemoryError: Context heap limit exceeded

This is different from the already-landed reserved thread OOM completion object: that path is correct for thread startup/completion pressure where JS execution cannot publish a fresh exception object. Here, the allocation happens inside running JS, so the ideal contract is a catchable JS exception at the allocation site.

Acceptance:

  • Allocations that exceed Context.Options.heap_limit_bytes inside an active JS frame throw OutOfMemoryError into that frame.
  • A local JS try/catch around the allocating expression can observe the OutOfMemoryError before it becomes the whole Thread completion result.
  • Host entry pressure before a JS frame exists may still surface as Zig error.OutOfMemory / top-level evaluation failure where appropriate.
  • semantics/oom-one-thread.js passes or progresses past the allocation-site catchability blocker.
  • Existing thread OOM survivor/recovery tests stay green, including sibling join behavior after one thread hits the heap cap.

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