Skip to content

Suspect signed/unsigned bug in the fs module of Node 6 and up on Windows #16496

Closed
@erikkemperman

Description

@erikkemperman
  • Version: Node 6 and higher
  • Platform: Windows
  • Subsystem: fs

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.

The assertion that fails on Appveyor Node >= 6 but passes on Node < 6, is here:
https://github.com/erikkemperman/windows-stats-quirk/blob/master/test/quirk.js#L11

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.

#include <stdint.h>
#include <stdio.h>
int main() {
  printf("%u\n", (uint32_t) -726974396); // 3567992900
}

The older Node versions, up to 5, are fine, and so are all of the versions on Travis.

Thanks for taking the time, hopefully this bug report will be somewhat helpful in improving an already pretty awesome platform!

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions