Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 63efd04

Browse files
ofrobotsaddaleax
authored andcommitted
src: destroy inspector agent before context
The inspector_agent depends on the context still being accessible during the destructor execution. PR-URL: nodejs/node#16472 Fixes: nodejs/node#15558 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent f34f9d0 commit 63efd04

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/env-inl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ inline Environment::Environment(IsolateData* isolate_data,
279279
emit_napi_warning_(true),
280280
makecallback_cntr_(0),
281281
#if HAVE_INSPECTOR
282-
inspector_agent_(this),
282+
inspector_agent_(new inspector::Agent(this)),
283283
#endif
284284
http_parser_buffer_(nullptr),
285285
fs_stats_field_array_(nullptr),
@@ -319,6 +319,11 @@ inline Environment::Environment(IsolateData* isolate_data,
319319
inline Environment::~Environment() {
320320
v8::HandleScope handle_scope(isolate());
321321

322+
#if HAVE_INSPECTOR
323+
// Destroy inspector agent before erasing the context.
324+
delete inspector_agent_;
325+
#endif
326+
322327
context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,
323328
nullptr);
324329
#define V(PropertyName, TypeName) PropertyName ## _.Reset();

src/env.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ class Environment {
712712
#undef V
713713

714714
#if HAVE_INSPECTOR
715-
inline inspector::Agent* inspector_agent() {
716-
return &inspector_agent_;
715+
inline inspector::Agent* inspector_agent() const {
716+
return inspector_agent_;
717717
}
718718
#endif
719719

@@ -767,7 +767,7 @@ class Environment {
767767
std::map<std::string, uint64_t> performance_marks_;
768768

769769
#if HAVE_INSPECTOR
770-
inspector::Agent inspector_agent_;
770+
inspector::Agent* const inspector_agent_;
771771
#endif
772772

773773
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
 (0)