You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wait for async I/O completion before disposing scan iterator
BufferAndLoad defers page reads via BumpCurrentEpoch(() => DoReadPage(...)).
SuspendDrain guarantees the drain callback (DoReadPage) has executed by the
time GetNext returns, but the async I/O issued by DoReadPage may still be
in flight. If Dispose frees the frame before the I/O callback fires, the
callback writes to freed native memory (AccessViolationException).
Fix: track outstanding async I/O with a pendingDrainCallbacks counter.
Increment before issuing AsyncReadPageFromDeviceToFrame, decrement in
AsyncReadPageFromDeviceToFrameCallback. Dispose spin-waits for the counter
to reach zero before freeing resources. No epoch acquisition needed in
Dispose — SuspendDrain already guarantees drain callbacks have executed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments