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

Commit 8edfd0a

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 8dd9f34 commit 8edfd0a

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
@@ -713,8 +713,8 @@ class Environment {
713713
#undef V
714714

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

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

770770
#if HAVE_INSPECTOR
771-
inspector::Agent inspector_agent_;
771+
inspector::Agent* const inspector_agent_;
772772
#endif
773773

774774
HandleWrapQueue handle_wrap_queue_;

0 commit comments

Comments
 (0)