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

Segmentation fault while terminating and starting workers #56312

Open
lucasecdb opened this issue Dec 18, 2024 · 3 comments
Open

Segmentation fault while terminating and starting workers #56312

lucasecdb opened this issue Dec 18, 2024 · 3 comments

Comments

@lucasecdb
Copy link

lucasecdb commented Dec 18, 2024

Version

v20.17.0

Platform

Darwin Lucass-MacBook-Pro.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

Subsystem

worker

What steps will reproduce the bug?

I'm still working on creating a minimal reproduction for this bug, but it can be seen reported on this Nuxt issue: nuxt/nuxt#23832

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

It is consistent, whenever the server tries to start a new worker and terminate the old one I see the segmentation fault occurring.

What is the expected behavior? Why is that the expected behavior?

The expected behavior is to not have any segmentation fault at all, and for the program to successfully terminate the previous worker and initiate the new one without issues. It is the expected behavior because the program shouldn't crash and is not violating any of the Node APIs.

What do you see instead?

I successfully extracted a core file using a Debug build of current main, and can see the following in lldb when running bt all:

Backtrace of failed program
  thread #1
    frame #0: 0x0000000192a305d0 libsystem_platform.dylib`_platform_strcmp
    frame #1: 0x0000000102fbfbfc node`v8::platform::tracing::TracingController::GetCategoryGroupEnabled(this=0x00006000020ca990, category_group="node,node.async_hooks") at tracing-controller.cc:304:9 [opt]
    frame #2: 0x0000000100b015b0 node`node::tracing::TraceEventHelper::GetCategoryGroupEnabled(group="node,node.async_hooks") at trace_event.h:327:24
    frame #3: 0x0000000100b10c1c node`node::AsyncWrap::AsyncReset(this=0x0000000155763b40, resource=Local<v8::Object> @ 0x000000016f38cd68, execution_async_id=-1) at async_wrap.cc:620:5
    frame #4: 0x0000000100b1ada4 node`node::AsyncWrap::AsyncWrap(this=0x0000000155763b40, env=0x0000000155844800, object=Local<v8::Object> @ 0x000000016f38cdd0, provider=PROVIDER_FSREQCALLBACK, execution_async_id=-1) at async_wrap.cc:496:3
    frame #5: 0x0000000100cffac8 node`node::ReqWrap<uv_fs_s>::ReqWrap(this=0x0000000155763b40, env=0x0000000155844800, object=Local<v8::Object> @ 0x000000016f38ce18, provider=PROVIDER_FSREQCALLBACK) at req_wrap-inl.h:21:7
    frame #6: 0x0000000100cff384 node`node::fs::FSReqBase::FSReqBase(this=0x0000000155763b40, binding_data=0x0000000156004870, req=Local<v8::Object> @ 0x000000016f38ce68, type=PROVIDER_FSREQCALLBACK, use_bigint=true) at node_file-inl.h:46:5
    frame #7: 0x0000000100d38828 node`node::fs::FSReqCallback::FSReqCallback(this=0x0000000155763b40, binding_data=0x0000000156004870, req=Local<v8::Object> @ 0x000000016f38cea8, use_bigint=true) at node_file-inl.h:80:5
    frame #8: 0x0000000100d1d82c node`node::fs::FSReqCallback::FSReqCallback(this=0x0000000155763b40, binding_data=0x0000000156004870, req=Local<v8::Object> @ 0x000000016f38cee8, use_bigint=true) at node_file-inl.h:83:27
    frame #9: 0x0000000100d1d7ac node`node::fs::NewFSReqCallback(args=0x000000016f38cf88) at node_file.cc:716:7
    frame #10: 0x0000000101241624 node`v8::internal::FunctionCallbackArguments::CallOrConstruct(this=0x000000016f38cfe0, function=<unavailable>, is_construct=<unavailable>) at api-arguments-inl.h:95:3 [opt]
    frame #11: 0x0000000101240810 node`v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<true>(isolate=0x0000000158008000, new_target=Handle<v8::internal::HeapObject> @ x23, fun_data=v8::internal::DirectHandle<FunctionTemplateInfo> @ x20, receiver=<unavailable>, argv=0x000000016f38d178, argc=<unavailable>) at builtins-api.cc:108:36 [opt]
    frame #12: 0x000000010123f554 node`v8::internal::Builtin_HandleApiConstruct(int, unsigned long*, v8::internal::Isolate*) at builtins-api.cc:139:3 [opt]
    frame #13: 0x000000010123f504 node`v8::internal::Builtin_HandleApiConstruct(args_length=<unavailable>, args_object=<unavailable>, isolate=0x0000000158008000) at builtins-api.cc:130:1 [opt]
    frame #14: 0x0000000102a69af4 node`Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit + 84
    frame #15: 0x00000001029bbe58 node`Builtins_JSBuiltinsConstructStub + 312
    frame #16: 0x000000010b888dd8
    frame #17: 0x000000010c932afc
    frame #18: 0x00000001029bcd0c node`Builtins_JSEntryTrampoline + 172
    frame #19: 0x00000001029bc9b0 node`Builtins_JSEntry + 176
    frame #20: 0x00000001014cf9ac node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [inlined] v8::internal::GeneratedCode<unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, long, unsigned long**>::Call(this=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>) at simulator.h:187:12 [opt]
    frame #21: 0x00000001014cf9a8 node`v8::internal::(anonymous namespace)::Invoke(isolate=0x0000000158008000, params=0x000000016f38d510) at execution.cc:420:22 [opt]
    frame #22: 0x00000001014cea94 node`v8::internal::Execution::Call(isolate=0x0000000158008000, callable=Handle<v8::internal::Object> @ x23, receiver=Handle<v8::internal::Object> @ x22, argc=0, argv=0x0000000000000000) at execution.cc:506:10 [opt]
    frame #23: 0x000000010118f1c8 node`v8::Function::Call(this=0x0000000157854c40, isolate=0x0000000158008000, context=<unavailable>, recv=Local<v8::Value> @ x22, argc=0, argv=0x0000000000000000) at api.cc:5581:7 [opt]
    frame #24: 0x0000000100ae38c8 node`node::InternalCallbackScope::Close(this=0x000000016f38d940) at callback.cc:174:22
    frame #25: 0x0000000100ae420c node`node::InternalMakeCallback(env=0x0000000155844800, resource=Local<v8::Object> @ 0x000000016f38da00, recv=Local<v8::Object> @ 0x000000016f38d9f8, callback=v8::Local<v8::Function> @ 0x000000016f38d9f0, argc=2, argv=0x000000016f38dc18, asyncContext=(async_id = 166953, trigger_async_id = 166952), context_frame=Local<v8::Value> @ 0x000000016f38d9d8) at callback.cc:235:9
    frame #26: 0x0000000100b1f23c node`node::AsyncWrap::MakeCallback(this=0x0000000155775830, cb=v8::Local<v8::Function> @ 0x000000016f38dac0, argc=2, argv=0x000000016f38dc18) at async_wrap.cc:670:7
    frame #27: 0x0000000100b42f3c node`node::AsyncWrap::MakeCallback(this=0x0000000155775830, symbol=v8::Local<v8::Name> @ 0x000000016f38db60, argc=2, argv=0x000000016f38dc18) at async_wrap-inl.h:83:10
    frame #28: 0x0000000100b42b7c node`node::AsyncWrap::MakeCallback(this=0x0000000155775830, symbol=v8::Local<v8::String> @ 0x000000016f38dbb0, argc=2, argv=0x000000016f38dc18) at async_wrap-inl.h:60:10
    frame #29: 0x0000000100d1d484 node`node::fs::FSReqCallback::Resolve(this=0x0000000155775830, value=Local<v8::Value> @ 0x000000016f38dc10) at node_file.cc:704:3
    frame #30: 0x0000000100d1d3c4 node`node::fs::FSReqCallback::ResolveStat(this=0x0000000155775830, stat=0x0000000155775910) at node_file.cc:692:3
    frame #31: 0x0000000100d1e034 node`node::fs::AfterStat(req=0x00000001557758a0) at node_file.cc:787:15
    frame #32: 0x0000000100d03f7c node`node::MakeLibuvRequestCallback<uv_fs_s, void (*)(uv_fs_s*)>::Wrapper(req=0x00000001557758a0) at req_wrap-inl.h:126:5
    frame #33: 0x000000010298cff8 node`uv__fs_done(w=0x00000001557759f0, status=0) at fs.c:1778:3
    frame #34: 0x000000010297ea60 node`uv__work_done(handle=0x000000010784c738) at threadpool.c:329:5
    frame #35: 0x0000000102987ec4 node`uv__async_io(loop=0x000000010784c670, w=0x000000010784c8e0, events=1) at async.c:212:5
    frame #36: 0x00000001029acdc0 node`uv__io_poll(loop=0x000000010784c670, timeout=0) at kqueue.c:375:9
    frame #37: 0x00000001029888c8 node`uv_run(loop=0x000000010784c670, mode=UV_RUN_DEFAULT) at core.c:458:5
    frame #38: 0x0000000100ae68c0 node`node::SpinEventLoopInternal(env=0x0000000155844800) at embed_helpers.cc:41:7
    frame #39: 0x0000000100d98bd8 node`node::NodeMainInstance::Run(this=0x000000016f396658, exit_code=0x000000016f3965a4, env=0x0000000155844800) at node_main_instance.cc:111:9
    frame #40: 0x0000000100d98840 node`node::NodeMainInstance::Run(this=0x000000016f396658) at node_main_instance.cc:100:3
    frame #41: 0x0000000100c76674 node`node::StartInternal(argc=5, argv=0x00006000032c4640) at node.cc:1488:24
    frame #42: 0x0000000100c76290 node`node::Start(argc=5, argv=0x000000016f396a38) at node.cc:1495:27
    frame #43: 0x0000000102fb1a1c node`main(argc=5, argv=0x000000016f396a38) at node_main.cc:97:10
    frame #44: 0x000000019267a0e0 dyld`start + 2360
  thread #2
    frame #0: 0x00000001929c8340 libsystem_kernel.dylib`kevent + 8
    frame #1: 0x00000001029ac95c node`uv__io_poll(loop=0x000000015581fce8, timeout=1724496) at kqueue.c:292:12
    frame #2: 0x00000001029888c8 node`uv_run(loop=0x000000015581fce8, mode=UV_RUN_DEFAULT) at core.c:458:5
    frame #3: 0x0000000100e183e8 node`node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Run(this=0x000000015581fc00) at node_platform.cc:95:5
    frame #4: 0x0000000100e18278 node`node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start(this=0x000000016fb9afb7, data=0x000000015581fc00)::'lambda'(void*)::operator()(void*) const at node_platform.cc:64:49
    frame #5: 0x0000000100e18250 node`node::WorkerThreadsTaskRunner::DelayedTaskScheduler::Start()::'lambda'(void*)::__invoke(data=0x000000015581fc00) at node_platform.cc:63:25
    frame #6: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #3
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at thread.c:798:7
    frame #3: 0x0000000100c8ff14 node`node::LibuvMutexTraits::cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at node_mutex.h:175:5
    frame #4: 0x0000000100c8febc node`node::ConditionVariableBase<node::LibuvMutexTraits>::Wait(this=0x0000000155606668, scoped_lock=0x00000001703a2f38) at node_mutex.h:249:3
    frame #5: 0x0000000100e18bb4 node`node::TaskQueue<v8::Task>::BlockingPop(this=0x0000000155606628) at node_platform.cc:618:22
    frame #6: 0x0000000100e1399c node`node::(anonymous namespace)::PlatformWorkerThread(data=0x0000600000dcbde0) at node_platform.cc:42:61
    frame #7: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #4
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at thread.c:798:7
    frame #3: 0x0000000100c8ff14 node`node::LibuvMutexTraits::cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at node_mutex.h:175:5
    frame #4: 0x0000000100c8febc node`node::ConditionVariableBase<node::LibuvMutexTraits>::Wait(this=0x0000000155606668, scoped_lock=0x0000000170baaf38) at node_mutex.h:249:3
    frame #5: 0x0000000100e18bb4 node`node::TaskQueue<v8::Task>::BlockingPop(this=0x0000000155606628) at node_platform.cc:618:22
    frame #6: 0x0000000100e1399c node`node::(anonymous namespace)::PlatformWorkerThread(data=0x0000600000dcbe10) at node_platform.cc:42:61
    frame #7: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #5
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at thread.c:798:7
    frame #3: 0x0000000100c8ff14 node`node::LibuvMutexTraits::cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at node_mutex.h:175:5
    frame #4: 0x0000000100c8febc node`node::ConditionVariableBase<node::LibuvMutexTraits>::Wait(this=0x0000000155606668, scoped_lock=0x00000001713b2f38) at node_mutex.h:249:3
    frame #5: 0x0000000100e18bb4 node`node::TaskQueue<v8::Task>::BlockingPop(this=0x0000000155606628) at node_platform.cc:618:22
    frame #6: 0x0000000100e1399c node`node::(anonymous namespace)::PlatformWorkerThread(data=0x0000600000dcbe40) at node_platform.cc:42:61
    frame #7: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #6
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at thread.c:798:7
    frame #3: 0x0000000100c8ff14 node`node::LibuvMutexTraits::cond_wait(cond=0x0000000155606668, mutex=0x0000000155606628) at node_mutex.h:175:5
    frame #4: 0x0000000100c8febc node`node::ConditionVariableBase<node::LibuvMutexTraits>::Wait(this=0x0000000155606668, scoped_lock=0x0000000171bbaf38) at node_mutex.h:249:3
    frame #5: 0x0000000100e18bb4 node`node::TaskQueue<v8::Task>::BlockingPop(this=0x0000000155606628) at node_platform.cc:618:22
    frame #6: 0x0000000100e1399c node`node::(anonymous namespace)::PlatformWorkerThread(data=0x0000600000dcbe70) at node_platform.cc:42:61
    frame #7: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #7
    frame #0: 0x00000001929c2170 libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x00000001029a38cc node`uv_sem_wait(sem=0x0000000107840c84) at thread.c:471:9
    frame #2: 0x0000000100f97abc node`node::inspector::(anonymous namespace)::StartIoThreadMain(unused=0x0000000000000000) at inspector_agent.cc:83:5
    frame #3: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #8
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x000000010784c600, mutex=0x000000010784c5c0) at thread.c:798:7
    frame #3: 0x000000010297f484 node`worker(arg=0x0000000000000000) at threadpool.c:76:7
    frame #4: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #9
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x000000010784c600, mutex=0x000000010784c5c0) at thread.c:798:7
    frame #3: 0x000000010297f484 node`worker(arg=0x0000000000000000) at threadpool.c:76:7
    frame #4: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #10
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x000000010784c600, mutex=0x000000010784c5c0) at thread.c:798:7
    frame #3: 0x000000010297f484 node`worker(arg=0x0000000000000000) at threadpool.c:76:7
    frame #4: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #11
    frame #0: 0x00000001929c59ec libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x0000000192a0355c libsystem_pthread.dylib`_pthread_cond_wait + 1228
    frame #2: 0x00000001029a3b7c node`uv_cond_wait(cond=0x000000010784c600, mutex=0x000000010784c5c0) at thread.c:798:7
    frame #3: 0x000000010297f484 node`worker(arg=0x0000000000000000) at threadpool.c:76:7
    frame #4: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #12
    frame #0: 0x00000001929c21f4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000001929d4b24 libsystem_kernel.dylib`mach_msg2_internal + 80
    frame #2: 0x00000001929cae34 libsystem_kernel.dylib`mach_msg_overwrite + 476
    frame #3: 0x00000001929c2578 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x0000000192ae2680 CoreFoundation`__CFRunLoopServiceMachPort + 160
    frame #5: 0x0000000192ae0f44 CoreFoundation`__CFRunLoopRun + 1208
    frame #6: 0x0000000192ae0434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #7: 0x0000000192b5e45c CoreFoundation`CFRunLoopRun + 64
    frame #8: 0x000000010ac48aa0 fsevents.node`fse_run_loop + 116
    frame #9: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #13
    frame #0: 0x00000001929c21f4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x00000001929d4b24 libsystem_kernel.dylib`mach_msg2_internal + 80
    frame #2: 0x00000001929cae34 libsystem_kernel.dylib`mach_msg_overwrite + 476
    frame #3: 0x00000001929c2578 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x0000000192ae2680 CoreFoundation`__CFRunLoopServiceMachPort + 160
    frame #5: 0x0000000192ae0f44 CoreFoundation`__CFRunLoopRun + 1208
    frame #6: 0x0000000192ae0434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #7: 0x0000000192b5e45c CoreFoundation`CFRunLoopRun + 64
    frame #8: 0x00000001029aa5ec node`uv__cf_loop_runner(arg=0x000000010784c670) at fsevents.c:719:3
    frame #9: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #14
    frame #0: 0x00000001929c3ea4 libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #15
    frame #0: 0x000000010ac7676c
    frame #1: 0x000000010298c4b8 node`uv__finish_close(handle=0x000000015607f590) at core.c:361:5
    frame #2: 0x0000000102988adc node`uv__run_closing_handles(loop=0x00000001749b6ae0) at core.c:375:5
    frame #3: 0x0000000102988948 node`uv_run(loop=0x00000001749b6ae0, mode=UV_RUN_ONCE) at core.c:473:5
    frame #4: 0x0000000100f2007c node`node::worker::WorkerThreadData::~WorkerThreadData(this=0x00000001749b6ad8) at node_worker.cc:258:9
    frame #5: 0x0000000100f1c108 node`node::worker::WorkerThreadData::~WorkerThreadData(this=0x00000001749b6ad8) at node_worker.cc:205:23
    frame #6: 0x0000000100f1bde0 node`node::worker::Worker::Run(this=0x00000001557b2c30) at node_worker.cc:442:1
    frame #7: 0x0000000100f20e1c node`node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_0::operator()(this=0x00000001749b6fb7, arg=0x00000001557b2c30) const at node_worker.cc:769:12
    frame #8: 0x0000000100f20dc8 node`node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_0::__invoke(arg=0x00000001557b2c30) at node_worker.cc:758:7
    frame #9: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136
  thread #16
    frame #0: 0x00000001929c3ea4 libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #17
    frame #0: 0x00000001929fdd20 libsystem_pthread.dylib`start_wqthread
* thread #18, stop reason = ESR_EC_DABORT_EL0 (fault address: 0x0)
    frame #0: 0x0000000192a0b044 libdyld.dylib`tlv_get_addr + 4
    frame #1: 0x00000001013fa174 node`v8::internal::PerThreadAssertScope<false, (v8::internal::PerThreadAssertType)1, (v8::internal::PerThreadAssertType)2>::PerThreadAssertScope() [inlined] v8::internal::PerThreadAssertScope<false, (v8::internal::PerThreadAssertType)1, (v8::internal::PerThreadAssertType)2>::PerThreadAssertScope(this=0x0000000174dc1764) at assert-scope.cc:33:17 [opt]
    frame #2: 0x00000001013fa164 node`v8::internal::PerThreadAssertScope<false, (v8::internal::PerThreadAssertType)1, (v8::internal::PerThreadAssertType)2>::PerThreadAssertScope(this=0x0000000174dc1764) at assert-scope.cc:33:49 [opt]
    frame #3: 0x0000000101cb1108 node`v8::internal::String::ComputeAndSetRawHash(v8::internal::SharedStringAccessGuardIfNeeded const&) [inlined] unsigned int v8::internal::(anonymous namespace)::HashString<unsigned char>(string=<unavailable>, start=<unavailable>, length=<unavailable>, seed=<unavailable>, access_guard=<unavailable>) at string.cc:1587:29 [opt]
    frame #4: 0x0000000101cb1104 node`v8::internal::String::ComputeAndSetRawHash(this=0x000028bb817485b0, access_guard=0x0000000174dc17e0) at string.cc:1654:13 [opt]
    frame #5: 0x0000000101ec1564 node`v8::internal::StringTableInsertionKey::StringTableInsertionKey(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::DeserializingUserCodeOption) [inlined] v8::internal::Name::EnsureRawHash(this=<unavailable>, access_guard=0x0000000174dc17e0) at name-inl.h:194:30 [opt]
    frame #6: 0x0000000101ec1530 node`v8::internal::StringTableInsertionKey::StringTableInsertionKey(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::DeserializingUserCodeOption) [inlined] v8::internal::Name::EnsureHash(this=<unavailable>, access_guard=0x0000000174dc17e0) at name-inl.h:208:27 [opt]
    frame #7: 0x0000000101ec1530 node`v8::internal::StringTableInsertionKey::StringTableInsertionKey(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::DeserializingUserCodeOption) [inlined] unsigned int v8::internal::(anonymous namespace)::ComputeRawHashField<v8::internal::Isolate>(isolate=<unavailable>, string=<unavailable>) at deserializer.cc:377:11 [opt]
    frame #8: 0x0000000101ec1524 node`v8::internal::StringTableInsertionKey::StringTableInsertionKey(this=0x0000000174dc1860, isolate=<unavailable>, string=v8::internal::DirectHandle<String> @ x20, deserializing_user_code=kNotDeserializingUserCode) at deserializer.cc:385:22 [opt]
    frame #9: 0x0000000101ca2ccc node`v8::internal::StringTable::InsertForIsolateDeserialization(this=0x000060000277d260, isolate=0x0000000138608000, strings=<unavailable>) at string-table.cc:684:31 [opt]
    frame #10: 0x0000000101ee7ba8 node`v8::internal::SharedHeapDeserializer::DeserializeStringTable(this=<unavailable>) at shared-heap-deserializer.cc:51:6 [opt]
    frame #11: 0x0000000101ee7810 node`v8::internal::SharedHeapDeserializer::DeserializeIntoIsolate(this=0x0000000174dc1bb8) at shared-heap-deserializer.cc:24:3 [opt]
    frame #12: 0x0000000101509c80 node`v8::internal::Isolate::Init(this=0x0000000138608000, startup_snapshot_data=0x0000000174dc20d0, read_only_snapshot_data=<unavailable>, shared_heap_snapshot_data=0x0000000174dc20a0, can_rehash=<unavailable>) at isolate.cc:5626:30 [opt]
    frame #13: 0x000000010150a5bc node`v8::internal::Isolate::InitWithSnapshot(this=0x0000000138608000, startup_snapshot_data=0x0000000174dc20d0, read_only_snapshot_data=0x0000000174dc20b8, shared_heap_snapshot_data=0x0000000174dc20a0, can_rehash=<unavailable>) at isolate.cc:5109:10 [opt]
    frame #14: 0x0000000101eea4e8 node`v8::internal::Snapshot::Initialize(isolate=0x0000000138608000) at snapshot.cc:198:19 [opt]
    frame #15: 0x00000001011b6318 node`v8::Isolate::Initialize(v8_isolate=0x0000000138608000, params=0x0000000174dc2390) at api.cc:9875:8 [opt]
    frame #16: 0x0000000100af168c node`node::NewIsolate(params=0x0000000174dc2390, event_loop=0x0000000174dc2ae0, platform=0x00006000032c46e0, snapshot_data=0x000000010784eae0, settings=0x0000000174dc2348) at environment.cc:328:3
  * frame #17: 0x0000000100f1f590 node`node::worker::WorkerThreadData::WorkerThreadData(this=0x0000000174dc2ad8, w=0x0000000156165f50) at node_worker.cc:163:9
    frame #18: 0x0000000100f1beb4 node`node::worker::WorkerThreadData::WorkerThreadData(this=0x0000000174dc2ad8, w=0x0000000156165f50) at node_worker.cc:144:48
    frame #19: 0x0000000100f1b080 node`node::worker::Worker::Run(this=0x0000000156165f50) at node_worker.cc:312:20
    frame #20: 0x0000000100f20e1c node`node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_0::operator()(this=0x0000000174dc2fb7, arg=0x0000000156165f50) const at node_worker.cc:769:12
    frame #21: 0x0000000100f20dc8 node`node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_0::__invoke(arg=0x0000000156165f50) at node_worker.cc:758:7
    frame #22: 0x0000000192a02f94 libsystem_pthread.dylib`_pthread_start + 136

You can see that thread number 18 (frame 3) stopped the program because of an assertion in V8 while creating the Isolate: DisallowGarbageCollection no_gc;, while thread number 15 was waiting for the previous worker to terminate.

Additional information

I'm suspicious there is an issue when creating workers while waiting for a previous worker to terminate (e.g. does the terminate process use garbage collection? if so, that could be the cause the worker starting on thread 18 fails the program since V8 doesn't expect it to be enabled), but I don't have the knowledge if this is something expected or not. If it isn't, then there is a bug somewhere that is allowing this to happen, and is one of the reason that creating a small reproduction is being very hard.

@lucasecdb
Copy link
Author

while I'm not able to provide the reproduction at this time, if any of you can give me some pointers on what to look out for when debugging this issue would help a lot. I can try to find the bug and submit a fix PR if necessary, but need some help with it.

@juanarbol
Copy link
Member

while I'm not able to provide the reproduction at this time, if any of you can give me some pointers on what to look out for when debugging this issue would help a lot. I can try to find the bug and submit a fix PR if necessary, but need some help with it.

Nice...

You could build on debug mode and way may get a richer backtrace. Also attach a debugger where Node is crashing.

@gryffcom
Copy link

FreeBSD FreeBSD 14.1-RELEASE-p5 GENERIC amd64
Fresh installed worker:
~ % worker
[1] 5464 segmentation fault worker

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

No branches or pull requests

3 participants