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

module: node aborts when package.json is a directory #8307

Closed
bnoordhuis opened this issue Aug 28, 2016 · 6 comments
Closed

module: node aborts when package.json is a directory #8307

bnoordhuis opened this issue Aug 28, 2016 · 6 comments
Assignees
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. module Issues and PRs related to the module subsystem.

Comments

@bnoordhuis
Copy link
Member

bnoordhuis commented Aug 28, 2016

See discussion in #8277.

$ mkdir -p tmp/package.json && strace -e pread ./out/Release/node -e 'require("./tmp")'
pread(9, 0x1dc2690, 32768, 0)           = -1 EISDIR (Is a directory)
/home/bnoordhuis/src/v1.x/out/Release/node[21915]: ../src/node_file.cc:555:void node::InternalModuleReadFile(const v8::FunctionCallbackInfo<v8::Value>&): Assertion `(numchars) >= (0)' failed.
 1: node::Abort() [./out/Release/node]
 2: node::Assert(char const* const (*) [4]) [./out/Release/node]
 3: 0x10dd222 [./out/Release/node]
 4: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [./out/Release/node]
 5: 0x9df175 [./out/Release/node]
 6: 0x9df967 [./out/Release/node]
 7: 0xadf0a1060c7
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=21915, si_uid=1000} ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)

Caused by the CHECK_GE(numchars, 0) in InternalModuleReadFile() in src/node_file.cc.

EDIT: It's worth mentioning that the BSDs allow reading from a directory file descriptor so merely squelching the EISDIR error is probably not the best fix.

@bnoordhuis bnoordhuis added c++ Issues and PRs that require attention from people who are familiar with C++. module Issues and PRs related to the module subsystem. labels Aug 28, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Aug 28, 2016

Regarding the BSDs, is it an option to just not support storing your package.json as a directory? Aside from that edge case, I came up with the same solution as @rvagg in #8277.

@bmeck
Copy link
Member

bmeck commented Nov 17, 2016

I vote we not support loading package.json as a directory

@bnoordhuis
Copy link
Member Author

Regarding the BSDs, is it an option to just not support storing your package.json as a directory?

This was never supported (and never worked) but the BSDs are different from other platforms in that trying to open a directory with the open(2) system call is not an error.

That is, you can't check for an EISDIR error because you won't get one on the BSDs.

Aside from that edge case, I came up with the same solution as @rvagg in #8277.

What in particular are you referring to?

@cjihrig
Copy link
Contributor

cjihrig commented Jun 8, 2017

More or less the same implementation as #8277, with null checks for the required file name. To be honest, it's been a long time and I don't remember all the details.

@jdalton
Copy link
Member

jdalton commented Jan 19, 2018

Regardless of being supported it probably shouldn't cause a hard crash.

@bmeck bmeck self-assigned this Jan 19, 2018
bmeck added a commit to bmeck/node that referenced this issue Jan 19, 2018
@bmeck
Copy link
Member

bmeck commented Jan 19, 2018

PR up, just added a stat instead of trying to juggle things after open.

bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Jan 20, 2018
@Trott Trott closed this as completed in 8ccd320 Feb 8, 2018
MylesBorins pushed a commit that referenced this issue Feb 21, 2018
PR-URL: #18270
Fixes: #8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this issue Feb 21, 2018
PR-URL: #18270
Fixes: #8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this issue Feb 21, 2018
PR-URL: #18270
Fixes: #8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
yhwang pushed a commit to yhwang/node that referenced this issue Feb 22, 2018
PR-URL: nodejs#18270
Fixes: nodejs#8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
BridgeAR pushed a commit to BridgeAR/node that referenced this issue May 1, 2018
PR-URL: nodejs#18270
Fixes: nodejs#8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MayaLekova pushed a commit to MayaLekova/node that referenced this issue May 8, 2018
PR-URL: nodejs#18270
Fixes: nodejs#8307
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
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++. module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants