ReviewOS

zig-utils/zig-js

VM: publish initialized global-binding quick caches

#629
Closed chris opened this 9 days ago ·
9 days ago

Problem

The exact Zig 0.17.0-dev.1818+7051f8e73 Linux unit shard deterministically panics in vm: quickens isolated polymorphic own-data property loops with exact steps with switch on corrupt value at quickGlobalBindingValue while reading a QuickGlobalBinding union.

Evidence: CI run 32338430544, unit shard 3. The stack reaches the cache through a getter invoked during the polymorphic property loop.

recordQuickGlobalBinding currently stores a newly allocated, uninitialized union pointer in chunk.quick_global_bindings[instruction] before resolving and initializing the cache payload. This violates the table comment’s fully-decoded-before-publication contract and leaves a reentrant read able to observe an invalid tag.

Required implementation

  • Build a new global-binding cache completely before publishing its pointer.
  • Preserve exact environment, global object, shape, slot, alias, accessor, and shared-mode guards.
  • Do not disable quickening, skip the test, weaken safety checks, or paper over an invalid tag.
  • Audit other type-erased quick-cache publication sites for the same ordering defect and file/link follow-ups where needed.

Acceptance

  • The focused polymorphic loop test passes repeatedly under exact dev.1818 on Linux.
  • Focused VM quickening tests pass in isolated and shared/seqlock modes.
  • Full unit and TSan gates pass without corrupt-tag panics.
  • Quantify quickening hit/step invariants before and after.

Parent: #498 Related: #465, #481, #491, #626

9 days ago

Implemented in 742a9be7. Global-binding resolution now produces a complete tagged value before a new type-erased cache pointer is published; unsupported rebinding clears stale entries. Exact dev.1818 focused tests pass 1/1 for the polymorphic witness and 1/1 for live globals, and the matching dev.1818 shard passes 434/434 with zero failures/leaks while preserving cross-mode values and steps. Keeping this issue open until fresh Linux x86-64 CI confirms the corrupt-tag panic is gone.

9 days ago

Fresh Linux x86-64 evidence confirms the exact formerly corrupting witness now passes: ordinary unit shard 3 reports vm: quickens isolated polymorphic own-data property loops with exact steps...OK, and TSan shard 3 reports the same witness OK. Both shards later fail unrelated existing tests (bounded Intl structural-part OOM; the ordinary shard additionally reaches a user-owned async/Thread panic), but neither reproduces the invalid global-cache tag. Closing the publication-order defect implemented by 742a9be7.

Sign in to comment on this issue.