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

Cannot use node.js file descriptors in addon on windows (EBADF) #416

Closed
insidiator opened this issue Mar 11, 2014 · 6 comments
Closed

Cannot use node.js file descriptors in addon on windows (EBADF) #416

insidiator opened this issue Mar 11, 2014 · 6 comments
Labels

Comments

@insidiator
Copy link

I am not sure if this is the correct place for my issue, so please forgive me if it turns out to be unrelated to node-gyp :)

I tried to use the node-fs-ext plugin (https://github.com/baudehlo/node-fs-ext) on windows, but it does not work, because file descriptors that come from the node.js filesystem functions are not recognized.

I added a function that opens a file to the plugin to test if something is wrong with the plugin itself, but the file pointers that I create inside the plugin work fine.
Conversely the pointers returned by my function do not work with the standard node.js functions.

After a lot of googling and trying things, I found a somewhat similar problem here http://osdir.com/ml/python.ctypes/2006-06/msg00087.html thus I suspect that there is some kind of mismatch between the runtime libraries in use.

As I am not a C++ developer I am not really sure what I can do about that, so I would be really grateful if somebody could point me in the right direction.

My setup:
Windows 7 x64
Windows SDK v7.1
Python 2.7.5
node-gyp@0.10.10
node@0.10.20 | win32 | x64

@JayBeavers
Copy link
Contributor

It's pretty hard to understand the issue you are seeing, you didn't include the log of the failures. Could you please provide repro steps (e.g. npm install node-fs-ext) and the full log in this bug?

@stefan-guggisberg
Copy link

i ran into the same issue :( the problem occurs when passing CRT (c runtime library) objects (such as file descriptors) from node to a native addon on windows.

e.g.

fs.open(pathToFile, 'r'. function (err, fd) {
  binding.doSomething(fd, function (err, ...) {});   
});

won't work on windows unless both node.exe and the addon are linked dynamically to MSVCRT (/MD).
since node.exe is linked statically to MSVCRT (at least AFAICT) you're out of luck.

you can find more information here.

it's clearly not a node-gyp issue but rather a windows, erm, "limitation".

@JCMais
Copy link

JCMais commented Sep 15, 2015

Is that something we should still be aware? Or it was in someway fixed?

@davedoesdev
Copy link

This is still an issue (encountered it in fs-ext) but difficult to see a solution.

@bnoordhuis
Copy link
Member

I'll close the report, it's not a node-gyp issue. Maybe it should be reported against nodejs/node, although I don't see a short-term solution.

@davedoesdev
Copy link

davedoesdev commented Jul 6, 2017

FYI Issue is now fixed (see nodejs/node#6369)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants