Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarshitha KP <harshi46@in.ibm.com>2020-03-18 17:26:00 +0300
committerAnna Henningsen <anna@addaleax.net>2020-03-30 11:27:35 +0300
commitb6459ec49048be8c5e52c30652ee00b63f11566b (patch)
treefb32aae48d545c3d487a1ec7ad9d7c6b6a70608f /src/node_worker.cc
parenta5e81e72b6d942b8229ebc653a57e9991f492955 (diff)
worker: runtime error on pthread creation
With large number of worker threads pthread fails with hard assertion. Instead of hard assertion throw a runtime error. PR-URL: https://github.com/nodejs/node/pull/32344 Fixes: https://github.com/nodejs/node/issues/32319 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_worker.cc')
-rw-r--r--src/node_worker.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/node_worker.cc b/src/node_worker.cc
index d359f6fcea2..26c6ce11cef 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -602,7 +602,7 @@ void Worker::StartThread(const FunctionCallbackInfo<Value>& args) {
uv_thread_options_t thread_options;
thread_options.flags = UV_THREAD_HAS_STACK_SIZE;
thread_options.stack_size = kStackSize;
- CHECK_EQ(uv_thread_create_ex(&w->tid_, &thread_options, [](void* arg) {
+ int ret = uv_thread_create_ex(&w->tid_, &thread_options, [](void* arg) {
// XXX: This could become a std::unique_ptr, but that makes at least
// gcc 6.3 detect undefined behaviour when there shouldn't be any.
// gcc 7+ handles this well.
@@ -623,7 +623,23 @@ void Worker::StartThread(const FunctionCallbackInfo<Value>& args) {
w->JoinThread();
// implicitly delete w
});
- }, static_cast<void*>(w)), 0);
+ }, static_cast<void*>(w));
+ if (ret != 0) {
+ char err_buf[128];
+ uv_err_name_r(ret, err_buf, sizeof(err_buf));
+ w->custom_error_ = "ERR_WORKER_INIT_FAILED";
+ w->custom_error_str_ = err_buf;
+ w->loop_init_failed_ = true;
+ w->thread_joined_ = true;
+ w->stopped_ = true;
+ w->env()->remove_sub_worker_context(w);
+ {
+ Isolate* isolate = w->env()->isolate();
+ HandleScope handle_scope(isolate);
+ THROW_ERR_WORKER_INIT_FAILED(isolate, err_buf);
+ }
+ w->MakeWeak();
+ }
}
void Worker::StopThread(const FunctionCallbackInfo<Value>& args) {