Inside the executePendingJobs function, the view used for ctxPtrOut is allocated before the FFI call. If QTS_ExecutePendingJob triggers a WASM memory growth, the TypedArray backing ctxPtrOut becomes detached.
const ctxPtrOut = this.memory.newMutablePointerArray<JSContextPointerPointer>(1)
const valuePtr = this.ffi.QTS_ExecutePendingJob(
this.rt.value,
maxJobsToExecute ?? -1,
ctxPtrOut.value.ptr,
)
When the code reads from this invalid view:
const context =
this.contextMap.get(ctxPtr) ??
this.newContext({
contextPointer: ctxPtr,
})
The code enters the fallback path, an unmanaged context is created that cannot be disposed of, and internal context tracking is invalidated.