From e98d83dd161588a0b29d257cea130d13f6f7f2ef Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Fri, 2 May 2025 14:57:17 +0200 Subject: [PATCH 1/6] Fix compilation with xcode 16.3 (#205) xcode 16.3 ships with clang17 as default compiler. This version of clang warns about casts between incompatible function types, and v8 has some of those: ``` include/node/v8-persistent-handle.h:512:26: error: cast from 'typename WeakCallbackInfo::Callback' (aka 'void (*)(const WeakCallbackInfo &)') to 'Callback' (aka 'void (*)(const WeakCallbackInfo &)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch] ``` This commit adds a -Wno-cast-function-type-mismatch flag to the compiler flags to suppress these warnings (that would otherwise cause errors because of the -Werror flag) and also a -Wno-unknown-warning-option flag to suppress the warning about the unknown warning option "-Wcast-function-type-mismatch" for clang < 17. --- binding.gyp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/binding.gyp b/binding.gyp index d059d3c0..55fa8b9a 100644 --- a/binding.gyp +++ b/binding.gyp @@ -83,6 +83,8 @@ 'xcode_settings': { 'OTHER_CFLAGS+': [ "-Wno-deprecated-declarations", + "-Wno-cast-function-type-mismatch", # clang17 now warns about casts between incompatible function types and v8 has some of those + "-Wno-unknown-warning-option", # "-Wcast-function-type-mismatch" is not a valid warning option for clang < 17 "-Werror", '-std=gnu++20', ], From dd3fd4365f08fa710736dafd61b6fa62ce5c0f24 Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Thu, 8 May 2025 13:15:44 +0200 Subject: [PATCH 2/6] Node 24 support (#207) * Add support for Node 24. Remove support for Node 16. * Fix for Node 24 --------- Co-authored-by: Attila Szegedi --- .github/workflows/build.yml | 4 ++-- .gitlab/benchmarks.yml | 3 ++- bindings/profilers/wall.cc | 14 +++++++------- package.json | 4 +++- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5da2350b..937f7826 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: asan: strategy: matrix: - version: [16, 18, 20, 22, 23] + version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -23,7 +23,7 @@ jobs: valgrind: strategy: matrix: - version: [16, 18, 20, 22, 23] + version: [18, 20, 22, 24] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index 73bb6494..a18ecdba 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -32,10 +32,11 @@ benchmarks: - ./steps/run-benchmarks.sh parallel: matrix: - - MAJOR_NODE_VERSION: 16 - MAJOR_NODE_VERSION: 18 - MAJOR_NODE_VERSION: 20 - MAJOR_NODE_VERSION: 22 + # TODO: Re-enable this once supports for Node 24 is merged on main + # - MAJOR_NODE_VERSION: 24 artifacts: name: "reports" paths: diff --git a/bindings/profilers/wall.cc b/bindings/profilers/wall.cc index 3769dbf0..33f6e3e7 100644 --- a/bindings/profilers/wall.cc +++ b/bindings/profilers/wall.cc @@ -671,7 +671,7 @@ NAN_METHOD(WallProfiler::New) { NAN_METHOD(WallProfiler::Start) { WallProfiler* wallProfiler = - Nan::ObjectWrap::Unwrap(info.Holder()); + Nan::ObjectWrap::Unwrap(info.This()); if (info.Length() != 0) { return Nan::ThrowTypeError("Start must not have any arguments."); @@ -766,7 +766,7 @@ NAN_METHOD(WallProfiler::Stop) { bool restart = info[0].As()->Value(); WallProfiler* wallProfiler = - Nan::ObjectWrap::Unwrap(info.Holder()); + Nan::ObjectWrap::Unwrap(info.This()); v8::Local profile; auto err = wallProfiler->StopImpl(restart, profile); @@ -996,27 +996,27 @@ void WallProfiler::SetContext(Isolate* isolate, Local value) { } NAN_GETTER(WallProfiler::GetContext) { - auto profiler = Nan::ObjectWrap::Unwrap(info.Holder()); + auto profiler = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(profiler->GetContext(info.GetIsolate())); } NAN_SETTER(WallProfiler::SetContext) { - auto profiler = Nan::ObjectWrap::Unwrap(info.Holder()); + auto profiler = Nan::ObjectWrap::Unwrap(info.This()); profiler->SetContext(info.GetIsolate(), value); } NAN_GETTER(WallProfiler::SharedArrayGetter) { - auto profiler = Nan::ObjectWrap::Unwrap(info.Holder()); + auto profiler = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(profiler->jsArray_.Get(v8::Isolate::GetCurrent())); } NAN_METHOD(WallProfiler::V8ProfilerStuckEventLoopDetected) { - auto profiler = Nan::ObjectWrap::Unwrap(info.Holder()); + auto profiler = Nan::ObjectWrap::Unwrap(info.This()); info.GetReturnValue().Set(profiler->v8ProfilerStuckEventLoopDetected()); } NAN_METHOD(WallProfiler::Dispose) { - auto profiler = Nan::ObjectWrap::Unwrap(info.Holder()); + auto profiler = Nan::ObjectWrap::Unwrap(info.This()); delete profiler; } diff --git a/package.json b/package.json index e48b9ae3..c4f684f5 100644 --- a/package.json +++ b/package.json @@ -83,5 +83,7 @@ }, "engines": { "node": ">=16" - } + }, + "//": "Temporary fix to make nan@2.22.2 work with Node 24", + "postinstall": "sed -i '' 's/^.* Holder() const.*//' ./node_modules/nan/nan_callbacks_12_inl.h" } From 872f59c1ac0c0ec60ef335488126e76aa2647154 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 8 May 2025 14:11:45 +0200 Subject: [PATCH 3/6] Enable benchmarks on Node 24 (#208) --- .gitlab/benchmarks.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index a18ecdba..31d0c913 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -35,8 +35,7 @@ benchmarks: - MAJOR_NODE_VERSION: 18 - MAJOR_NODE_VERSION: 20 - MAJOR_NODE_VERSION: 22 - # TODO: Re-enable this once supports for Node 24 is merged on main - # - MAJOR_NODE_VERSION: 24 + - MAJOR_NODE_VERSION: 24 artifacts: name: "reports" paths: From 3e4ecd3396aada81e28a0c5a967ba1f8699ace48 Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Thu, 8 May 2025 14:34:46 +0200 Subject: [PATCH 4/6] Increase timeout for OOM profile export (#206) Also ensure that stdout/stderr from the child process are redirected to stderr from the parent process. --- bindings/profilers/heap.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bindings/profilers/heap.cc b/bindings/profilers/heap.cc index 0ad9a9de..6f7565bb 100644 --- a/bindings/profilers/heap.cc +++ b/bindings/profilers/heap.cc @@ -323,7 +323,7 @@ static int CreateTempFile(uv_loop_t& loop, std::string& filepath) { } static void ExportProfile(HeapProfilerState& state) { - const int64_t timeoutMs = 5000; + const int64_t timeoutMs = 15000; uv_loop_t loop; int r; @@ -355,6 +355,14 @@ static void ExportProfile(HeapProfilerState& state) { options.file = args[0]; options.args = args.data(); options.exit_cb = &OnExit; + uv_stdio_container_t child_stdio[3]; + child_stdio[0].flags = UV_IGNORE; + child_stdio[1].flags = UV_INHERIT_FD; + child_stdio[1].data.fd = 2; + child_stdio[2].flags = UV_INHERIT_FD; + child_stdio[2].data.fd = 2; + options.stdio = child_stdio; + options.stdio_count = 3; uv_process_t child_req; uv_timer_t timer; timer.data = &child_req; From d6a89d30d0311c03ab43d492d68cd2b18c5fc502 Mon Sep 17 00:00:00 2001 From: Nicolas Savoire Date: Sat, 10 May 2025 02:57:48 +0200 Subject: [PATCH 5/6] Workaround for v8 crash (#212) 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 From 777864174467d3e2381c37258a7291c12379ea5d Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 8 May 2025 14:13:43 +0200 Subject: [PATCH 6/6] v5.8.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index b5311269..755b1bd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@datadog/pprof", - "version": "5.7.1", + "version": "5.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@datadog/pprof", - "version": "5.7.1", + "version": "5.8.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index c4f684f5..a4cdb874 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@datadog/pprof", - "version": "5.7.1", + "version": "5.8.0", "description": "pprof support for Node.js", "repository": "datadog/pprof-nodejs", "main": "out/src/index.js",