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

Commit

Permalink
src: destroy inspector agent before context
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ofrobots authored and addaleax committed Oct 26, 2017
1 parent f34f9d0 commit 63efd04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ inline Environment::Environment(IsolateData* isolate_data,
emit_napi_warning_(true),
makecallback_cntr_(0),
#if HAVE_INSPECTOR
inspector_agent_(this),
inspector_agent_(new inspector::Agent(this)),
#endif
http_parser_buffer_(nullptr),
fs_stats_field_array_(nullptr),
Expand Down Expand Up @@ -319,6 +319,11 @@ inline Environment::Environment(IsolateData* isolate_data,
inline Environment::~Environment() {
v8::HandleScope handle_scope(isolate());

#if HAVE_INSPECTOR
// Destroy inspector agent before erasing the context.
delete inspector_agent_;
#endif

context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex,
nullptr);
#define V(PropertyName, TypeName) PropertyName ## _.Reset();
Expand Down
6 changes: 3 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ class Environment {
#undef V

#if HAVE_INSPECTOR
inline inspector::Agent* inspector_agent() {
return &inspector_agent_;
inline inspector::Agent* inspector_agent() const {
return inspector_agent_;
}
#endif

Expand Down Expand Up @@ -767,7 +767,7 @@ class Environment {
std::map<std::string, uint64_t> performance_marks_;

#if HAVE_INSPECTOR
inspector::Agent inspector_agent_;
inspector::Agent* const inspector_agent_;
#endif

HandleWrapQueue handle_wrap_queue_;
Expand Down

0 comments on commit 63efd04

Please sign in to comment.