From b542f64923b048c7df269cf5a8245d102bdc0f7e Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Fri, 9 May 2025 15:18:48 +0200 Subject: [PATCH] Workaround for v8 crash v8 destroys the heap profiler after the heap spaces which can cause crashes: https://github.com/nodejs/node/blob/v24.0.1/deps/v8/src/heap/heap.cc#L6227-L6246 This workaround stops the heap profiler before the heap spaces are destroyed. --- bindings/profilers/heap.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bindings/profilers/heap.cc b/bindings/profilers/heap.cc index 6f7565bb..dc80992b 100644 --- a/bindings/profilers/heap.cc +++ b/bindings/profilers/heap.cc @@ -56,6 +56,11 @@ struct HeapProfilerState { explicit HeapProfilerState(v8::Isolate* isolate) : isolate(isolate) {} ~HeapProfilerState() { + auto profiler = isolate->GetHeapProfiler(); + if (profiler) { + profiler->StopSamplingHeapProfiler(); + } + UninstallNearHeapLimitCallback(); if (async) { // defer deletion of async when uv_close callback is invoked