Skip to content

Commit 30c80cb

Browse files
jasonginitaloacasas
authored andcommitted
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: #10623 Reviewed-By: Matthew Loring <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent b89b2a7 commit 30c80cb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/tracing/agent.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ void Agent::Stop() {
5656
// Perform final Flush on TraceBuffer. We don't want the tracing controller
5757
// to flush the buffer again on destruction of the V8::Platform.
5858
tracing_controller_->StopTracing();
59-
delete tracing_controller_;
59+
tracing_controller_->Initialize(nullptr);
60+
tracing_controller_ = nullptr;
61+
6062
// Thread should finish when the tracing loop is stopped.
6163
uv_thread_join(&thread_);
6264
v8::platform::SetTracingController(platform_, nullptr);

0 commit comments

Comments
 (0)