-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
test: test buffer behavior when zeroFill undefined #11706
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
When ArrayBufferAllocator has an undefined zeroFill property, Buffer.allocUnsafe() should zero fill. Refs: nodejs@27e84ddd4e1#commitcomment-19182129
I don't know. This is brittle both in how it monkey-patches the bindings and how it expects buffers to contain random garbage. If in an individual run the buffers all come from freshly mmap-ed memory (not inconceivable with a loop like that) the test will fail. You could ameliorate it somewhat by filling the buffer with non-zero data so that it's not all zeroes when its memory is reused for another buffer but that's still no guarantee. |
Yes, indeed. Best what can be said for it is that it's probably better than no test at all (our current situation). Would happily close this in favor of a C++ addon that did the testing instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, and I don’t think it hurts to have this
// `process.binding('buffer').setupBufferJS` be monkey-patched before this runs. | ||
const monkeyPatchedBuffer = require('../../lib/buffer'); | ||
|
||
// On unpatched buffer. allocUnsafe() should not zero fill memory. It's always |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: ,
after buffer
?
Thanks, landed with fixed typo in 9ee58c0. |
When ArrayBufferAllocator has an undefined zeroFill property, Buffer.allocUnsafe() should zero fill. Refs: 27e84ddd4e1#commitcomment-19182129 PR-URL: #11706 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
(Looks like this may have landed without a CI run. :-O ) |
When ArrayBufferAllocator has an undefined zeroFill property, Buffer.allocUnsafe() should zero fill. Refs: nodejs@27e84ddd4e1#commitcomment-19182129 PR-URL: nodejs#11706 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
When ArrayBufferAllocator has an undefined zeroFill property, Buffer.allocUnsafe() should zero fill. Refs: nodejs@27e84ddd4e1#commitcomment-19182129 PR-URL: nodejs#11706 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check that buffers created with `Buffer.allocUnsafe()` are not zero-filled. The test introduced in nodejs#11706 passes even if the buffer has been zero-filled and fails if none of the buffer values are zero. Signed-off-by: Karl Cheng <qantas94heavy@gmail.com> Refs: nodejs#11706
Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check that buffers created with `Buffer.allocUnsafe()` are not zero-filled. The test introduced in #11706 passes even if the buffer has been zero-filled and fails if none of the buffer values are zero. Refs: #11706 PR-URL: #12290 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
looks like this has failures. Please manually backport (and include #12290 ) |
Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check that buffers created with `Buffer.allocUnsafe()` are not zero-filled. The test introduced in #11706 passes even if the buffer has been zero-filled and fails if none of the buffer values are zero. Refs: #11706 PR-URL: #12290 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check that buffers created with `Buffer.allocUnsafe()` are not zero-filled. The test introduced in #11706 passes even if the buffer has been zero-filled and fails if none of the buffer values are zero. Refs: #11706 PR-URL: #12290 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fixes parallel/test-buffer-bindingobj-no-zerofill to properly check that buffers created with `Buffer.allocUnsafe()` are not zero-filled. The test introduced in #11706 passes even if the buffer has been zero-filled and fails if none of the buffer values are zero. Refs: #11706 PR-URL: #12290 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
When
ArrayBufferAllocator
has an undefinedzeroFill
property,Buffer.allocUnsafe()
should zero fill.Refs: 27e84ddd4e1#commitcomment-19182129
The
|| [0]
(discussed in the Refs: above) is the only piece of code inbuffer.js
not covered by tests. Ideally, this test would probably be a C++ addon test, but until someone writes that test, this will at least confirm that the intended behavior is correct.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test buffer