fix: enable crashpad for ELECTRON_RUN_AS_NODE processes (#36460)
* wip: enable crashpad for node processes fix: add PID testing method wip: plumb fd into child_process in node * node::ProcessInitializationFlags::kNoDefaultSignalHandling * chore: clean up debug logging * chore: gate platform includes * test: clean up node process test * fix: pass pid in node_main * chore: cleanup impl * chore: fixup patch method definition * fix: expose bound methods to node_main * fix: remove bound methods * fix: crashpad connection for all ELECTRON_RUN_AS_NODE processes * chore: fix typo * chore: address review feedback * chore: delay crashpad initialization * chore: ensure options.env, code hygiene * chore: add argv test, check for process.env over {} * fix: fix test, return options.env immutability Co-authored-by: VerteDinde <keeleymhammond@gmail.com> Co-authored-by: Jeremy Rose <jeremya@chromium.org> Co-authored-by: VerteDinde <vertedinde@electronjs.org>
This commit is contained in:
parent
16a7bd7102
commit
2c723d7e84
10 changed files with 194 additions and 12 deletions
51
patches/node/enable_crashpad_linux_node_processes.patch
Normal file
51
patches/node/enable_crashpad_linux_node_processes.patch
Normal file
|
@ -0,0 +1,51 @@
|
|||
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
|
||||
index 73c1dc769542865bdf7a2a03c16cef141d3f4b05..76151c75ef7ad420d2642c1cd11c8624b7d7e2a0 100644
|
||||
--- a/lib/child_process.js
|
||||
+++ b/lib/child_process.js
|
||||
@@ -59,6 +59,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,
|
||||
@@ -159,7 +160,6 @@ function fork(modulePath, args = [], options) {
|
||||
ArrayPrototypeSplice(execArgv, index - 1, 2);
|
||||
}
|
||||
}
|
||||
-
|
||||
args = [...execArgv, modulePath, ...args];
|
||||
|
||||
if (typeof options.stdio === 'string') {
|
||||
@@ -613,6 +613,21 @@ function normalizeSpawnArguments(file, args, options) {
|
||||
'options.windowsVerbatimArguments');
|
||||
}
|
||||
|
||||
+ if (process.platform === 'linux') {
|
||||
+ if (ObjectPrototypeHasOwnProperty(options.env || process.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) {
|
||||
+ options.env.CRASHDUMP_SIGNAL_FD = fd;
|
||||
+ options.env.CRASHPAD_HANDLER_PID = pid;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (options.shell) {
|
||||
const command = ArrayPrototypeJoin([file, ...args], ' ');
|
||||
// Set the shell, switches, and commands.
|
Loading…
Add table
Add a link
Reference in a new issue