summaryrefslogtreecommitdiff
path: root/src/tracing/agent.cc
diff options
context:
space:
mode:
authorJason Ginchereau <jasongin@microsoft.com>2017-01-04 15:21:26 -0800
committerMichael Zasso <mzasso@localhost.localdomain>2017-01-07 13:56:43 +0100
commit58c38c2d2e6f4db57396dbe17a88b630a94f49f5 (patch)
treeb4a0fcf4d1f358cdb7407a64cba166c1b935da6d /src/tracing/agent.cc
parenta5bdcc39ac1353c37c12fd9b2bc11d6509b3c8bf (diff)
downloadandroid-node-v8-58c38c2d2e6f4db57396dbe17a88b630a94f49f5.tar.gz
android-node-v8-58c38c2d2e6f4db57396dbe17a88b630a94f49f5.tar.bz2
android-node-v8-58c38c2d2e6f4db57396dbe17a88b630a94f49f5.zip
src: fix TracingController cleanup
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: https://github.com/nodejs/node/pull/10623 Reviewed-By: Matthew Loring <mattloring@google.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'src/tracing/agent.cc')
-rw-r--r--src/tracing/agent.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tracing/agent.cc b/src/tracing/agent.cc
index 97a3e11a2c..ceab09e5a2 100644
--- a/src/tracing/agent.cc
+++ b/src/tracing/agent.cc
@@ -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);