-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: test buffer behavior when zeroFill undefined #11706
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 <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
(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 <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
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 <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]>
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 <[email protected]> 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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]>
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]>
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]>
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 <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: James M Snell <[email protected]>
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