mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
When an asynchronous randomInt() call finds the cache empty, it queues itself and starts randomFill() on the shared cache buffer. A synchronous call made before that job completes refills the same buffer with randomFillSync() and returns values from offset 0. The completion callback then reset the offset to 0, so the queued call and later calls returned the bytes that synchronous calls had already used. The threadpool job and randomFillSync() could also write the buffer at the same time. Fill a separate buffer asynchronously and copy it into the cache once the job is done. Fixes: https://github.com/nodejs/node/issues/66595 Refs: https://github.com/nodejs/node/pull/35110 Signed-off-by: Jiawen Geng <technicalcute@gmail.com> Assisted-by: claude:opus-5.5 PR-URL: https://github.com/nodejs/node/pull/66597 Reviewed-By: Filip Skokan <panva.ip@gmail.com>