Uh oh!
There was an error while loading. Please reload this page.
buffer: recreate pooled ArrayBuffer after transfer - #61364
Conversation
| const base64 = 'aGVsbG8='; // "hello" | ||
| const buf = Buffer.from(base64, 'base64'); | ||
| buf.buffer.transfer(); | ||
| assert.strictEqual(buf.buffer.byteLength, 0); |
There was a problem hiding this comment.
The buffer should not be transferrable at all... This still transfers the underlying buffer.
This just masks the issue.
this could have corrupted other buffers allocated prior to >x=Buffer.from('hello')<Buffer68656c6c6f>>y=Buffer.from('world')<Buffer776f726c64>>y.buffer.transfer()>x<Buffer>>Which could also include buffers allocated by Node.js internally |
Renegade334
commented
Jan 14, 2026
Thanks for the PR! Ultimately, I think #61372 is the correct approach here. As Nikita mentioned, this doesn't really solve the underlying issue. |
lindsaycode05
commented
Jan 15, 2026
Thanks guys, that makes sense. Given the broader semantics (detaching a shared backing store invalidates all views), my PR isn’t the right, long-term fix. I’ll leave it to #61372 and maintainer direction from here. Appreciate the discussion and pointers! Feel free to close this PR whenever convenient. |
Fixes#61362
Summary
ArrayBuffer.prototype.transfer()), subsequentBuffer.from(..., 'base64')calls would throwERR_BUFFER_OUT_OF_BOUNDS. This change ensures pooled Buffer creation doesn’t rely on a detached pool ArrayBuffer.Repro
Changes
Buffer.fromafter transfer.Tests
python3 tools/test.py test/parallel/test-buffer-pool-untransferable.jsmake -j4 test