From eb0002857b42dbb00be44580f00dd24e7a701bd4 Mon Sep 17 00:00:00 2001 From: Hannes Payer Date: Wed, 22 Nov 2017 14:43:42 +0100 Subject: [PATCH] src: start heap object tracking after platform is initialized Garbage collection is triggered by the heap object tracker. The garbage collector may spawn garbage collection tasks on the foreground thread. This is only allowed after registering the isolate in the platform which happens in IsolateData. This CL moves the starting of the heap object tracker after calling IsolateData to ensure that. PR-URL: https://github.com/nodejs/node/pull/17249 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Franziska Hinkelmann Reviewed-By: Timothy Gu Reviewed-by: Michael Lippautz --- src/node.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/node.cc b/src/node.cc index ad2e3df933dc23..7384215106e191 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4887,10 +4887,6 @@ inline int Start(uv_loop_t* event_loop, isolate->SetAutorunMicrotasks(false); isolate->SetFatalErrorHandler(OnFatalError); - if (track_heap_objects) { - isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); - } - { Mutex::ScopedLock scoped_lock(node_isolate_mutex); CHECK_EQ(node_isolate, nullptr); @@ -4907,6 +4903,9 @@ inline int Start(uv_loop_t* event_loop, event_loop, v8_platform.Platform(), allocator.zero_fill_field()); + if (track_heap_objects) { + isolate->GetHeapProfiler()->StartTrackingHeapObjects(true); + } exit_code = Start(isolate, &isolate_data, argc, argv, exec_argc, exec_argv); }