electron/patches/node/enable_crashpad_linux_node_processes.patch

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
2.4 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: VerteDinde <keeleymhammond@gmail.com>
Date: Sun, 20 Nov 2022 21:45:20 -0800
Subject: fix: enable crashpad for ELECTRON_RUN_AS_NODE linux processes
Passes the crashpad handler PID and crashdump signal file descriptor
to child processes spawned with `ELECTRON_RUN_AS_NODE` which is used
by the crashpad client to connect with the handler process.
diff --git a/lib/child_process.js b/lib/child_process.js
chore: bump node to v22.17.0 (38-x-y) (#47556) * chore: bump node in DEPS to v22.17.0 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * chore: adjust crypto specs: - https://github.com/nodejs/node/pull/58117 - https://github.com/nodejs/node/pull/58387 * deps: update libuv to 1.51.0 https://github.com/nodejs/node/pull/58124 * test: fix test-buffer-tostring-range on allocation failure https://github.com/nodejs/node/pull/58416 * build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch https://github.com/nodejs/node/pull/58090 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * inspector: add protocol method Network.dataReceived https://github.com/nodejs/node/pull/58001 * test: force slow JSON.stringify path for overflow https://github.com/nodejs/node/pull/58181 * chore: fixup patch indices * 6049967: Remove protocol::Maybe and roll inspector_protocol https://chromium-review.googlesource.com/c/chromium/src/+/6049967 * chore: fixup crypto test patch * src: fix module buffer allocation https://github.com/nodejs/node/pull/57738 * crypto: expose process.features.openssl_is_boringssl https://github.com/nodejs/node/pull/58387 * util: add internal assignFunctionName() function https://github.com/nodejs/node/pull/57916 * build: fix pointer compression builds https://github.com/nodejs/node/pull/58171 * chore: put back config options * fixup! deps: update libuv to 1.51.0 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
index e848b3d5ee9b13ea3ea303eb3b57ef47ef951580..5b89c420f1a917526ab311fed52bff01637a86fe 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
chore: bump node to v22.17.0 (38-x-y) (#47556) * chore: bump node in DEPS to v22.17.0 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * chore: adjust crypto specs: - https://github.com/nodejs/node/pull/58117 - https://github.com/nodejs/node/pull/58387 * deps: update libuv to 1.51.0 https://github.com/nodejs/node/pull/58124 * test: fix test-buffer-tostring-range on allocation failure https://github.com/nodejs/node/pull/58416 * build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch https://github.com/nodejs/node/pull/58090 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * inspector: add protocol method Network.dataReceived https://github.com/nodejs/node/pull/58001 * test: force slow JSON.stringify path for overflow https://github.com/nodejs/node/pull/58181 * chore: fixup patch indices * 6049967: Remove protocol::Maybe and roll inspector_protocol https://chromium-review.googlesource.com/c/chromium/src/+/6049967 * chore: fixup crypto test patch * src: fix module buffer allocation https://github.com/nodejs/node/pull/57738 * crypto: expose process.features.openssl_is_boringssl https://github.com/nodejs/node/pull/58387 * util: add internal assignFunctionName() function https://github.com/nodejs/node/pull/57916 * build: fix pointer compression builds https://github.com/nodejs/node/pull/58171 * chore: put back config options * fixup! deps: update libuv to 1.51.0 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
@@ -62,6 +62,7 @@ let debug = require('internal/util/debuglog').debuglog(
);
const { Buffer } = require('buffer');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
+const { getCrashdumpSignalFD, getCrashpadHandlerPID } = process._linkedBinding('electron_common_crashpad_support');
const {
AbortError,
chore: bump node to v22.17.0 (38-x-y) (#47556) * chore: bump node in DEPS to v22.17.0 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * chore: adjust crypto specs: - https://github.com/nodejs/node/pull/58117 - https://github.com/nodejs/node/pull/58387 * deps: update libuv to 1.51.0 https://github.com/nodejs/node/pull/58124 * test: fix test-buffer-tostring-range on allocation failure https://github.com/nodejs/node/pull/58416 * build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch https://github.com/nodejs/node/pull/58090 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * inspector: add protocol method Network.dataReceived https://github.com/nodejs/node/pull/58001 * test: force slow JSON.stringify path for overflow https://github.com/nodejs/node/pull/58181 * chore: fixup patch indices * 6049967: Remove protocol::Maybe and roll inspector_protocol https://chromium-review.googlesource.com/c/chromium/src/+/6049967 * chore: fixup crypto test patch * src: fix module buffer allocation https://github.com/nodejs/node/pull/57738 * crypto: expose process.features.openssl_is_boringssl https://github.com/nodejs/node/pull/58387 * util: add internal assignFunctionName() function https://github.com/nodejs/node/pull/57916 * build: fix pointer compression builds https://github.com/nodejs/node/pull/58171 * chore: put back config options * fixup! deps: update libuv to 1.51.0 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
@@ -154,7 +155,6 @@ function fork(modulePath, args = [], options) {
ArrayPrototypeSplice(execArgv, index - 1, 2);
}
}
-
args = [...execArgv, modulePath, ...args];
if (typeof options.stdio === 'string') {
chore: bump node to v22.17.0 (38-x-y) (#47556) * chore: bump node in DEPS to v22.17.0 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * chore: adjust crypto specs: - https://github.com/nodejs/node/pull/58117 - https://github.com/nodejs/node/pull/58387 * deps: update libuv to 1.51.0 https://github.com/nodejs/node/pull/58124 * test: fix test-buffer-tostring-range on allocation failure https://github.com/nodejs/node/pull/58416 * build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch https://github.com/nodejs/node/pull/58090 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * inspector: add protocol method Network.dataReceived https://github.com/nodejs/node/pull/58001 * test: force slow JSON.stringify path for overflow https://github.com/nodejs/node/pull/58181 * chore: fixup patch indices * 6049967: Remove protocol::Maybe and roll inspector_protocol https://chromium-review.googlesource.com/c/chromium/src/+/6049967 * chore: fixup crypto test patch * src: fix module buffer allocation https://github.com/nodejs/node/pull/57738 * crypto: expose process.features.openssl_is_boringssl https://github.com/nodejs/node/pull/58387 * util: add internal assignFunctionName() function https://github.com/nodejs/node/pull/57916 * build: fix pointer compression builds https://github.com/nodejs/node/pull/58171 * chore: put back config options * fixup! deps: update libuv to 1.51.0 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
@@ -610,6 +610,22 @@ function normalizeSpawnArguments(file, args, options) {
'options.windowsVerbatimArguments');
}
+ const env = options.env || process.env;
+
+ if ((process.platform === 'linux') &&
+ ObjectPrototypeHasOwnProperty(env, 'ELECTRON_RUN_AS_NODE') &&
+ (file === process.execPath)) {
+ // On Linux, pass the file descriptor which crashpad handler process
+ // uses to monitor the child process and PID of the handler process.
+ // https://source.chromium.org/chromium/chromium/src/+/110.0.5415.0:components/crash/core/app/crashpad_linux.cc;l=199-206
+ const fd = getCrashdumpSignalFD();
+ const pid = getCrashpadHandlerPID();
+ if (fd !== -1 && pid !== -1) {
+ env.CRASHDUMP_SIGNAL_FD = fd;
+ env.CRASHPAD_HANDLER_PID = pid;
+ }
+ }
+
if (options.shell) {
chore: bump node to v18.13.0 (main) (#36818) * chore: bump node in DEPS to v18.13.0 * child_process: validate arguments for null bytes https://github.com/nodejs/node/pull/44782 * bootstrap: merge main thread and worker thread initializations https://github.com/nodejs/node/pull/44869 * module: ensure relative requires work from deleted directories https://github.com/nodejs/node/pull/42384 * src: add support for externally shared js builtins https://github.com/nodejs/node/issues/44000 * lib: disambiguate `native module` to `binding` https://github.com/nodejs/node/pull/45673 * test: convert test-debugger-pid to async/await https://github.com/nodejs/node/pull/45179 * deps: upgrade to libuv 1.44.2 https://github.com/nodejs/node/pull/42340 * src: fix cppgc incompatibility in v8 https://github.com/nodejs/node/pull/43521 * src: use qualified `std::move` call in node_http2 https://github.com/nodejs/node/pull/45555 * build: fix env.h for cpp20 https://github.com/nodejs/node/pull/45516 * test: remove experimental-wasm-threads flag https://github.com/nodejs/node/pull/45074 * src: iwyu in cleanup_queue.cc https://github.com/nodejs/node/pull/44983 * src: add missing include for `std::all_of` https://github.com/nodejs/node/pull/45541 * deps: update ICU to 72.1 https://github.com/nodejs/node/pull/45068 * chore: fixup patch indices * chore: remove errant semicolons - https://github.com/nodejs/node/pull/44179 - https://github.com/nodejs/node/pull/44193 * src: add support for externally shared js builtins https://github.com/nodejs/node/pull/44376 * chore: add missing GN filenames * deps: update nghttp2 to 1.51.0 https://github.com/nodejs/node/pull/45537 * chore: disable more Node.js snapshot tests The Snapshot feature is currently disabled * chore: disable ICU timezone tests Node.js uses a different version of ICU than Electron so they will often be out of sync. * chore: disable threadpool event tracing test Event tracing is not enabled in embedded Node.js * chore: fixup patch indices * chore: comments from review Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-01-11 11:33:48 +01:00
validateArgumentNullCheck(options.shell, 'options.shell');
const command = ArrayPrototypeJoin([file, ...args], ' ');
chore: bump node to v22.17.0 (38-x-y) (#47556) * chore: bump node in DEPS to v22.17.0 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * chore: adjust crypto specs: - https://github.com/nodejs/node/pull/58117 - https://github.com/nodejs/node/pull/58387 * deps: update libuv to 1.51.0 https://github.com/nodejs/node/pull/58124 * test: fix test-buffer-tostring-range on allocation failure https://github.com/nodejs/node/pull/58416 * build: use FILE_OFFSET_BITS=64 esp. on 32-bit arch https://github.com/nodejs/node/pull/58090 * build: use //third_party/simdutf by default in GN https://github.com/nodejs/node/pull/58115 * inspector: add protocol method Network.dataReceived https://github.com/nodejs/node/pull/58001 * test: force slow JSON.stringify path for overflow https://github.com/nodejs/node/pull/58181 * chore: fixup patch indices * 6049967: Remove protocol::Maybe and roll inspector_protocol https://chromium-review.googlesource.com/c/chromium/src/+/6049967 * chore: fixup crypto test patch * src: fix module buffer allocation https://github.com/nodejs/node/pull/57738 * crypto: expose process.features.openssl_is_boringssl https://github.com/nodejs/node/pull/58387 * util: add internal assignFunctionName() function https://github.com/nodejs/node/pull/57916 * build: fix pointer compression builds https://github.com/nodejs/node/pull/58171 * chore: put back config options * fixup! deps: update libuv to 1.51.0 * chore: update patches --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com>
2025-06-30 14:49:12 +02:00
@@ -643,7 +659,6 @@ function normalizeSpawnArguments(file, args, options) {
ArrayPrototypeUnshift(args, file);
}
- const env = options.env || process.env;
const envPairs = [];
// process.env.NODE_V8_COVERAGE always propagates, making it possible to