Skip to content

vm: node crashes if timeout is set and nofile limit is reached #8555

Closed
@chatziko

Description

@chatziko
  • Version: v6.6.0 and v4.5.0
  • Platform: ubuntu trusty, 3.13.0-86-generic, x86_64
  • Subsystem: vm

If a timeout is given to one of vm's methods, and the nofile limit is reached, the node process crashes. It can be easily reproduced (on both v4.5.0 and v.6.6.0) with this 2-liner:

> require('posix').setrlimit('nofile', { soft: 0 })
> require('vm').runInNewContext('1', undefined, { timeout: 1000 });

/usr/bin/nodejs[5049]: ../src/node_watchdog.cc:16:node::Watchdog::Watchdog(v8::Isolate*, uint64_t): Assertion `(0) == (rc)' failed.
 1: node::Abort() [node]
 2: node::Assert(char const* const (*) [4]) [node]
 3: 0x10ea8d6 [node]
 4: node::ContextifyScript::EvalMachine(node::Environment*, long, bool, bool, v8::FunctionCallbackInfo<v8::Value> const&, v8::TryCatch*) [node]
 5: node::ContextifyScript::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [node]
 7: 0x9f3902 [node]
 8: 0x9f3f7e [node]
 9: 0x2c5c8fb092a7
Aborted (core dumped)

It seems that node::Watchdog tries to create a libuv thread to implement the timeout. uv_loop_init fails due to the nofile limit, causing this assertion to fail. The correct behaviour would be to throw some meaningful exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    vmIssues and PRs related to the vm subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions