Skip to content
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

readdirSync fails on Windows (using Apple Boot camp) when accessing a OSX drive #8723

Closed
bjarnij opened this issue Sep 22, 2016 · 21 comments
Closed
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX. windows Issues and PRs related to the Windows platform.

Comments

@bjarnij
Copy link

bjarnij commented Sep 22, 2016

  • Version: v4.5.0
  • Platform: Windows 10 64 bit (Running on a Mac using Apple Boot camp)
  • Subsystem: fs

When running Windows on Mac using Apple Boot camp, readdirSync fails when accessing the OSX drive.
This is the error I got:

Error: UNKNOWN: unknown error, scandir 'D:\usr\bin'
    at Error (native)
    at Object.fs.readdirSync (fs.js:808:18)
    ...

Here is a code example:

var fs = require('fs');

var fullPath = "D:\\usr\\bin";

console.log("The location: "  + fullPath + " contains the following: ");
fs.accessSync(fullPath, fs.F_OK);
var files = fs.readdirSync(fullPath);
for (var i in files) {
    console.log("  " + files[i]);
}

The same code works fine when accessing the Windows Boot camp drive instead and when running on OSX...

@bjarnij
Copy link
Author

bjarnij commented Sep 22, 2016

I tried Version: v6.6.0 too and it was the same:

fs.js:951
  return binding.readdir(pathModule._makeLong(path), options.encoding);
                 ^

Error: UNKNOWN: unknown error, scandir 'D:\usr\bin'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)

@mscdex mscdex added the fs Issues and PRs related to the fs subsystem / file system. label Sep 22, 2016
@Fishrock123 Fishrock123 added the macos Issues and PRs related to the macOS platform / OSX. label Sep 22, 2016
@eldyvoon
Copy link

Have the same problem :(

@bnoordhuis
Copy link
Member

Node (or rather, libuv) uses CreateFileW(FILE_LIST_DIRECTORY | SYNCHRONIZE) + NtQueryDirectoryFile() to read directories. If I had to venture a guess, it's that the Windows HFS+ driver doesn't (properly?) support that.

I have no way to test myself but if you want to debug this, I'd start by instrumenting fs__scandir() in deps/uv/src/win/fs.c. A few well-placed printf statements can probably tell you what is going on.

@Eugeny
Copy link

Eugeny commented Apr 27, 2017

Latest official Node.js build now simply crashes instead of returning error.

@refack refack self-assigned this Apr 27, 2017
@Trott
Copy link
Member

Trott commented Aug 4, 2017

@refack Are you actively working on this? Is a help wanted label appropriate?

@Eugeny @bjarnij or anyone else: Can anyone confirm that this is still happening with Node.js 8.2.1? (I imagine it is, but might as well confirm since this has been dormant for 3 months.)

@bnoordhuis
Copy link
Member

We might as well close this as it's unlikely to be a Node.js bug. Good idea, bad idea?

@Eugeny
Copy link

Eugeny commented Aug 5, 2017

Unfortunately, I don't have any Macs at my disposal at the moment.

@bnoordhuis how exactly is this not a Node bug? At least in Node 7, it's a regression from a returned error to a hard crash.

@bnoordhuis
Copy link
Member

Define 'hard crash'?

@Eugeny
Copy link

Eugeny commented Aug 5, 2017

A segmentation fault aka "Application stopped working"

@bnoordhuis
Copy link
Member

How did you establish it was caused by fs.readdirSync() and not, for example, a native add-on?

@Eugeny
Copy link

Eugeny commented Aug 5, 2017

Yes, I've been debugging the Node process itself and it crashed somewhere inside the fs module implementation. That's how I found this github issue. I can't recall exact details but I can try to find the exact location again next week.

@refack refack added help wanted Issues that need assistance from volunteers or PRs that need help to proceed. mentor-available c++ Issues and PRs that require attention from people who are familiar with C++. libuv Issues and PRs related to the libuv dependency or the uv binding. windows Issues and PRs related to the Windows platform. labels Aug 5, 2017
@refack
Copy link
Contributor

refack commented Aug 5, 2017

@refack Are you actively working on this? Is a help wanted label appropriate?

Not actively working on this, assigned myself just to keep track.
IMHO although it segfaults, it is an edge case (Windows via Bootcamp, accessing a macOS volume), hence it requires a complicated set up to reproduce.
(I have limited access to mac hardware, and I can't bootcamp it, if anyone want to donate some hardware, it will be very helpful /cc @apple ;)

RE keeping this open — personally I'm +1 on keeping this open since the comments indicate there is a issue here, and I can't think of different way to keep track (not a TODO comment nor a know_issue.js test).

/cc @nodejs/platform-windows @nodejs/platform-macos if anyone has spare cycles PTAL.

@bnoordhuis
Copy link
Member

@Eugeny A debugger backtrace would help.

@Eugeny
Copy link

Eugeny commented Aug 7, 2017

Here's what I got:
image

image

It seems to be this line: https://github.com/nodejs/node/blob/v7.4.0/deps/uv/src/win/fs.c#L906 (the array lookup), but I'm not 100% sure of it.

Seems like the info ptr is junk because next_entry_offset was junk in the previous iteration

@Eugeny
Copy link

Eugeny commented Aug 7, 2017

Actually, I'm sure of it. wchar_len was optimized away into RSI here.

@refack
Copy link
Contributor

refack commented Aug 8, 2017

@Eugeny a core dump would be nice to have. Although I think a more general solution might be based on using Windows' I/O manager - #8897 (comment)
image

@bnoordhuis
Copy link
Member

@Eugeny Is that with Node v7.4.0? What does the latest v8.x do? v7.x is out of support.

@apapirovski
Copy link
Contributor

@refack do you want to keep this open? There has been no movement in a while, no new info and it's a pretty extreme edge case.

@bnoordhuis
Copy link
Member

I'll close this. The UNKNOWN error is with 99.9% certainty not our bug and the crash was in an eol'd version of node. If someone has information to the contrary, please leave a comment.

@jorangreef
Copy link
Contributor

@refack I think this should be re-opened.

We received this from an app running v7.9.0 on a user's machine today:

Error: UNKNOWN: unknown error, scandir 'C:\Users\Red act Ted\Redacte (Redacte Redact)\Redactedre\Reda\REDA\Redact Redac Redactedredacte'

We received the error several times in the same process and then Node crashed.

It's just a regular C drive running on real Windows, no VM, nothing special.

I don't think libuv's fs__scandir has had any changes since Node v7.9.0 even if Node v7.9.0 is out of support so this might still be an issue?

I can collect more information from the user's machine tomorrow.

@bnoordhuis
Copy link
Member

EOL is EOL but happy to reopen if it reproduces with the latest v8.x or v9.x and is otherwise the same issue (readdirSync, Windows, HFS.)

@refack refack removed their assignment Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. libuv Issues and PRs related to the libuv dependency or the uv binding. macos Issues and PRs related to the macOS platform / OSX. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

10 participants