-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
First typed array is not zero-filled (v5.10.0) #6006
Comments
I am able to reproduce. Not sure if the labels I have applied are correct or not. I'm doing a bisect right now to see what's up /cc @nodejs/security |
Hm, I cannot reproduce it from the repl though...weird |
@evanlucas probably because some allocations are already made |
Looks like the regression comes in from 3c02727 edit: wrong sha at first |
master is affected also |
/cc @jasnell |
I'm not 100% but I'm going to guess we are doing something wrong here 3c02727#diff-cd53544f44aab2c697bcd7b6a57f23ccR949 |
Calling |
Passing the --zero-fill-buffers flag definitely makes it work |
@thealphanerd ... quick test on v5.x with that additional check removed still shows the problem. Master includes that exact same check also and I'm unable to reproduce there. |
I just ran a test with the following on master console.log(new Float64Array(10));
console.log(new Float64Array(10));
var a = new Buffer.allocUnsafe(200);
console.log(new Float64Array(10));
console.log(new Float64Array(10)); output is Float64Array [
0,
0,
2.5196862903032468e+180,
2.1390944465e-314,
0,
1.1125369292536007e-308,
0,
3.105036371167128e+231,
1.7272338147994846e-77,
6.953355807835004e-309 ]
Float64Array [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Float64Array [
0,
0,
2.1345912614e-314,
2.1346182947e-314,
0,
0,
2.1345912604e-314,
2.1346095003e-314,
2.134609532e-314,
2.1346095636e-314 ]
Float64Array [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] |
If `kNoZeroFill` is set here, it won't be reset in case of pooled allocation. In case of "slow" allocation it will be set later anyway. Fixes: nodejs#6006
If `kNoZeroFill` is set here, it won't be reset in case of pooled allocation. In case of "slow" allocation it will be set later anyway. Fixes: #6006 PR-URL: #6007 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
This makes sure that `kNoZeroFill` flag is not accidentally set by moving the all the flag operations directly inside `createBuffer()`. It safeguards against logical errors like #6006. This also ensures that `kNoZeroFill` flag is always restored to 0 using a try-finally block, as it could be not restored to 0 in cases of failed or zero-size `Uint8Array` allocation. It safeguards against errors like #2930. It also makes the `size > 0` check not needed there. PR-URL: nodejs-private/node-private#30 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This makes sure that `kNoZeroFill` flag is not accidentally set by moving the all the flag operations directly inside `createBuffer()`. It safeguards against logical errors like #6006. This also ensures that `kNoZeroFill` flag is always restored to 0 using a try-finally block, as it could be not restored to 0 in cases of failed or zero-size `Uint8Array` allocation. It safeguards against errors like #2930. It also makes the `size > 0` check not needed there. PR-URL: nodejs-private/node-private#30 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This makes sure that `kNoZeroFill` flag is not accidentally set by moving the all the flag operations directly inside `createBuffer()`. It safeguards against logical errors like nodejs/node#6006. This also ensures that `kNoZeroFill` flag is always restored to 0 using a try-finally block, as it could be not restored to 0 in cases of failed or zero-size `Uint8Array` allocation. It safeguards against errors like nodejs/node#2930. It also makes the `size > 0` check not needed there. PR-URL: https://github.com/nodejs/node-private/pull/35 Reviewed-By: James M Snell <jasnell@gmail.com>
Version: v5.10.0
Platform: Darwin [...] 14.5.0 Darwin Kernel Version 14.5.0: Mon Jan 11 18:48:35 PST 2016; root:xnu-2782.50.2~1/RELEASE_X86_64 x86_64
The first typed array created during script execution may contain non-zero values. Subsequent typed arrays are zero-filled, as expected.
I began to see this behavior after installing v5.10.0 from the following source: https://nodejs.org/dist/v5.10.0/node-v5.10.0-darwin-x64.tar.gz
The previous version, 5.9.1, is not affected.
I'm pasting sample output from the attached script
zerofill_bug.txt
below.zerofill_bug.txt
File contents
Sample output
The text was updated successfully, but these errors were encountered: