Commit 7582b2aa authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

Fix 873811 by guarding v8_session_ for calls via V8Inspector::Channel.

v8_session_ starts out being a nullptr, and the constructor
of InspectorSession initializes it. However, this initialization
involves calling inspector->connect which calls the inspector
session (this) with sendResponse / flushProtocolNotifications.

This PR tries to resolve it by guarding v8_session_ for the
V8Inspector::Channel methods.

Bug: 873811
Change-Id: I8142eb61f9a8f6fb003b9baa0b6222730234ccae
Reviewed-on: https://chromium-review.googlesource.com/1235054Reviewed-by: default avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592881}
parent f36265bb
...@@ -49,8 +49,12 @@ InspectorSession::InspectorSession( ...@@ -49,8 +49,12 @@ InspectorSession::InspectorSession(
v8_session_state_(kV8StateKey), v8_session_state_(kV8StateKey),
v8_session_state_json_(&v8_session_state_, /*default_value=*/String()) { v8_session_state_json_(&v8_session_state_, /*default_value=*/String()) {
v8_session_state_.InitFrom(&session_state_); v8_session_state_.InitFrom(&session_state_);
// inspector->connect may result in calls to |this| against the
// V8Inspector::Channel interface for receiving responses / notifications,
// while v8_session_ is still nullptr.
v8_session_ = v8_session_ =
inspector->connect(context_group_id, this, inspector->connect(context_group_id, /*channel*/ this,
ToV8InspectorStringView(v8_session_state_json_.Get())); ToV8InspectorStringView(v8_session_state_json_.Get()));
} }
...@@ -144,7 +148,8 @@ void InspectorSession::SendProtocolResponse(int call_id, ...@@ -144,7 +148,8 @@ void InspectorSession::SendProtocolResponse(int call_id,
if (disposed_) if (disposed_)
return; return;
flushProtocolNotifications(); flushProtocolNotifications();
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON())); if (v8_session_)
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON()));
client_->SendProtocolResponse(session_id_, call_id, message, client_->SendProtocolResponse(session_id_, call_id, message,
session_state_.TakeUpdates()); session_state_.TakeUpdates());
} }
...@@ -210,7 +215,8 @@ void InspectorSession::flushProtocolNotifications() { ...@@ -210,7 +215,8 @@ void InspectorSession::flushProtocolNotifications() {
agents_[i]->FlushPendingProtocolNotifications(); agents_[i]->FlushPendingProtocolNotifications();
if (!notification_queue_.size()) if (!notification_queue_.size())
return; return;
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON())); if (v8_session_)
v8_session_state_json_.Set(ToCoreString(v8_session_->stateJSON()));
for (wtf_size_t i = 0; i < notification_queue_.size(); ++i) { for (wtf_size_t i = 0; i < notification_queue_.size(); ++i) {
client_->SendProtocolNotification(session_id_, client_->SendProtocolNotification(session_id_,
notification_queue_[i]->Serialize(), notification_queue_[i]->Serialize(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment