Skip to content

Infinite loop at shutdown  #47748

Closed
@hhugo

Description

@hhugo

Version

v16.18.1, v18.16.0 and v20.0.0

Platform

Linux 5.15.0-41-generic #44-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

I don't have an easy way to reproduce the issue.

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

It triggers once every 10 runs maybe, it triggers much more often if I set break breakpoints (e.g. node::PerIsolatePlatformData::FlushForegroundTasksInternal)

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

I expect the process to terminate successfully.

What do you see instead?

The process hangs at 100% cpu after having done its normal job.

Attaching gdb gives me traces like

#0  v8::internal::Object::IsJSReceiver (cage_base=..., this=<optimized out>) at ../deps/v8/src/objects/tagged-impl.h:142
#1  v8::internal::LookupIterator::GetRoot (index=18446744073709551615, lookup_start_object=..., isolate=0x5571659076c0) at ../deps/v8/src/objects/lookup-inl.h:285
#2  v8::internal::LookupIterator::Start<false> (this=0x7ffedf9a85c0) at ../deps/v8/src/objects/lookup.cc:65
#3  0x000055715f0d5c83 in v8::internal::LookupIterator::LookupIterator (configuration=v8::internal::LookupIterator::PROTOTYPE_CHAIN, lookup_start_object=..., key=..., receiver=..., isolate=0x5571659076c0, this=0x7ffedf9a85c0) at ../deps/v8/src/objects/lookup.h:34
#4  v8::internal::Runtime::GetObjectProperty (isolate=isolate@entry=0x5571659076c0, lookup_start_object=lookup_start_object@entry=..., key=key@entry=..., receiver=..., receiver@entry=..., is_found=is_found@entry=0x0) at ../deps/v8/src/runtime/runtime-object.cc:40
#5  0x000055715e54420d in v8::Object::Get (this=<optimized out>, context=..., key=...) at ../deps/v8/src/handles/handles.h:137
#6  0x000055715e1e87bd in node::errors::TriggerUncaughtException (isolate=0x5571659076c0, error=..., message=..., from_promise=false) at ../src/node_errors.cc:1138
#7  0x000055715e1e69b6 in node::errors::PerIsolateMessageListener (message=..., error=...) at ../src/node_errors.cc:962
#8  0x000055715e89ef4d in v8::internal::MessageHandler::ReportMessageNoExceptions (isolate=0x5571659076c0, loc=<optimized out>, message=..., api_exception_obj=...) at ../deps/v8/src/execution/messages.cc:192
#9  0x000055715e89f67b in v8::internal::MessageHandler::ReportMessage (isolate=0x5571659076c0, loc=0x7ffedf9a9060, message=...) at ../deps/v8/src/handles/handles.h:137
#10 0x000055715e88287b in v8::internal::Isolate::ReportPendingMessages (this=this@entry=0x5571659076c0) at ../deps/v8/src/execution/isolate.cc:2695
#11 0x000055715e84df88 in v8::internal::(anonymous namespace)::Invoke (isolate=isolate@entry=0x5571659076c0, params=...) at ../deps/v8/src/execution/execution.cc:372
#12 0x000055715e84f0e1 in v8::internal::Execution::CallBuiltin (isolate=isolate@entry=0x5571659076c0, builtin=..., receiver=receiver@entry=..., argc=argc@entry=1, argv=argv@entry=0x7ffedf9a9270) at ../deps/v8/src/execution/execution.cc:551
#13 0x000055715e54eba9 in v8::internal::InvokeFinalizationRegistryCleanupFromTask (context=..., context@entry=..., finalization_registry=finalization_registry@entry=..., callback=...) at ../deps/v8/src/api/api.cc:11369
#14 0x000055715e994cd0 in v8::internal::FinalizationRegistryCleanupTask::RunInternal (this=0x557167724dc0) at ../deps/v8/src/heap/finalization-registry-cleanup-task.cc:88
#15 0x000055715e2bcb4c in node::PerIsolatePlatformData::RunForegroundTask (this=0x5571658f7200, task=std::unique_ptr<v8::Task> = {...}) at ../src/node_platform.cc:430
#16 0x000055715e2bd179 in node::PerIsolatePlatformData::FlushForegroundTasksInternal (this=0x5571658f7200) at ../src/node_platform.cc:494
#17 0x000055715e2bcde7 in node::NodePlatform::DrainTasks (this=0x5571659ae6f0, isolate=0x5571659076c0) at ../src/node_platform.cc:457
#18 0x000055715e03f75f in node::FreeEnvironment (env=0x55716599dcd0) at ../src/api/environment.cc:514
#19 0x000055715e039e84 in node::FunctionDeleter<node::Environment, &node::FreeEnvironment>::operator() (this=0x7ffedf9a9650, pointer=0x55716599dcd0) at ../src/util.h:682
#20 0x000055715e038d36 in std::unique_ptr<node::Environment, node::FunctionDeleter<node::Environment, &node::FreeEnvironment> >::~unique_ptr (this=0x7ffedf9a9650, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:361
#21 0x000055715e2668c6 in node::NodeMainInstance::Run (this=0x7ffedf9a96e0) at ../src/node_main_instance.cc:86
#22 0x000055715e166f2a in node::LoadSnapshotDataAndRun (snapshot_data_ptr=0x7ffedf9a97c0, result=0x55716584a220) at ../src/node.cc:1208
#23 0x000055715e167312 in node::StartInternal (argc=1, argv=0x5571659e83d0) at ../src/node.cc:1259
#24 0x000055715e1673ca in node::Start (argc=1, argv=0x7ffedf9a99c8) at ../src/node.cc:1266
#25 0x000055715fc01b64 in main (argc=1, argv=0x7ffedf9a99c8) at ../src/node_main.cc:97

and

#0  v8::internal::ReadOnlyRoots::GetLocation (this=this@entry=0x7ffedf9a9260, root_index=root_index@entry=v8::internal::RootIndex::kUndefinedValue) at ../deps/v8/src/roots/roots-inl.h:102
#1  0x000055715f0702e2 in v8::internal::ReadOnlyRoots::address_at (root_index=v8::internal::RootIndex::kUndefinedValue, this=0x7ffedf9a9260) at ../deps/v8/src/roots/roots-inl.h:144
#2  v8::internal::ReadOnlyRoots::object_at (root_index=v8::internal::RootIndex::kUndefinedValue, this=0x7ffedf9a9260) at ../deps/v8/src/roots/roots-inl.h:135
#3  v8::internal::ReadOnlyRoots::unchecked_undefined_value (this=0x7ffedf9a9260) at ../deps/v8/src/roots/roots-inl.h:96
#4  v8::internal::ReadOnlyRoots::CheckType_undefined_value (this=this@entry=0x7ffedf9a9260) at ../deps/v8/src/roots/roots.cc:57
#5  0x000055715e9b5963 in v8::internal::ReadOnlyRoots::undefined_value (this=0x7ffedf9a9260) at ../deps/v8/src/roots/roots-inl.h:96
#6  v8::internal::Object::IsUndefined (roots=..., this=<optimized out>) at ../deps/v8/src/objects/objects-inl.h:140
#7  v8::internal::Object::IsUndefined (isolate=0x5571659076c0, this=<optimized out>) at ../deps/v8/src/objects/objects-inl.h:124
#8  v8::internal::Heap::HasDirtyJSFinalizationRegistries (this=0x557165914978) at ../deps/v8/src/heap/heap-inl.h:522
#9  v8::internal::Heap::PostFinalizationRegistryCleanupTaskIfNeeded (this=0x557165914978) at ../deps/v8/src/heap/heap.cc:6552
#10 0x000055715e994d59 in v8::internal::FinalizationRegistryCleanupTask::RunInternal (this=0x5571676ed5e0) at ../deps/v8/src/heap/finalization-registry-cleanup-task.cc:98
#11 0x000055715e2bcb4c in node::PerIsolatePlatformData::RunForegroundTask (this=0x5571658f7200, task=std::unique_ptr<v8::Task> = {...}) at ../src/node_platform.cc:430
#12 0x000055715e2bd179 in node::PerIsolatePlatformData::FlushForegroundTasksInternal (this=0x5571658f7200) at ../src/node_platform.cc:494
#13 0x000055715e2bcde7 in node::NodePlatform::DrainTasks (this=0x5571659ae6f0, isolate=0x5571659076c0) at ../src/node_platform.cc:457
#14 0x000055715e03f75f in node::FreeEnvironment (env=0x55716599dcd0) at ../src/api/environment.cc:514
#15 0x000055715e039e84 in node::FunctionDeleter<node::Environment, &node::FreeEnvironment>::operator() (this=0x7ffedf9a9650, pointer=0x55716599dcd0) at ../src/util.h:682
#16 0x000055715e038d36 in std::unique_ptr<node::Environment, node::FunctionDeleter<node::Environment, &node::FreeEnvironment> >::~unique_ptr (this=0x7ffedf9a9650, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/unique_ptr.h:361
#17 0x000055715e2668c6 in node::NodeMainInstance::Run (this=0x7ffedf9a96e0) at ../src/node_main_instance.cc:86
#18 0x000055715e166f2a in node::LoadSnapshotDataAndRun (snapshot_data_ptr=0x7ffedf9a97c0, result=0x55716584a220) at ../src/node.cc:1208
#19 0x000055715e167312 in node::StartInternal (argc=1, argv=0x5571659e83d0) at ../src/node.cc:1259
#20 0x000055715e1673ca in node::Start (argc=1, argv=0x7ffedf9a99c8) at ../src/node.cc:1266
#21 0x000055715fc01b64 in main (argc=1, argv=0x7ffedf9a99c8) at ../src/node_main.cc:97

The process never return from node::NodePlatform::DrainTasks

Additional information

Based on some name seen in the backtrace, the following information might be useful.

My process use FinalizationRegistry with a finalization function calling into wasm. Concretely, I've a mapping between some js value and some wasm allocations, and have finalisers on some js value that free the memory on the wasm side (calling free).

I'm currently unable to reproduce the issue when removing the call to (wasm) free in the finaliser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions