[pull] main from oven-sh:main
Merged
PU
4mo ago+749+749+012345678901234567890123456789-94-94-01234567890123456789
See Commits and Changes for more details.
Created by pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by cubic
Makes threadsafe FFI callbacks safe after VM teardown and adds VM-scoped wall-clock termination deadlines. Also standardizes i64/u64 Number conversions to be architecture-independent.
- Threadsafe JSFFICallbacks: the entry thunk now targets a persistent
FFI::ThreadsafeCallbackHandleinstead of the GC cell. Late calls (afterclose()or VM/global destruction) are dropped and return 0;runThreadsafeInvocationexits early if the cell is gone. Threadsafe callbacks are rooted VM‑wide until closed and drained, and the handle (with thunk) is kept alive once an entrypoint was handed out to avoid UAF. - i64/u64 Number conversion:
writeInt64Slotuses modular conversion viaJSC::toInt64and stores the low 64 bits, making behavior identical on x86‑64 and arm64; NaN/±∞ convert to 0. Pointer types keep using the CPU truncation (doubleToInt64). Tests and fuzzers were updated to cover the new edges. - Termination deadlines: new
VM::addTerminationDeadline,VM::cancelTermination, andVM::hasPendingTermination, plus$vm.callWithTimeLimit(fn, ms)that withdraws its own termination and throws RangeError "timed out" on expiry. Nested limits re‑request termination for enclosing scopes. A new stress test validates semantics.
Migration
- If an embedder accepts a threadsafe invocation but chooses not to run it, call
FFI::retireThreadsafeInvocation(exported inBunFFI.h) to withdraw the pending count and unroot if needed.