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

Crash if unhandled exception is thrown inside a node program with worker_threads inuse #45421

Closed
ywave620 opened this issue Nov 11, 2022 · 1 comment

Comments

@ywave620
Copy link
Contributor

ywave620 commented Nov 11, 2022

Version

nodev16x, main

Platform

mac, linux

Subsystem

worker

What steps will reproduce the bug?

  const { Worker } = require('worker_threads');
  new Worker('', { eval: true });
  throw new Error('xxx');

How often does it reproduce? Is there a required condition?

consistenly reproducable in debug build. Release build does not suffer from this issue because we are failing on an assertion which is enabled in debug build only.

What is the expected behavior?

throw new Error('xxx');
^

Error: xxx
    at Object.<anonymous> (/Users/roger/Work/node-contribute/test/sequential/test-worker-master-no-error-listener-for-worker.js:3:7)
    at Module._compile (node:internal/modules/cjs/loader:1175:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1229:10)
    at Module.load (node:internal/modules/cjs/loader:1038:32)
    at Module._load (node:internal/modules/cjs/loader:879:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.0.0-pre

What do you see instead?

throw new Error('xxx');
^

Error: xxx
    at Object.<anonymous> (/Users/roger/Work/node-contribute/test/sequential/test-worker-master-no-error-listener-for-worker.js:3:7)
    at Module._compile (node:internal/modules/cjs/loader:1175:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1229:10)
    at Module.load (node:internal/modules/cjs/loader:1038:32)
    at Module._load (node:internal/modules/cjs/loader:879:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47

Node.js v20.0.0-pre

#
# Fatal error in ../deps/v8/src/execution/isolate.cc, line 5594
# Debug check failed: state == EXTERNAL || state == IDLE.
#
#
#
#FailureMessage Object: 0x7ff7b7b554d0
 1: 0x10843621d node::DumpBacktrace(__sFILE*) [/Users/roger/Work/node-contribute/out/Debug/node]
 2: 0x1086e5956 node::NodePlatform::GetStackTracePrinter()::$_3::operator()() const [/Users/roger/Work/node-contribute/out/Debug/node]
 3: 0x1086e5919 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke() [/Users/roger/Work/node-contribute/out/Debug/node]
 4: 0x10a4a32e6 V8_Fatal(char const*, int, char const*, ...) [/Users/roger/Work/node-contribute/out/Debug/node]
 5: 0x10a4a2c85 v8::base::(anonymous namespace)::DefaultDcheckHandler(char const*, int, char const*) [/Users/roger/Work/node-contribute/out/Debug/node]
 6: 0x108d6e1bb v8::internal::Isolate::SetIdle(bool) [/Users/roger/Work/node-contribute/out/Debug/node]
 7: 0x1083adbc0 node::InternalCallbackScope::Close()::$_0::operator()() const [/Users/roger/Work/node-contribute/out/Debug/node]
 8: 0x1083adb97 node::OnScopeLeaveImpl<node::InternalCallbackScope::Close()::$_0>::~OnScopeLeaveImpl() [/Users/roger/Work/node-contribute/out/Debug/node]
 9: 0x1083abb55 node::OnScopeLeaveImpl<node::InternalCallbackScope::Close()::$_0>::~OnScopeLeaveImpl() [/Users/roger/Work/node-contribute/out/Debug/node]
10: 0x1083ab671 node::InternalCallbackScope::Close() [/Users/roger/Work/node-contribute/out/Debug/node]
11: 0x1083ab1ec node::InternalCallbackScope::~InternalCallbackScope() [/Users/roger/Work/node-contribute/out/Debug/node]
12: 0x1083aacd5 node::InternalCallbackScope::~InternalCallbackScope() [/Users/roger/Work/node-contribute/out/Debug/node]
13: 0x1083ac084 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/roger/Work/node-contribute/out/Debug/node]
14: 0x1083e7991 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Users/roger/Work/node-contribute/out/Debug/node]
15: 0x108410cf5 node::AsyncWrap::MakeCallback(v8::Local<v8::Name>, int, v8::Local<v8::Value>*) [/Users/roger/Work/node-contribute/out/Debug/node]
16: 0x108410923 node::AsyncWrap::MakeCallback(v8::Local<v8::String>, int, v8::Local<v8::Value>*) [/Users/roger/Work/node-contribute/out/Debug/node]
17: 0x1087abd2b node::worker::Worker::JoinThread() [/Users/roger/Work/node-contribute/out/Debug/node]
18: 0x108478ee7 node::Environment::stop_sub_worker_contexts() [/Users/roger/Work/node-contribute/out/Debug/node]
19: 0x1083b8713 node::DefaultProcessExitHandlerInternal(node::Environment*, node::ExitCode) [/Users/roger/Work/node-contribute/out/Debug/node]
20: 0x10848d46c decltype(std::__1::forward<void (*&)(node::Environment*, node::ExitCode)>(fp)(std::__1::forward<node::Environment*>(fp0), std::__1::forward<node::ExitCode>(fp0))) std::__1::__invoke<void (*&)(node::Environment*, node::ExitCode), node::Environment*, node::ExitCode>(void (*&)(node::Environment*, node::ExitCode), node::Environment*&&, node::ExitCode&&) [/Users/roger/Work/node-contribute/out/Debug/node]
21: 0x10848d3f7 void std::__1::__invoke_void_return_wrapper<void>::__call<void (*&)(node::Environment*, node::ExitCode), node::Environment*, node::ExitCode>(void (*&)(node::Environment*, node::ExitCode), node::Environment*&&, node::ExitCode&&) [/Users/roger/Work/node-contribute/out/Debug/node]
22: 0x10848d387 std::__1::__function::__alloc_func<void (*)(node::Environment*, node::ExitCode), std::__1::allocator<void (*)(node::Environment*, node::ExitCode)>, void (node::Environment*, node::ExitCode)>::operator()(node::Environment*&&, node::ExitCode&&) [/Users/roger/Work/node-contribute/out/Debug/node]
23: 0x10848c178 std::__1::__function::__func<void (*)(node::Environment*, node::ExitCode), std::__1::allocator<void (*)(node::Environment*, node::ExitCode)>, void (node::Environment*, node::ExitCode)>::operator()(node::Environment*&&, node::ExitCode&&) [/Users/roger/Work/node-contribute/out/Debug/node]
24: 0x1084a4d7a std::__1::__function::__value_func<void (node::Environment*, node::ExitCode)>::operator()(node::Environment*&&, node::ExitCode&&) const [/Users/roger/Work/node-contribute/out/Debug/node]
25: 0x108478e04 std::__1::function<void (node::Environment*, node::ExitCode)>::operator()(node::Environment*, node::ExitCode) const [/Users/roger/Work/node-contribute/out/Debug/node]
26: 0x108478dab node::Environment::Exit(node::ExitCode) [/Users/roger/Work/node-contribute/out/Debug/node]
27: 0x1085b4bce node::errors::TriggerUncaughtException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>, bool) [/Users/roger/Work/node-contribute/out/Debug/node]
28: 0x1085b44c7 node::errors::PerIsolateMessageListener(v8::Local<v8::Message>, v8::Local<v8::Value>) [/Users/roger/Work/node-contribute/out/Debug/node]
29: 0x108d7a4a4 v8::internal::MessageHandler::ReportMessageNoExceptions(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::Object>, v8::Local<v8::Value>) [/Users/roger/Work/node-contribute/out/Debug/node]
30: 0x108d7a113 v8::internal::MessageHandler::ReportMessage(v8::internal::Isolate*, v8::internal::MessageLocation const*, v8::internal::Handle<v8::internal::JSMessageObject>) [/Users/roger/Work/node-contribute/out/Debug/node]
31: 0x108d5c8e4 v8::internal::Isolate::ReportPendingMessages() [/Users/roger/Work/node-contribute/out/Debug/node]
32: 0x108d32fa7 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/roger/Work/node-contribute/out/Debug/node]
33: 0x108d32bc9 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [/Users/roger/Work/node-contribute/out/Debug/node]
34: 0x108a89f50 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/Users/roger/Work/node-contribute/out/Debug/node]
35: 0x1085544ce node::builtins::BuiltinLoader::CompileAndCall(v8::Local<v8::Context>, char const*, int, v8::Local<v8::Value>*, node::Environment*) [/Users/roger/Work/node-contribute/out/Debug/node]
36: 0x1085542e9 node::builtins::BuiltinLoader::CompileAndCall(v8::Local<v8::Context>, char const*, node::Realm*) [/Users/roger/Work/node-contribute/out/Debug/node]
37: 0x108711412 node::Realm::ExecuteBootstrapper(char const*) [/Users/roger/Work/node-contribute/out/Debug/node]
38: 0x1084fb845 node::StartExecution(node::Environment*, char const*) [/Users/roger/Work/node-contribute/out/Debug/node]
39: 0x1084fb6b9 node::StartExecution(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [/Users/roger/Work/node-contribute/out/Debug/node]
40: 0x1083b6785 node::LoadEnvironment(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [/Users/roger/Work/node-contribute/out/Debug/node]
41: 0x1086576f3 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/Users/roger/Work/node-contribute/out/Debug/node]
42: 0x108656ff1 node::NodeMainInstance::Run() [/Users/roger/Work/node-contribute/out/Debug/node]
43: 0x1084fdaff node::LoadSnapshotDataAndRun(node::SnapshotData const**, node::InitializationResultImpl const*) [/Users/roger/Work/node-contribute/out/Debug/node]
44: 0x1084fde19 node::StartInternal(int, char**) [/Users/roger/Work/node-contribute/out/Debug/node]
45: 0x1084fdb6b node::Start(int, char**) [/Users/roger/Work/node-contribute/out/Debug/node]
46: 0x10a04f162 main [/Users/roger/Work/node-contribute/out/Debug/node]
47: 0x110df952e 
zsh: trace trap  out/Debug/node 

Additional information

No response

@legendecas
Copy link
Member

Fixed in #45596.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants