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

Node fatal error: ToggleAsyncHook Cannot toggle Inspector's AsyncHook #27261

Closed
edopalmieri opened this issue Apr 16, 2019 · 24 comments
Closed
Labels
inspector Issues and PRs related to the V8 inspector protocol

Comments

@edopalmieri
Copy link

  • Version:
    Versions I have tested in which the fatal error occurs: 11.14.x, 11.13.x, 11.12.x, 11.11.x, 11.10.x
    Version under which the error does not occur: 10.15.3

  • Platform:
    18.5.0 Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64 x86_64

  • Subsystem:
    Occurs when using the worker_threads module. The fatal error occurs under the worker thread, but as a consequence the whole node process is taken down.

I have a node application that uses multithreading (worker_threads module) to handle some CPU intensive tasks that are triggered by requests over websockets. The main thread handles the ws traffic and creates worker threads to handle the tasks required by the ws request. The worker thread performs the task and returns a result to the main thread. Whenever running this application with versions 11.x I get the error below. The application works without issues when run ontop of Node version 10.15.3 with the experimental flag set.

I have already mentioned this in a comment to:
#26798

undefined:0



illegal access
FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0x100069ede node::Abort() [/usr/local/bin/node]
2: 0x10006a62e node::errors::TryCatchScope::~TryCatchScope() [/usr/local/bin/node]
2019-04-16T14:20:09.280Z Peer ::ffff:127.0.0.1 disconnected.
 3: 0x10006a4c0 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x10010290f node::inspector::Agent::ToggleAsyncHook(v8::Isolate*, v8::Persistent<v8::Function, node::ResetInDestructorPersistentTraits<v8::Function> > const&) [/usr/local/bin/node]
 5: 0x100178063 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [/usr/local/bin/node]
 6: 0x100180747 v8_inspector::V8DebuggerAgentImpl::disable() [/usr/local/bin/node]
 7: 0x100199093 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/usr/local/bin/node]
 8: 0x10019933e v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/usr/local/bin/node]
 9: 0x100103454 node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/usr/local/bin/node]
10: 0x1001034ae node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/usr/local/bin/node]
11: 0x100103892 node::inspector::NodeInspectorClient::disconnectFrontend(int) [/usr/local/bin/node]
12: 0x1001036c9 node::inspector::(anonymous namespace)::SameThreadInspectorSession::~SameThreadInspectorSession() [/usr/local/bin/node]
13: 0x1001036f6 node::inspector::(anonymous namespace)::SameThreadInspectorSession::~SameThreadInspectorSession() [/usr/local/bin/node]
14: 0x100110214 node::inspector::(anonymous namespace)::DeletableWrapper<node::inspector::(anonymous namespace)::MainThreadSessionState>::~DeletableWrapper() [/usr/local/bin/node]
15: 0x100110238 node::inspector::(anonymous namespace)::DeletableWrapper<node::inspector::(anonymous namespace)::MainThreadSessionState>::~DeletableWrapper() [/usr/local/bin/node]
16: 0x100111363 std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > > > >::erase(std::__1::__hash_const_iterator<std::__1::__hash_node<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, void*>*>) [/usr/local/bin/node]
17: 0x10011128a unsigned long std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > > > >::__erase_unique<int>(int const&) [/usr/local/bin/node]
18: 0x10010f811 node::inspector::MainThreadInterface::RemoveObject(int) [/usr/local/bin/node]
19: 0x10010f415 node::inspector::MainThreadInterface::DispatchMessages() [/usr/local/bin/node]
20: 0x1000c0e1a node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/usr/local/bin/node]
21: 0x1000c039a node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/usr/local/bin/node]
22: 0x1000c127b node::NodePlatform::FlushForegroundTasks(v8::Isolate*) [/usr/local/bin/node]
23: 0x100102f1d node::inspector::NodeInspectorClient::runMessageLoop() [/usr/local/bin/node]
24: 0x1000da81a std::__1::__function::__func<node::worker::Worker::Run()::$_0, std::__1::allocator<node::worker::Worker::Run()::$_0>, void ()>::operator()() [/usr/local/bin/node]
25: 0x100081149 node::OnScopeLeave::~OnScopeLeave() [/usr/local/bin/node]
26: 0x1000d7f8b node::worker::Worker::Run() [/usr/local/bin/node]
27: 0x1000d9e73 node::worker::Worker::StartThread(v8::FunctionCallbackInfo<v8::Value> const&)::$_2::__invoke(void*) [/usr/local/bin/node]
28: 0x7fff5e9912eb _pthread_body [/usr/lib/system/libsystem_pthread.dylib]
29: 0x7fff5e994249 _pthread_start [/usr/lib/system/libsystem_pthread.dylib]
30: 0x7fff5e99040d thread_start [/usr/lib/system/libsystem_pthread.dylib]

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
@MaxinLight
Copy link

MaxinLight commented May 16, 2019

I have a same problem, but only I use debugger in JetBrains PHPStorm

@edopalmieri
Copy link
Author

I am also using JetBrains (Webstorm) to debug the application. I see the error under Webstorm, I will have to test if it does not happen outside of Webstorm.

@joyeecheung
Copy link
Member

Hi, sorry about not noticing this earlier. Can you still reproduce this in newer versions of v12?

@connor4312
Copy link
Contributor

We have a report of this in Node 13.7.0 in VS Code's JavaScript debugger @joyeecheung microsoft/vscode-js-debug#222

@joyeecheung
Copy link
Member

@connor4312 Thanks for the notice.

One thing to note with the stack trace in the OP is that this happens when the worker is shutting down, and that's when JS is not supposed to be executed - however our inspector agent is not aware of this and tries to toggle the inspector async hooks to stop tracking async call stacks, which requires JS execution. In microsoft/vscode-js-debug#222 (comment) it happens when the main thread is shutting down.

We should probably just return there when JS execution is not allowed, I'll work on a fix, but it would be helpful if there is a reproducible test case.

@joyeecheung joyeecheung added the inspector Issues and PRs related to the V8 inspector protocol label Feb 18, 2020
@joyeecheung
Copy link
Member

On a second thought the ordering seems odd, NodeInspectorClient::disconnectFrontend() is invoked before Agent::WaitForDisconnect() is invoked through the exit hook, is that just a race or a bug? cc @nodejs/inspector

@SergeyFromHell
Copy link

SergeyFromHell commented May 18, 2020

Got same problem with v14.2.0 and vs-code:

FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0xa295e0 node::Abort() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 2: 0x9782df node::FatalError(char const*, char const*) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 3: 0x9782e8  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 4: 0xb1d3c8  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 5: 0x11f7544 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 6: 0x11fc841 v8_inspector::V8DebuggerAgentImpl::disable() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 7: 0x121887f v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 8: 0x1218b21 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
 9: 0xb19804  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
10: 0xb19ca1  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
11: 0xb37b5a  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
12: 0xb39651 node::inspector::MainThreadInterface::RemoveObject(int) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
13: 0xb3794e  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
14: 0xb37d6a  [/home/user/.nvm/versions/node/v14.2.0/bin/node]
15: 0x9ceaf8 node::Environment::RunAndClearInterrupts() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
16: 0x9cebbc node::Environment::RunAndClearNativeImmediates(bool) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
17: 0x9cf2f9 node::Environment::CleanupHandles() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
18: 0x9cf657 node::Environment::RunCleanup() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
19: 0x996f87 node::FreeEnvironment(node::Environment*) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
20: 0xa6a1ff node::NodeMainInstance::Run() [/home/user/.nvm/versions/node/v14.2.0/bin/node]
21: 0x9f9651 node::Start(int, char**) [/home/user/.nvm/versions/node/v14.2.0/bin/node]
22: 0x7f465ba0db97 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
23: 0x992f0c  [/home/user/.nvm/versions/node/v14.2.0/bin/node]```

@jkrems
Copy link
Contributor

jkrems commented Jun 2, 2020

There's another report of something that sounds similar (#33448, H/T @joyeecheung for making the connection), that report also includes a repo with code that at some point produced the crash.

@towry
Copy link

towry commented Jun 10, 2020

VSCode + Jest + Debugger:

 env CI=vscode-jest-tests 'NODE_OPTIONS=--require "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.bundle.js" ' 'VSCODE_INSPECTOR_OPTIONS={"inspectorIpc":"/var/folders/gd/8tghdshx483fdmjm04n68kwr0000gn/T/node-cdp.76500-1.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/towry/.nvm/versions/node/v12.18.0/bin/node","onlyEntrypoint":false,"fileCallback":"/var/folders/gd/8tghdshx483fdmjm04n68kwr0000gn/T/node-debug-callback-45bad808c4bf1a02"}' /Users/towry/.nvm/versions/node/v12.18.0/bin/node /Users/towry/xxxcompany/qxjs/node_modules/jest/bin/jest --runInBand cascaderHelper.spec.ts --testNamePattern #mapPath 
Debugger listening on ws://127.0.0.1:52848/fa17f06d-df95-4cc7-aebf-59247f96610f
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
PASS src/core/__tests__/cascaderHelper.spec.ts
  cascaderHelper
    ✓ #mapPath (3 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.697 s, estimated 3 s
Ran all test suites matching /cascaderHelper.spec.ts/i.
Debugger listening on ws://127.0.0.1:52848/fa17f06d-df95-4cc7-aebf-59247f96610f
For help, see: https://nodejs.org/en/docs/inspector
undefined:0



illegal access
FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0x1011c96b5 node::Abort() (.cold.1) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 2: 0x10009cae9 node::Abort() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 3: 0x10009cc4f node::OnFatalError(char const*, char const*) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 4: 0x10009caf9 node::FatalError(char const*, char const*) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 5: 0x10016ab60 node::inspector::Agent::AsyncTaskScheduled(v8_inspector::StringView const&, void*, bool) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 6: 0x1008220f3 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 7: 0x10082ad43 v8_inspector::V8DebuggerAgentImpl::disable() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 8: 0x1008432b4 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
 9: 0x10084356e v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
10: 0x10016b9db node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
11: 0x10016ba4e node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
12: 0x10016c2ae node::inspector::NodeInspectorClient::disconnectFrontend(int) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
13: 0x10016c01b node::inspector::(anonymous namespace)::SameThreadInspectorSession::~SameThreadInspectorSession() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
14: 0x10017eacc node::inspector::(anonymous namespace)::DeletableWrapper<node::inspector::(anonymous namespace)::MainThreadSessionState>::~DeletableWrapper() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
15: 0x10015d9fa unsigned long std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > > > >::__erase_unique<int>(int const&) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
16: 0x10017ecbe node::inspector::(anonymous namespace)::DeleteRequest::Call(node::inspector::MainThreadInterface*) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
17: 0x10017d903 node::inspector::MainThreadInterface::DispatchMessages() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
18: 0x10017f2fe node::inspector::(anonymous namespace)::DispatchMessagesTask::Run() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
19: 0x100105d53 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
20: 0x100104a77 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
21: 0x10093da84 uv__async_io [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
22: 0x100950f0f uv__io_poll [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
23: 0x10093dff1 uv_run [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
24: 0x100050549 node::Environment::CleanupHandles() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
25: 0x100050cc2 node::Environment::RunCleanup() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
26: 0x1000ddb0e node::NodeMainInstance::Run() [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
27: 0x100073015 node::Start(int, char**) [/Users/towry/.nvm/versions/node/v12.18.0/bin/node]
28: 0x7fff73b47cc9 start [/usr/lib/system/libdyld.dylib]
29: 0x5 
[1]    76897 abort      env CI=vscode-jest-tests   /Users/towry/.nvm/versions/node/v12.18.0/bin/node 

@connor4312
Copy link
Contributor

connor4312 commented Jul 14, 2020

Our new debugger is the default in the latest version of VS Code, and we've since seen increasing numbers of issues coming in for this. It seems most/all are Jest users. It would be great if we could take another look at this issue.

cc @joyeecheung (not able to tag the inspector team like you did 🙂 )

@bradennapier
Copy link

Our new debugger is the default in the latest version of VS Code, and we've since seen increasing numbers of issues coming in for this. It seems most/all are Jest users. It would be great if we could take another look at this issue.

cc @joyeecheung (not able to tag the inspector team like you did 🙂 )

I noticed this when using the vscode debugger and mocha. Interestingly it was due to beforeEach

no error

beforeEach(async () => {
    trader1 = users.trader1();
    trader2 = users.trader2();
  });

error

beforeEach(() => {
    trader1 = users.trader1();
    trader2 = users.trader2();
  });

@addaleax
Copy link
Member

Thanks for the ping!

I think #34362 should fix this as well.

@eugene-kim
Copy link

eugene-kim commented Jul 22, 2020

@towry are you still seeing this issue? I just upgraded my version of node to 12.18.3 from 12.18.2 and I'm still getting the same error when debugging jest tests in VSCode.

The node.js version indicated in the "About Visual Studio Code" pop up (pasted below) says 12.18.1 but I have 12.18.3 installed and active via nvm. 12.18.3 is also my nvm default version and I explicitly have the runtime version of my launch.json debug config to be 12.18.3.

CC: @addaleax @joyeecheung

Error output:

illegal access
FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0x1011c2ff5 node::Abort() (.cold.1) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 2: 0x10009fbc9 node::Abort() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 3: 0x10009fd2f node::OnFatalError(char const*, char const*) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 4: 0x10009fbd9 node::FatalError(char const*, char const*) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 5: 0x1001707c0 node::inspector::Agent::AsyncTaskScheduled(v8_inspector::StringView const&, void*, bool) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 6: 0x100820e23 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 7: 0x100829953 v8_inspector::V8DebuggerAgentImpl::disable() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 8: 0x100841a96 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
 9: 0x100841d4e v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
10: 0x10017166b node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
11: 0x1001716de node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
12: 0x100171f2e node::inspector::NodeInspectorClient::disconnectFrontend(int) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
13: 0x100171c9b node::inspector::(anonymous namespace)::SameThreadInspectorSession::~SameThreadInspectorSession() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
14: 0x10018458c node::inspector::(anonymous namespace)::DeletableWrapper<node::inspector::(anonymous namespace)::MainThreadSessionState>::~DeletableWrapper() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
15: 0x10016356a unsigned long std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > > > >::__erase_unique<int>(int const&) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
16: 0x10018477e node::inspector::(anonymous namespace)::DeleteRequest::Call(node::inspector::MainThreadInterface*) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
17: 0x1001833cd node::inspector::MainThreadInterface::DispatchMessages() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
18: 0x100184dbe node::inspector::(anonymous namespace)::DispatchMessagesTask::Run() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
19: 0x10010a2cb node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
20: 0x100108fd7 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
21: 0x10093b2db uv__async_io [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
22: 0x10094e60a uv__io_poll [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
23: 0x10093b861 uv_run [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
24: 0x1000537d9 node::Environment::CleanupHandles() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
25: 0x100053c38 node::Environment::RunCleanup() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
26: 0x1000e2035 node::NodeMainInstance::Run() [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
27: 0x100075e05 node::Start(int, char**) [/Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node]
28: 0x7fff708f9cc9 start [/usr/lib/system/libdyld.dylib]
[1]    27498 abort      env   /Users/eugene.kim/.nvm/versions/node/v12.18.3/bin/node  util.test

launch.json config:

{
      "type": "node",
      "request": "launch",
      "name": "Jest Current File",
      "program": "${workspaceFolder}/node_modules/.bin/jest",
      "args": ["${fileBasenameNoExtension}", "--runInBand", "--testTimeout=5000000"],
      "console": "integratedTerminal",
      "sourceMaps": true,
      "runtimeVersion": "12.18.3",
      "internalConsoleOptions": "neverOpen",
      "disableOptimisticBPs": true,
      "windows": {
        "program": "${workspaceFolder}/node_modules/jest/bin/jest"
      },
      "envFile": "${workspaceFolder}/src/.env"
    }

Visual Studio Code Details

Version: 1.47.2
Commit: 17299e413d5590b14ab0340ea477cdd86ff13daf
Date: 2020-07-15T18:18:50.054Z (6 days ago)
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.6.0

@ericleb010
Copy link

ericleb010 commented Jul 22, 2020

Same error here with 12.18.3 installed just now, when debugging with Jest in VSCode.

@connor4312
Copy link
Contributor

connor4312 commented Jul 22, 2020

Anna just fixed this issue yesterday -- it will be a little while before it's released in (I assume) a Node 14 build 🙂

@eugene-kim
Copy link

Ah, you're right @connor4312. The PR (#34362) for the change isn't in the 12.8.3 changelog. I don't know why I assumed it would be. Ignore my comment please @addaleax @joyeecheung and thank you for your work!

cjihrig pushed a commit that referenced this issue Jul 23, 2020
In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of #34361.

Fixes: #34361

PR-URL: #34362
Fixes: #27261
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Jul 27, 2020
In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of #34361.

Fixes: #34361

PR-URL: #34362
Fixes: #27261
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@0Ams
Copy link

0Ams commented Aug 5, 2020

@connor4312, @addaleax, @joyeecheung
Is there any plan that these changes will be applied to v12.18.x?

@addaleax
Copy link
Member

addaleax commented Aug 5, 2020

@0Ams Yes, this should also be part of the next v12.x release, I think.

@matttowerssonos
Copy link

@addaleax - Thanks for chasing this down! Do you happen to know if there is a separate issue or PR that is tracking this fix in v12.x?

addaleax added a commit that referenced this issue Aug 13, 2020
In the termination case, we should not crash. There’s also no harm
being done by ignoring the termination exception here, since the
thread is about to be torn down anyway.

Also, add a guard against running this during shutdown. That is the
likely cause of #34361.

Fixes: #34361

PR-URL: #34362
Fixes: #27261
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax
Copy link
Member

@matttowerssonos I’ve pushed it to the v12.x staging branch, but as you can see from the schedule, the next v12.x release is planned for September: nodejs/Release#494 /cc @nodejs/lts

@yolpsoftware
Copy link

Does this means that the "please report this" line is now obsolete?

I'm posting my stacktrace anyway, since it's a bit different to the ones above:

illegal access
FATAL ERROR:
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 00007FF7DC38538F napi_wrap+114751
 2: 00007FF7DC32FE26 v8::base::CPU::has_sse+66646
 3: 00007FF7DC330C26 v8::base::CPU::has_sse+70230
 4: 00007FF7DC330409 v8::base::CPU::has_sse+68153
 5: 00007FF7DC243A69 std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+79657
 6: 00007FF7DC624B97 v8::internal::compiler::TopLevelLiveRange::has_preassigned_slot+79495
 7: 00007FF7DC61773D v8::internal::compiler::TopLevelLiveRange::has_preassigned_slot+25133
 8: 00007FF7DC6073E8 v8_inspector::V8StackTraceId::V8StackTraceId+46600
 9: 00007FF7DC6075E4 v8_inspector::V8StackTraceId::V8StackTraceId+47108
10: 00007FF7DC241ABD std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+71549
11: 00007FF7DC244A54 std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+83732
12: 00007FF7DC2409F7 std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+67255
13: 00007FF7DC241D19 std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+72153
14: 00007FF7DC242134 std::basic_ostream<char,std::char_traits<char> >::basic_ostream<char,std::char_traits<char> >+73204
15: 00007FF7DC22D5B0 std::basic_ostream<char,std::char_traits<char> >::put+3552
16: 00007FF7DC22EA03 std::basic_ostream<char,std::char_traits<char> >::put+8755
17: 00007FF7DC22DF2A std::basic_ostream<char,std::char_traits<char> >::put+5978
18: 00007FF7DC22EAA9 std::basic_ostream<char,std::char_traits<char> >::put+8921
19: 00007FF7DC2C81AF std::basic_ostream<char,std::char_traits<char> >::operator<<+71055
20: 00007FF7DC2C7214 std::basic_ostream<char,std::char_traits<char> >::operator<<+67060
21: 00007FF7DC3D54FB uv_async_send+331
22: 00007FF7DC3D4C9C uv_loop_init+1212
23: 00007FF7DC3D4E64 uv_run+244
24: 00007FF7DC373480 napi_wrap+41264
25: 00007FF7DC384017 napi_wrap+109767
26: 00007FF7DC2E69D2 v8::internal::UnoptimizedCompilationInfo::feedback_vector_spec+32098
27: 00007FF7DC359963 node::Start+275
28: 00007FF7DC1C6A9C RC4_options+340380
29: 00007FF7DD052188 v8::internal::SetupIsolateDelegate::SetupHeap+1300536
30: 00007FFC4C8D7BD4 BaseThreadInitThunk+20
31: 00007FFC4DA8CE51 RtlUserThreadStart+33

VSCode, Node 12.18.2.

@dddddd889
Copy link

environment:

{
    "jest": "^25.3.0",
    "ts-node": "^9.0.0",
    "typescript": "^3.8.3"
}
$ node -v
v14.6.0
{
  "name": "Debug Jest Tests",
  "type": "node",
  "request": "launch",
  "runtimeArgs": [
    "--inspect-brk",
    "${workspaceRoot}/node_modules/.bin/jest",
    "--runInBand"
  ],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "cwd": "${workspaceFolder}",
  "port": 9229
}

error:

Ran all test suites.
Debugger listening on ws://127.0.0.1:53885/fe1b1321-c831-4b41-8f14-2fdb6edbd85f
For help, see: https://nodejs.org/en/docs/inspector
undefined:0



illegal access
FATAL ERROR: 
node::inspector::Agent::ToggleAsyncHook Cannot toggle Inspector's AsyncHook, please report this.
 1: 0x1012b7fd5 node::Abort() (.cold.1) [/usr/local/bin/node]
 2: 0x1000a3fa9 node::Abort() [/usr/local/bin/node]
 3: 0x1000a410f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 4: 0x1000a3fb9 node::FatalError(char const*, char const*) [/usr/local/bin/node]
 5: 0x1001735f3 node::inspector::Agent::ToggleAsyncHook(v8::Isolate*, v8::Global<v8::Function> const&) [/usr/local/bin/node]
 6: 0x10089d333 v8_inspector::V8Debugger::setAsyncCallStackDepth(v8_inspector::V8DebuggerAgentImpl*, int) [/usr/local/bin/node]
 7: 0x1008a4f13 v8_inspector::V8DebuggerAgentImpl::disable() [/usr/local/bin/node]
 8: 0x1008be114 v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/usr/local/bin/node]
 9: 0x1008be3be v8_inspector::V8InspectorSessionImpl::~V8InspectorSessionImpl() [/usr/local/bin/node]
10: 0x10017445b node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/usr/local/bin/node]
11: 0x1001744ce node::inspector::(anonymous namespace)::ChannelImpl::~ChannelImpl() [/usr/local/bin/node]
12: 0x100174d8e node::inspector::NodeInspectorClient::disconnectFrontend(int) [/usr/local/bin/node]
13: 0x100174afb node::inspector::(anonymous namespace)::SameThreadInspectorSession::~SameThreadInspectorSession() [/usr/local/bin/node]
14: 0x10018785c node::inspector::(anonymous namespace)::DeletableWrapper<node::inspector::(anonymous namespace)::MainThreadSessionState>::~DeletableWrapper() [/usr/local/bin/node]
15: 0x1001666ea unsigned long std::__1::__hash_table<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::__unordered_map_hasher<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::hash<int>, true>, std::__1::__unordered_map_equal<int, std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > >, std::__1::equal_to<int>, true>, std::__1::allocator<std::__1::__hash_value_type<int, std::__1::unique_ptr<node::inspector::Deletable, std::__1::default_delete<node::inspector::Deletable> > > > >::__erase_unique<int>(int const&) [/usr/local/bin/node]
16: 0x100187a4e node::inspector::(anonymous namespace)::DeleteRequest::Call(node::inspector::MainThreadInterface*) [/usr/local/bin/node]
17: 0x1001866cd node::inspector::MainThreadInterface::DispatchMessages() [/usr/local/bin/node]
18: 0x10018813e node::CallbackQueue<void, node::Environment*>::CallbackImpl<node::inspector::MainThreadInterface::Post(std::__1::unique_ptr<node::inspector::Request, std::__1::default_delete<node::inspector::Request> >)::$_0>::Call(node::Environment*) [/usr/local/bin/node]
19: 0x100056151 node::Environment::RunAndClearInterrupts() [/usr/local/bin/node]
20: 0x100055a4c node::Environment::RunAndClearNativeImmediates(bool) [/usr/local/bin/node]
21: 0x100055885 node::Environment::CleanupHandles() [/usr/local/bin/node]
22: 0x100055ec2 node::Environment::RunCleanup() [/usr/local/bin/node]
23: 0x10000514a node::FreeEnvironment(node::Environment*) [/usr/local/bin/node]
24: 0x1000e3eec node::NodeMainInstance::Run() [/usr/local/bin/node]
25: 0x1000786d2 node::Start(int, char**) [/usr/local/bin/node]
26: 0x7fff6cdfccc9 start [/usr/lib/system/libdyld.dylib]
[1]    63789 abort      env   /usr/local/bin/node  --runInBand

@dotnetjunky
Copy link

Is this bug supposed to be fixed in v12.18.4? I still get the error with the same callstack as @dingyanhe 's above.

@addaleax
Copy link
Member

addaleax commented Oct 5, 2020

Is this bug supposed to be fixed in v12.18.4?

No – the fix is in v14.7.0 and will be released in v12.19.0 as well once that is out, you can subscribe to the latter issue to get updates on the release progress

Does this means that the "please report this" line is now obsolete?

Yes, it’s just a matter of time of waiting for the v12.x release (unless you’re seeing this on v14.7.0+ or v12.19.0+, in which case you best open a new issue. 🙂 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.