From e6a334c5ed62158d4fc8d54cdaa1e6c8ff63a119 Mon Sep 17 00:00:00 2001 From: Marcel Schmidt Date: Thu, 3 Dec 2026 14:04:39 +0000 Subject: [PATCH] build: define HAVE_INSPECTOR for the libnode target The generated node_snapshot.cc is compiled in the libnode target and includes node_options.h, but only node_base gets HAVE_INSPECTOR (via node_inspector.gypi). EnvironmentOptions then has a different layout in the two targets (ODR violation). With LTO, GCC reports -Wodr and node crashed on exit with "free(): invalid pointer" in ~EnvironmentOptions. Set HAVE_INSPECTOR in libnode like node_base. Signed-off-by: Marcel Schmidt --- node.gyp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/node.gyp b/node.gyp index 3d7c29c6bdb..4fa8acbbbe0 100644 --- a/node.gyp +++ b/node.gyp @@ -1099,6 +1099,15 @@ ], 'conditions': [ + # node_snapshot.cc (generated) is compiled in this target and includes + # node_options.h; without HAVE_INSPECTOR here EnvironmentOptions lacks the + # inspector members (ODR violation with node_base, -Wodr; with LTO node + # crashed on exit with "free(): invalid pointer"). Same as node_base. + [ 'v8_enable_inspector==1', { + 'defines': [ 'HAVE_INSPECTOR=1' ], + }, { + 'defines': [ 'HAVE_INSPECTOR=0' ], + }], [ 'node_builtin_modules_path!=""', { # When loading builtins from disk, JS source files do not need to # trigger rebuilds since the binary reads them at runtime.