Skip to content

Runtime: make heap caps collect/retry before unrecoverable OOM #29

Description

@chrisbbreuer

Parent: #24, #27, #14.

While continuing #27 after the catch-binding fix, the PR-249 semantics/oom-one-thread.js witness still fails with a whole-thread/top-level OutOfMemoryError:

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

The previous #27 slice made local catch (e) under Context.Options.heap_limit_bytes work for focused allocation pressure. The remaining witness shape is different: after the hog thread catches/reports OOM and drops its JS references, later allocations must recover. Today the heap cap is enforced by BudgetAllocator at the context allocator layer. In arena-backed mode there is no individual reclamation, and even enabling GC/parallel mid-script collection locally did not make the witness pass; the cap still reaches an unrecoverable OOM path rather than a collect-then-retry/recover path.

Local probes (not committed):

  • Enabling GC/parallel_js/parallel_midscript_gc for just semantics/oom-one-thread.js changed one run to a raw top-level error.OutOfMemory with no JS exception when stringifying would otherwise print ?, and with a higher 320MiB cap still failed as reserved OutOfMemoryError.
  • This suggests the missing contract is not simple catch binding anymore; it is heap-cap recovery: when a capped GC-backed context hits the cap, the runtime needs a safe collection/retry or emergency-headroom policy before declaring OOM unrecoverable.

Acceptance:

  • For GC-backed capped contexts, allocation pressure attempts an appropriate safe collection/retry before surfacing unrecoverable OutOfMemoryError.
  • The policy is safe with threads: no collection while unscanned running peers can hold native-stack roots, unless using the abort-safe parallel mid-script protocol.
  • Dropping JS references after an OOM lets later allocations succeed once the collector can reclaim unreachable cells/backing stores.
  • semantics/oom-one-thread.js passes or progresses to a more specific non-recovery blocker.
  • Existing focused Runtime: make heap-limit allocation failures catchable at JS allocation sites #27 regressions remain green: optional catch, catch binding, string pressure, and sibling Thread survival.
  • Update docs/threads/limits.md and docs/threads/testing.md to distinguish fail-closed arena caps from reclaimable GC-backed capped contexts.

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