Closed
Description
- 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.