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

--inspect crash in Node >=14.0.0 when accessing global variable in devtools #36845

Closed
jrmyio opened this issue Jan 8, 2021 · 10 comments
Closed
Labels
confirmed-bug Issues with confirmed bugs. inspector Issues and PRs related to the V8 inspector protocol

Comments

@jrmyio
Copy link

jrmyio commented Jan 8, 2021

What steps will reproduce the bug?

Run below test.js by using node --inspect=0.0.0.0:9229 test.js and inspect the file with chrome://inspect in Chrome (I am using Windows 10).
In the chrome dev tools try to access the "test" variable by typing test in the devtools. The node process will crash on the first try or on your next couple calls.

// test.js
function registerGlobals(objects){
    Object.keys(objects).forEach((key) => {
        (globalThis)[key] = objects[key];
    });
};

var test = {
    blaat: 'some value'
};
registerGlobals({
    test
});

setInterval(() => {
    console.log('hearthbeat');
}, 1000);

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

It happends consistently after the first 1-5 tries when accessing the "test" global variable.

What is the expected behavior?

Not crash and return the results like in Node <= 13

What do you see instead?

node --inspect=0.0.0.0:9229 test
Debugger listening on ws://0.0.0.0:9229/e7de75b7-eb6f-4fee-a374-0666c9644a98
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
test
test
test
test
test


#
# Fatal error in , line 0
# Check failed: !isolate->has_pending_exception().
#
#
#
#FailureMessage Object: 0x7fffb56adfb0
 1: 0xa96131  [node]
 2: 0x19614f4 V8_Fatal(char const*, ...) [node]
 3: 0xc191fa  [node]
 4: 0xc1c634 v8::internal::Builtin_ConsoleLog(int, unsigned long*, v8::internal::Isolate*) [node]
 5: 0x13a6339  [node]
Illegal instruction (core dumped)

Additional information

This only started happenening since Node version 14.0.0. Before, in v13.14.0, this crash does not happen.

@targos targos added inspector Issues and PRs related to the V8 inspector protocol confirmed-bug Issues with confirmed bugs. labels Jan 8, 2021
@targos
Copy link
Member

targos commented Jan 8, 2021

I can reproduce. I'm preparing a debug build to get a better stack trace.

@targos
Copy link
Member

targos commented Jan 8, 2021

1: 0xfc5a3d node::DumpBacktrace(_IO_FILE*) [./node_g]
 2: 0x115491d  [./node_g]
 3: 0x115493d  [./node_g]
 4: 0x2b90c87 V8_Fatal(char const*, int, char const*, ...) [./node_g]
 5: 0x2b90cb3  [./node_g]
 6: 0x14df494 v8::internal::Debug::StopSideEffectCheckMode() [./node_g]
 7: 0x14be779 v8::internal::DebugEvaluate::Global(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::debug::EvaluateGlobalMode, v8::internal::REPLMode) [./node_g]
 8: 0x13298c0 v8::debug::EvaluateGlobal(v8::Isolate*, v8::Local<v8::String>, v8::debug::EvaluateGlobalMode, bool) [./node_g]
 9: 0x1dc5492 v8_inspector::V8RuntimeAgentImpl::evaluate(v8_inspector::String16 const&, v8_crdtp::detail::ValueMaybe<v8_inspector::String16>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<int>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<double>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, v8_crdtp::detail::ValueMaybe<bool>, std::unique_ptr<v8_inspector::protocol::Runtime::Backend::EvaluateCallback, std::default_delete<v8_inspector::protocol::Runtime::Backend::EvaluateCallback> >) [./node_g]
10: 0x12dc188 v8_inspector::protocol::Runtime::DomainDispatcherImpl::evaluate(v8_crdtp::Dispatchable const&) [./node_g]
11: 0x1de5aba v8_crdtp::UberDispatcher::DispatchResult::Run() [./node_g]
12: 0x1db4abb v8_inspector::V8InspectorSessionImpl::dispatchProtocolMessage(v8_inspector::StringView) [./node_g]
13: 0x120810f  [./node_g]
14: 0x1208f06 node::inspector::NodeInspectorClient::dispatchMessageFromFrontend(int, v8_inspector::StringView const&) [./node_g]
(gdb) bt
#0  v8::base::OS::Abort () at ../../deps/v8/src/base/platform/platform-posix.cc:488
#1  0x0000000002b90c98 in V8_Fatal (file=0x3445a68 "../../deps/v8/src/debug/debug.cc", line=2273, format=format@entry=0x563c8f2 "Debug check failed: %s.") at ../../deps/v8/src/base/logging.cc:167
#2  0x0000000002b90cb3 in v8::base::(anonymous namespace)::DefaultDcheckHandler (file=<optimized out>, line=<optimized out>, message=<optimized out>) at ../../deps/v8/src/base/logging.cc:57
#3  0x00000000014df494 in v8::internal::Debug::StopSideEffectCheckMode (this=0x5d89300) at ../../deps/v8/src/debug/debug.cc:2273
#4  0x00000000014be779 in v8::internal::DebugEvaluate::Global (isolate=isolate@entry=0x5dad200, source=..., mode=mode@entry=v8::debug::EvaluateGlobalMode::kDisableBreaksAndThrowOnSideEffect, 
    repl_mode=repl_mode@entry=v8::internal::REPLMode::kYes) at ../../deps/v8/src/execution/isolate.h:1073
#5  0x00000000013298c0 in v8::debug::EvaluateGlobal (isolate=0x5dad200, source=..., mode=mode@entry=v8::debug::EvaluateGlobalMode::kDisableBreaksAndThrowOnSideEffect, repl=repl@entry=true)
    at ../../deps/v8/src/api/api.cc:10202
#6  0x0000000001dc5492 in v8_inspector::V8RuntimeAgentImpl::evaluate (this=0x5eed920, expression=..., objectGroup=..., includeCommandLineAPI=..., silent=..., executionContextId=..., returnByValue=..., generatePreview=..., 
    userGesture=..., maybeAwaitPromise=..., throwOnSideEffect=..., timeout=..., disableBreaks=..., maybeReplMode=..., allowUnsafeEvalBlockedByCSP=..., callback=...) at ../../deps/v8/src/inspector/v8-inspector-impl.h:63
#7  0x00000000012dc188 in v8_inspector::protocol::Runtime::DomainDispatcherImpl::evaluate (this=<optimized out>, dispatchable=...) at /usr/include/c++/8/bits/char_traits.h:96
#8  0x0000000001de5aba in std::function<void ()>::operator()() const (this=0x7fffffff9c98) at /usr/include/c++/8/bits/std_function.h:682
#9  v8_crdtp::UberDispatcher::DispatchResult::Run (this=this@entry=0x7fffffff9c90) at ../../deps/v8/third_party/inspector_protocol/crdtp/dispatch.cc:529
#10 0x0000000001db4abb in v8_inspector::V8InspectorSessionImpl::dispatchProtocolMessage (this=0x5edac50, message=...) at ../../deps/v8/src/inspector/v8-inspector-session-impl.cc:378
#11 0x000000000120810f in node::inspector::(anonymous namespace)::ChannelImpl::dispatchProtocolMessage (this=0x5ed47f0, message=...) at ../../src/inspector_agent.cc:256
#12 0x0000000001208f06 in node::inspector::NodeInspectorClient::dispatchMessageFromFrontend (this=0x5e35740, session_id=1, message=...) at ../../src/inspector_agent.cc:479
#13 0x0000000001204e73 in node::inspector::(anonymous namespace)::SameThreadInspectorSession::Dispatch (this=0x5eeeeb0, message=...) at ../../src/inspector_agent.cc:954
#14 0x00000000012326b9 in node::inspector::(anonymous namespace)::MainThreadSessionState::Dispatch (this=0x5edb6a0, message=std::unique_ptr<v8_inspector::StringBuffer> = {...})
    at ../../src/inspector/main_thread_interface.cc:152
#15 0x00000000012343cc in node::inspector::(anonymous namespace)::AnotherThreadObjectReference<node::inspector::(anonymous namespace)::MainThreadSessionState>::Apply<std::unique_ptr<v8_inspector::StringBuffer> > (
    target=0x5edb6a0, fn=

@targos
Copy link
Member

targos commented Jan 8, 2021

This only happens with the Chrome devtools. I cannot reproduce using node inspect.

@targos
Copy link
Member

targos commented Jan 8, 2021

@nodejs/inspector

@oyyd
Copy link
Contributor

oyyd commented Jan 14, 2021

The code below is simpler and could also reproduce:

// test.js
const inspector = require('inspector');
setInterval(() => {
    inspector.console.log('heartbeat')
}, 1000);

node --inspect test.js and type process in Chrome Devtools.

@tinpotnick
Copy link

I am not sure if I am helping at all - but I just found this bug also. I am running node v14.15.4 on Fedora.

@alex3d
Copy link

alex3d commented May 26, 2021

Node process crash happens even before we have hit Enter when devtools tries to evaluate a partial expression.
So we have found a workaround for this issue: turn off "eager evaluation" in chrome devtools:
image

@SpeedyCraftah
Copy link

SpeedyCraftah commented Jul 6, 2021

I just had this issue. But instead of accessing variables, it happens to me whenever I have an array typed in the debugger and when it changes, it crashes. I have a WS array and whenever someone tries connecting, which adds to the array, node crashes if I have a line entered that references the array. If I wait for them to connect and then type the line, it doesn't crash. (tried node 16 and 15)

PS - If anyone has any alternative debugging module for node.js I'd love to hear it

@jespertheend
Copy link

I can no longer reproduce this as of node 16.6.0.

@jasnell
Copy link
Member

jasnell commented Jan 22, 2025

I'm unable to reproduce this locally, and given that there's been no further discussion or activity on this in years, I'm going to go ahead and close the issue. It can be reopened if necessary.

@jasnell jasnell closed this as completed Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

No branches or pull requests

9 participants