Skip to content

Commit

Permalink
src: fix TracingController cleanup
Browse files Browse the repository at this point in the history
This fixes an incorrect deletion of the `TracingController` instance,
which in some environments could cause an error about an invalid
pointer passed to `free()`. The `TracingController` instance is
actually owned by a `unique_ptr` member of the platform, so calling
`platform::SetTracingController(nullptr)` is the correct way to
delete it. But before that, the `TraceBuffer` must be deleted in
order for the tracing loop to exit; that is accomplished by calling
`TracingController::Initialize(nullptr)`.

PR-URL: nodejs#10623
Reviewed-By: Matthew Loring <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
jasongin authored and italoacasas committed Mar 1, 2017
1 parent b89b2a7 commit 30c80cb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/tracing/agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ void Agent::Stop() {
// Perform final Flush on TraceBuffer. We don't want the tracing controller
// to flush the buffer again on destruction of the V8::Platform.
tracing_controller_->StopTracing();
delete tracing_controller_;
tracing_controller_->Initialize(nullptr);
tracing_controller_ = nullptr;

// Thread should finish when the tracing loop is stopped.
uv_thread_join(&thread_);
v8::platform::SetTracingController(platform_, nullptr);
Expand Down

0 comments on commit 30c80cb

Please sign in to comment.