You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suspect signed/unsigned bug in the fs module of Node 6 and up on Windows #16496
There seems to be a signed/unsigned bug in the fs module of Node 6 and higher on Windows.
Specifically, I see different values in fs.Stats.dev for the synchronous and asynchronous versions fs.stat() and fs.statSync() (for the same file, obviously).
This only happens on Windows (well, technically Appveyor, I am unable to try it locally because I don't have a Windows machine at hand) and only in Node 6 and up.
I've created a minimal repository demonstrating this bug, here.
As you see in the logs, it got stat.dev == -726974396 from the async call, but it got stat.dev == 3567992900 from the sync call!
This happens to be what you get if you cast the former, in C, from int32_t to uint32_t, so I suspect something like that must be going wrong in Node/LibUV.
Also, I think it might be possible for something like this to happen for other fields than dev but those are probably just less likely to overflow like this.
Activity
mscdex commentedon Oct 25, 2017
Probably need something like #12614 for v6.x since it could be that an incomplete backport was done to v6.x at some point.
erikkemperman commentedon Oct 26, 2017
FYI it also happens with
lstatandlstatSync, as well asfstatandfstatSync. Updated my repo to demonstrate this:https://github.com/erikkemperman/windows-stats-quirk/blob/master/test/quirk.js#L23
https://github.com/erikkemperman/windows-stats-quirk/blob/master/test/quirk.js#L35
All of these fail on Appveyor but pass on Travis.
Also, I think it might be possible for something like this to happen for other fields than
devbut those are probably just less likely to overflow like this.fs: include more fs.stat*() optimizations
fs: fix stat dev unsigned cast overflow
fs: fix stat dev unsigned cast overflow
fs: fix stat dev unsigned cast overflow
gireeshpunathil commentedon Apr 27, 2018
link #12419
TimothyGu commentedon May 21, 2018
I believe this has been fixed by #16705.