GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Shut a worker's platform data down after releasing per_isolate_mutex_ by Andarist · Pull Request #218 · replayio/node

Conversation

@Andarist

@Andarist Andarist commented Nov 2, 2026

Copy link
Copy Markdown
Member

NodePlatform::UnregisterIsolate called PerIsolatePlatformData::Shutdown with per_isolate_mutex_ held, and Shutdown takes ordered locks: the ordered flush_tasks_mutex_ (since #170) and, closing flush_tasks_, the uv_async_t's ordered lock. per_isolate_mutex_ itself isn't ordered (GC tasks posted at nondeterministic points reach it through ForIsolate), so a replay can hand it to the exiting worker before the main thread, which the recording gave it first. The worker then waits for the main thread's turn on its flush_tasks_mutex_ (the main thread posts to the worker's isolate, e.g. an Atomics.notify resolving a waitAsync), while the main thread waits for per_isolate_mutex_, e.g. in ScavengeJob's GetForegroundTaskRunner.

That is the node-recording worker-threads/atomics-wait-async-notify- terminating-worker replay Hanged: the hang report has the main thread waiting to acquire a lock owned by a worker thread, which waits on an ordered lock whose next owner is the main thread, and gdb on a hung replay shows the worker in Worker::Run -> UnregisterIsolate -> Shutdown -> pthread_mutex_lock -> OrderedLock and the main thread in ScavengeJob::ScheduleTaskIfNeeded -> ForIsolate -> uv_mutex_lock.

The entry is now erased under the mutex and its data shut down after releasing it. Other threads post through task runners they got while the isolate was registered (futex waiters, wasm), which Shutdown still handles under flush_tasks_mutex_; a lookup of the entry in between fails just as one after UnregisterIsolate always did.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Andarist @claude
Shut a worker's platform data down after releasing per_isolate_mutex_
17a7b12
NodePlatform::UnregisterIsolate called PerIsolatePlatformData::Shutdown
with per_isolate_mutex_ held, and Shutdown takes ordered locks: the
ordered flush_tasks_mutex_ (since #170) and, closing flush_tasks_, the
uv_async_t's ordered lock. per_isolate_mutex_ itself isn't ordered (GC
tasks posted at nondeterministic points reach it through ForIsolate), so
a replay can hand it to the exiting worker before the main thread, which
the recording gave it first. The worker then waits for the main thread's
turn on its flush_tasks_mutex_ (the main thread posts to the worker's
isolate, e.g. an Atomics.notify resolving a waitAsync), while the main
thread waits for per_isolate_mutex_, e.g. in ScavengeJob's
GetForegroundTaskRunner.

That is the node-recording worker-threads/atomics-wait-async-notify-
terminating-worker replay Hanged: the hang report has the main thread
waiting to acquire a lock owned by a worker thread, which waits on an
ordered lock whose next owner is the main thread, and gdb on a hung
replay shows the worker in Worker::Run -> UnregisterIsolate ->
Shutdown -> pthread_mutex_lock -> OrderedLock and the main thread in
ScavengeJob::ScheduleTaskIfNeeded -> ForIsolate -> uv_mutex_lock.

The entry is now erased under the mutex and its data shut down after
releasing it. Other threads post through task runners they got while
the isolate was registered (futex waiters, wasm), which Shutdown still
handles under flush_tasks_mutex_; a lookup of the entry in between fails
just as one after UnregisterIsolate always did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Andarist
Andarist merged commit 904fbe1 into master Nov 2, 2026
2 of 3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Andarist
Andarist deleted the andarist/unregister-isolate-shutdown-unlocked branch November 2, 2026 10:38
bhackett1024 added a commit that referenced this pull request Nov 5, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
0f9eb4b
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
4c74d40
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
ac52f5a
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
1a56cd0
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
50af1a2
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
d1049ea
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
bf47270
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
88cdca3
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
ace5ee1
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
1e6baac
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
c7bed5a
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
11ce7e6
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
513ed27
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
f10e85b
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
77263cb
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
c6a6050
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
b4d4458
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
6bbcf44
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
976fcf8
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
f1ef165
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
4e347be
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
319f6ba
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
1fa096a
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
1bcbd90
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
3d6f0c8
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
0bf9ee3
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 10, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
5606556
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist
Patch Node.js event loop and environment for recording
2ee7454
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
6e0f272
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 11, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
ab47a74
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 12, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js event loop and environment for recording
6994b18
Add recording assertions and determinism guards in the event loop,
environment lifecycle, immediate/timer execution, interrupt handling,
performance timing, and platform hrtime. Finish the recording on
process exit. Assert on each SpinEventLoop iteration.

Shut a worker's platform data down after releasing per_isolate_mutex_:
Shutdown() takes ordered locks that another thread can be due to take
before it may proceed, and holding the isolate map's plain mutex across
that deadlocked the replay.

Buffer.allocUnsafe stays zero-filled while recording: node 24 hands out memory
from a pool whose contents depend on what ran before, so an unzeroed buffer
makes the recording depend on allocations it does not order.

Node 26's racy shortcut past the native immediates is not taken when
recording: it reads a flag without the lock that guards the queue, so whether
the immediates run at all depends on timing the recording does not order.

Rebase note: upstream frequently refactors env.cc. The invariants are:
- The threadsafe-immediates mutex is ordered and is always taken; don't
  reintroduce the unlocked size() checks before locking, which race.
- Every place the loop calls into JS (timers, immediates, the tick
  callback) has a recording assert.
- Time values that reach JS are recorded (GetNow) or initialized at a
  deterministic point (performance timeOrigin), and V8's platform clock
  (uv_hrtime) passes through events.
- Features whose timing can't be replayed (V8 interrupts, performance
  observers) invalidate the recording rather than run silently.
- ArrayBuffer memory is always zero-filled.
- RecordReplayFinishRecording() runs on both the normal exit path and
  the process.exit() path.
- Nothing holding a plain lock may call into code that takes ordered
  locks, which can block until another thread's recorded turn.

Includes later changes from #128 and #218.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Andarist
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.