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

src: create env->inspector_console_api_object earlier #24906

Closed
wants to merge 1 commit into from

Conversation

joyeecheung
Copy link
Member

Previously we create env->inspector_console_api_object() when
process.binding('inspector') is called, which may be too late
if the inspector console is used before the first call to
process.binding('inspector') - that is possible when
using --inspect-brk-node. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
installAdditionalCommandLineAPI() can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Dec 8, 2018
@joyeecheung
Copy link
Member Author

joyeecheung commented Dec 8, 2018

I can't seem to reproduce the crash with code or node-inspect, this is how to reproduce it:

  1. Run node --inspect-brk-node
  2. Open the Chrome DevTools, attach to the node process, and use the console in the UI.

It will crash like this:

See stack trace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
  * frame #0: 0x0000000101639582 node_g`v8::base::OS::Abort() at platform-posix.cc:399 [opt]
    frame #1: 0x0000000101631d65 node_g`v8::base::(anonymous namespace)::DefaultDcheckHandler(file=<unavailable>, line=<unavailable>, message=<unavailable>) at logging.cc:56 [opt]
    frame #2: 0x00000001005172d9 node_g`v8::Utils::OpenHandle(that=0x00007fffa8e2b9a0, allow_empty_handle=<unavailable>) at api-inl.h:121 [opt]
    frame #3: 0x0000000100554d4c node_g`v8::Object::GetPropertyNames(this=0x0000000000000000, context=<unavailable>, mode=kOwnOnly, property_filter=18, index_filter=<unavailable>, key_conversion=kKeepNumbers) at api.cc:4402 [opt]
    frame #4: 0x0000000100346115 node_g`node::inspector::NodeInspectorClient::installAdditionalCommandLineAPI(this=0x0000000103b11b18, context=(val_ = 0x0000000104067d50), target=(val_ = 0x0000000104067d68)) at inspector_agent.cc:507
    frame #5: 0x00000001004d076b node_g`v8_inspector::V8Console::createCommandLineAPI(this=0x0000000103b11af0, context=<unavailable>, sessionId=<unavailable>) at v8-console.cc:780 [opt]
    frame #6: 0x00000001004bdf03 node_g`v8_inspector::InjectedScript::commandLineAPI(this=0x0000000103f00470) at injected-script.cc:646 [opt]
    frame #7: 0x00000001004be1a8 node_g`v8_inspector::InjectedScript::Scope::installCommandLineAPI(this=0x00007ffeefbfb6d0) at injected-script.cc:682 [opt]
    frame #8: 0x00000001004eb111 node_g`v8_inspector::V8DebuggerAgentImpl::evaluateOnCallFrame(this=0x0000000103b196e0, callFrameId=<unavailable>, expression=0x00007ffeefbfb938, objectGroup=Maybe<v8_inspector::String16> @ 0x00007ffeefbfb8c8, includeCommandLineAPI=<unavailable>, silent=Maybe<bool> @ 0x00007ffeefbfb860, returnByValue=Maybe<bool> @ 0x00007ffeefbfb868, generatePreview=Maybe<bool> @ 0x00007ffeefbfb870, throwOnSideEffect=Maybe<bool> @ 0x00007ffeefbfb878, timeout=Maybe<double> @ 0x00007ffeefbfb880, result=0x00007ffeefbfb9c8, exceptionDetails=0x00007ffeefbfb9d0) at v8-debugger-agent-impl.cc:1065 [opt]
    frame #9: 0x00000001011ab7c9 node_g`v8_inspector::protocol::Debugger::DispatcherImpl::evaluateOnCallFrame(this=0x0000000103b198f0, callId=16, method=0x00007ffeefbfbbe0, message=0x00007ffeefbfbbc0, requestMessageObject=<unavailable>, errors=<unavailable>) at Debugger.cpp:1051 [opt]
    frame #10: 0x00000001011aab09 node_g`v8_inspector::protocol::Debugger::DispatcherImpl::dispatch(this=<unavailable>, callId=16, method=0x00007ffeefbfbbe0, message=0x00007ffeefbfbbc0, messageObject=unique_ptr<v8_inspector::protocol::DictionaryValue, std::__1::default_delete<v8_inspector::protocol::DictionaryValue> > @ 0x00007ffeefbfbb80) at Debugger.cpp:919 [opt]
    frame #11: 0x000000010119c208 node_g`v8_inspector::protocol::UberDispatcher::dispatch(this=<unavailable>, callId=16, method=0x00007ffeefbfbbe0, parsedMessage=unique_ptr<v8_inspector::protocol::Value, std::__1::default_delete<v8_inspector::protocol::Value> > @ 0x00007ffeefbfbc08, rawMessage=0x00007ffeefbfbbc0) at Protocol.cpp:815 [opt]
    frame #12: 0x0000000100501163 node_g`v8_inspector::V8InspectorSessionImpl::dispatchProtocolMessage(this=<unavailable>, message=<unavailable>) at v8-inspector-session-impl.cc:329 [opt]
    frame #13: 0x0000000100340752 node_g`node::inspector::(anonymous namespace)::ChannelImpl::dispatchProtocolMessage(this=0x0000000103b004d0, message=0x0000000103f00128) at inspector_agent.cc:235
    frame #14: 0x00000001003401d7 node_g`node::inspector::NodeInspectorClient::dispatchMessageFromFrontend(this=0x0000000103b11b18, session_id=1, message=0x0000000103f00128) at inspector_agent.cc:493
    frame #15: 0x000000010033eef3 node_g`node::inspector::(anonymous namespace)::SameThreadInspectorSession::Dispatch(this=0x0000000103b1c650, message=0x0000000103f00128) at inspector_agent.cc:909
    frame #16: 0x000000010038af6f node_g`node::inspector::(anonymous namespace)::MainThreadSessionState::Dispatch(this=0x0000000103b020f0, message=<unavailable>) at main_thread_interface.cc:171
    frame #17: 0x000000010038b6b4 node_g`void node::inspector::(anonymous namespace)::AnotherThreadObjectReference<node::inspector::(target=0x0000000103b020f0, fn=00 af 38 00 01 00 00 00 00 00 00 00 00 00 00 00, argument=0x0000000103f000b8)::MainThreadSessionState>::Apply<std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&) at main_thread_interface.cc:145
    frame #18: 0x000000010038bdd9 node_g`node::inspector::(anonymous namespace)::CallRequest<node::inspector::(anonymous namespace)::MainThreadSessionState, std::__1::__bind<void (&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::placeholders::__ph<1> const&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > > >::Call(node::inspector::MainThreadInterface*) [inlined] decltype(__f=(0x0000000103f000a0), __args=0x00007ffeefbfc440, __args=0x0000000103f000a8, __args=0x0000000103f000b8)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&)>(fp)(std::__1::forward<node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&>(fp0))) std::__1::__invoke<void (*&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&>(void (*&&&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), node::inspector::(anonymous namespace)::MainThreadSessionState*&&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&&&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&&&) at type_traits:4428
    frame #19: 0x000000010038bd57 node_g`node::inspector::(anonymous namespace)::CallRequest<node::inspector::(anonymous namespace)::MainThreadSessionState, std::__1::__bind<void (&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::placeholders::__ph<1> const&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > > >::Call(node::inspector::MainThreadInterface*) [inlined] std::__1::__bind_return<void (*)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&>, __is_valid_bind_return<void (*)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&> >::value>::type std::__1::__apply_functor<void (__f=(0x0000000103f000a0), __bound_args=size=3, __args=size=1)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >, 0ul, 1ul, 2ul, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&> >(void (*&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >&, std::__1::__tuple_indices<0ul, 1ul, 2ul>, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&>&&) at functional:2216
    frame #20: 0x000000010038bc4d node_g`node::inspector::(anonymous namespace)::CallRequest<node::inspector::(anonymous namespace)::MainThreadSessionState, std::__1::__bind<void (&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::placeholders::__ph<1> const&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > > >::Call(node::inspector::MainThreadInterface*) [inlined] std::__1::__bind_return<void (*)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&>, __is_valid_bind_return<void (*)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::tuple<std::__1::placeholders::__ph<1>, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >, std::__1::tuple<node::inspector::(anonymous namespace)::MainThreadSessionState*&&> >::value>::type std::__1::__bind<void (this=0x0000000103f000a0, __args=0x00007ffeefbfc440)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::placeholders::__ph<1> const&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > >::operator()<node::inspector::(anonymous namespace)::MainThreadSessionState*>(node::inspector::(anonymous namespace)::MainThreadSessionState*&&) at functional:2249
    frame #21: 0x000000010038bbaa node_g`node::inspector::(anonymous namespace)::CallRequest<node::inspector::(this=0x0000000103f00090, thread=0x0000000103e08600)::MainThreadSessionState, std::__1::__bind<void (&)(node::inspector::(anonymous namespace)::MainThreadSessionState*, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >&), std::__1::placeholders::__ph<1> const&, void (node::inspector::(anonymous namespace)::MainThreadSessionState::*&)(std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> >), std::__1::unique_ptr<v8_inspector::StringBuffer, std::__1::default_delete<v8_inspector::StringBuffer> > > >::Call(node::inspector::MainThreadInterface*) at main_thread_interface.cc:78
    frame #22: 0x0000000100381bdc node_g`node::inspector::MainThreadInterface::DispatchMessages(this=0x0000000103e08600) at main_thread_interface.cc:295
    frame #23: 0x00000001003868f9 node_g`node::inspector::(anonymous namespace)::DispatchMessagesTask::Run(this=0x0000000103f00560) at main_thread_interface.cc:92
    frame #24: 0x00000001002773df node_g`node::PerIsolatePlatformData::RunForegroundTask(task=unique_ptr<v8::Task, std::__1::default_delete<v8::Task> > @ 0x00007ffeefbfc998) at node_platform.cc:338
    frame #25: 0x0000000100273e4b node_g`node::PerIsolatePlatformData::FlushForegroundTasksInternal(this=0x0000000103b02208) at node_platform.cc:401
    frame #26: 0x0000000100279678 node_g`node::NodePlatform::FlushForegroundTasks(this=0x0000000103d1a970, isolate=0x0000000105000000) at node_platform.cc:437
    frame #27: 0x000000010033a7f6 node_g`node::inspector::NodeInspectorClient::runMessageLoop(this=0x0000000103b11b18) at inspector_agent.cc:632
    frame #28: 0x0000000100345f2c node_g`node::inspector::NodeInspectorClient::runMessageLoopOnPause(this=0x0000000103b11b18, context_group_id=1) at inspector_agent.cc:425
    frame #29: 0x00000001004da1cd node_g`v8_inspector::V8Debugger::handleProgramBreak(this=0x0000000103b11cc0, pausedContext=<unavailable>, exception=<unavailable>, breakpointIds=size=0, exceptionType=<unavailable>, isUncaught=<unavailable>) at v8-debugger.cc:537 [opt]
    frame #30: 0x0000000100a0a6ec node_g`v8::internal::Debug::OnDebugBreak(this=<unavailable>, break_points_hit=<unavailable>) at debug.cc:1777 [opt]
    frame #31: 0x0000000100a13c76 node_g`v8::internal::Debug::HandleDebugBreak(this=0x0000000103e028e0, ignore_break_mode=<unavailable>) at debug.cc:1965 [opt]
    frame #32: 0x0000000100eddc88 node_g`v8::internal::__RT_impl_Runtime_HandleDebuggerStatement(args=<unavailable>, isolate=0x0000000105000000) at runtime-debug.cc:120 [opt]
    frame #33: 0x0000000101a1f055 node_g`v8_Default_embedded_blob_ + 2914869
    frame #34: 0x0000000101771a54 node_g`v8_Default_embedded_blob_ + 107572
    frame #35: 0x0000000101b37c15 node_g`v8_Default_embedded_blob_ + 4064757
    frame #36: 0x00000f2b9970cb8e
    frame #37: 0x0000000101764563 node_g`v8_Default_embedded_blob_ + 53059
    frame #38: 0x00000f2b99705f7e
    frame #39: 0x0000000100abc475 node_g`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, v8::internal::Handle<v8::internal::Object>, v8::internal::Execution::MessageHandling, v8::internal::Execution::Target) [inlined] v8::internal::GeneratedCode<v8::internal::Object*, v8::internal::Object*, v8::internal::Object*, v8::internal::Object*, int, v8::internal::Object***>::Call(args=<unavailable>, args=<unavailable>, args=<unavailable>, args=5, args=0x0000000103d1af80) at simulator.h:113 [opt]
    frame #40: 0x0000000100abc465 node_g`v8::internal::(anonymous namespace)::Invoke(isolate=0x0000000000000000, is_construct=true, target=<unavailable>, receiver=<unavailable>, argc=5, args=0x0000000103d1af80, new_target=<unavailable>, message_handling=kReport, execution_target=kCallable) at execution.cc:155 [opt]
    frame #41: 0x0000000100abb9c4 node_g`v8::internal::(anonymous namespace)::CallInternal(isolate=0x0000000105000000, callable=Handle<v8::internal::Object> @ r13, receiver=<unavailable>, argc=32766, argv=0x0000000105000000, message_handling=<unavailable>, target=kCallable) at execution.cc:191 [opt]
    frame #42: 0x0000000100abb7c7 node_g`v8::internal::Execution::Call(isolate=<unavailable>, callable=<unavailable>, receiver=<unavailable>, argc=<unavailable>, argv=<unavailable>) at execution.cc:202 [opt]
    frame #43: 0x000000010055d1ca node_g`v8::Function::Call(this=0x0000000104067d10, context=<unavailable>, recv=<unavailable>, argc=<unavailable>, argv=<unavailable>) at api.cc:5019 [opt]
    frame #44: 0x00000001001da6dd node_g`node::native_module::NativeModuleLoader::CompileAndCall(this=0x00000001026b0568, context=(val_ = 0x000000010405af40), id="internal/bootstrap/loaders", parameters=0x00007ffeefbfe000 size=5, arguments=0x00007ffeefbfdfd8 size=5, optional_env=0x00007ffeefbfe670) at node_native_module.cc:141
    frame #45: 0x00000001000e7245 node_g`node::ExecuteBootstrapper(env=0x00007ffeefbfe670, id="internal/bootstrap/loaders", parameters=0x00007ffeefbfe000 size=5, arguments=0x00007ffeefbfdfd8 size=5) at node.cc:1199
    frame #46: 0x00000001000e6b2a node_g`node::LoadEnvironment(env=0x00007ffeefbfe670) at node.cc:1262
    frame #47: 0x00000001000f3aee node_g`node::Start(isolate=0x0000000105000000, isolate_data=0x0000000104069600, args=size=1, exec_args=size=1) at node.cc:1951
    frame #48: 0x00000001000ee070 node_g`node::Start(event_loop=0x00000001026c3020, args=size=1, exec_args=size=1) at node.cc:2068
    frame #49: 0x00000001000ed78f node_g`node::Start(argc=2, argv=0x0000000103d1a710) at node.cc:2127
    frame #50: 0x000000010146e12e node_g`main(argc=2, argv=0x00007ffeefbff638) at node_main.cc:124
    frame #51: 0x0000000100001034 node_g`start + 52

With this patch the crash is gone.

@addaleax addaleax added the inspector Issues and PRs related to the V8 inspector protocol label Dec 8, 2018
@joyeecheung
Copy link
Member Author

@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 10, 2018
@Trott
Copy link
Member

Trott commented Dec 10, 2018

@Trott
Copy link
Member

Trott commented Dec 11, 2018

Full rebuild CI now that we have test-cli-syntax marked unreliable: https://ci.nodejs.org/job/node-test-pull-request/19435/

@Trott
Copy link
Member

Trott commented Dec 12, 2018

@Trott
Copy link
Member

Trott commented Dec 13, 2018

Landed in a1b283c

@Trott Trott closed this Dec 13, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Dec 13, 2018
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: nodejs#24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
BethGriggs pushed a commit that referenced this pull request Dec 17, 2018
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: #24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Dec 18, 2018
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: nodejs#24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 12, 2019
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: #24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Feb 12, 2019
BethGriggs pushed a commit that referenced this pull request Feb 20, 2019
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: #24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
rvagg pushed a commit that referenced this pull request Feb 28, 2019
Previously we create env->inspector_console_api_object() when
`process.binding('inspector')` is called, which may be too late
if the inspector console is used before the first call to
`process.binding('inspector')` - that is possible when
using `--inspect-brk-node`. Setting a breakpoint and using the
inspector console before that would crash the process.

This patch moves the initialization of the console API object to
the point when Environment is initialized so that
`installAdditionalCommandLineAPI()` can be essentially a noop
if we use the inspector console before the inspector binding
is initialized instead of crashing on an empty object.

PR-URL: #24906
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. inspector Issues and PRs related to the V8 inspector protocol lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants