Skip to content

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

Description

@bnoordhuis

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c++Issues and PRs that require attention from people who are familiar with C++.moduleIssues and PRs related to the module subsystem.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions