blob: adc2b3f221b5ca1b9c6abd392430bb9451553eed [file] [log] [blame]
James Kuszmaulb13e13f2023-11-22 20:44:04 -08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Tyler Veness <calcmogul@gmail.com>
3Date: Fri, 14 Jul 2023 17:33:08 -0700
Maxwell Henderson80bec322024-01-09 15:48:44 -08004Subject: [PATCH 1/9] Revert "win,process: write minidumps when sending SIGQUIT
5 (#3840)"
James Kuszmaulb13e13f2023-11-22 20:44:04 -08006
7This reverts commit 748d894e82abcdfff7429cf745003e182c47f163.
8---
Maxwell Henderson80bec322024-01-09 15:48:44 -08009 CMakeLists.txt | 6 +--
James Kuszmaulb13e13f2023-11-22 20:44:04 -080010 configure.ac | 2 +-
11 include/uv/win.h | 1 -
12 src/win/process.c | 116 ----------------------------------------------
Maxwell Henderson80bec322024-01-09 15:48:44 -080013 4 files changed, 2 insertions(+), 123 deletions(-)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080014
15diff --git a/CMakeLists.txt b/CMakeLists.txt
Maxwell Henderson80bec322024-01-09 15:48:44 -080016index 72377851b69f74c5285fd34ae206ad6bed3745c1..3ec6bd00542f5aacfc6245b1f82e365eb1cff02c 100644
James Kuszmaulb13e13f2023-11-22 20:44:04 -080017--- a/CMakeLists.txt
18+++ b/CMakeLists.txt
Maxwell Henderson80bec322024-01-09 15:48:44 -080019@@ -183,11 +183,7 @@ if(WIN32)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080020 advapi32
21 iphlpapi
22 userenv
23- ws2_32
24- dbghelp
25- ole32
Maxwell Henderson80bec322024-01-09 15:48:44 -080026- uuid
27- shell32)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080028+ ws2_32)
29 list(APPEND uv_sources
30 src/win/async.c
31 src/win/core.c
32diff --git a/configure.ac b/configure.ac
Maxwell Henderson80bec322024-01-09 15:48:44 -080033index 0a1042ce3d384f6a4392a100275c14cb31ba2816..6c87c36039446e04f6c30c23b8fdb9b957dd610d 100644
James Kuszmaulb13e13f2023-11-22 20:44:04 -080034--- a/configure.ac
35+++ b/configure.ac
36@@ -74,7 +74,7 @@ AM_CONDITIONAL([OS400], [AS_CASE([$host_os],[os400], [true], [false])
37 AM_CONDITIONAL([SUNOS], [AS_CASE([$host_os],[solaris*], [true], [false])])
38 AM_CONDITIONAL([WINNT], [AS_CASE([$host_os],[mingw*], [true], [false])])
39 AS_CASE([$host_os],[mingw*], [
Maxwell Henderson80bec322024-01-09 15:48:44 -080040- LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid -lshell32"
James Kuszmaulb13e13f2023-11-22 20:44:04 -080041+ LIBS="$LIBS -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32"
42 ])
43 AS_CASE([$host_os], [solaris2.10], [
44 CFLAGS="$CFLAGS -DSUNOS_NO_IFADDRS"
45diff --git a/include/uv/win.h b/include/uv/win.h
46index 6f8c47298e407bcb0151cf383a8370b71074f03e..eb74776978340a4910194bae35a9da6493e8c0a6 100644
47--- a/include/uv/win.h
48+++ b/include/uv/win.h
49@@ -91,7 +91,6 @@ typedef struct pollfd {
50 * variants (Linux and Darwin)
51 */
52 #define SIGHUP 1
53-#define SIGQUIT 3
54 #define SIGKILL 9
55 #define SIGWINCH 28
56
57diff --git a/src/win/process.c b/src/win/process.c
Maxwell Henderson80bec322024-01-09 15:48:44 -080058index 43059858f3112e7e7185796525697629b72988df..119b46cb3f37122395c172c6e9700d472a2173ed 100644
James Kuszmaulb13e13f2023-11-22 20:44:04 -080059--- a/src/win/process.c
60+++ b/src/win/process.c
61@@ -32,9 +32,6 @@
62 #include "internal.h"
63 #include "handle-inl.h"
64 #include "req-inl.h"
65-#include <dbghelp.h>
66-#include <shlobj.h>
67-#include <psapi.h> /* GetModuleBaseNameW */
68
69
70 #define SIGKILL 9
Maxwell Henderson80bec322024-01-09 15:48:44 -080071@@ -1173,120 +1170,7 @@ static int uv__kill(HANDLE process_handle, int signum) {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080072 return UV_EINVAL;
73 }
74
75- /* Create a dump file for the targeted process, if the registry key
76- * `HKLM:Software\Microsoft\Windows\Windows Error Reporting\LocalDumps`
77- * exists. The location of the dumps can be influenced by the `DumpFolder`
78- * sub-key, which has a default value of `%LOCALAPPDATA%\CrashDumps`, see [0]
79- * for more detail. Note that if the dump folder does not exist, we attempt
80- * to create it, to match behavior with WER itself.
81- * [0]: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps */
82- if (signum == SIGQUIT) {
83- HKEY registry_key;
84- DWORD pid, ret;
85- WCHAR basename[MAX_PATH];
86-
87- /* Get target process name. */
88- GetModuleBaseNameW(process_handle, NULL, &basename[0], sizeof(basename));
89-
90- /* Get PID of target process. */
91- pid = GetProcessId(process_handle);
92-
93- /* Get LocalDumps directory path. */
94- ret = RegOpenKeyExW(
95- HKEY_LOCAL_MACHINE,
96- L"SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps",
97- 0,
98- KEY_QUERY_VALUE,
99- &registry_key);
100- if (ret == ERROR_SUCCESS) {
101- HANDLE hDumpFile = NULL;
102- WCHAR dump_folder[MAX_PATH], dump_name[MAX_PATH];
103- DWORD dump_folder_len = sizeof(dump_folder), key_type = 0;
104- ret = RegGetValueW(registry_key,
105- NULL,
106- L"DumpFolder",
107- RRF_RT_ANY,
108- &key_type,
109- (PVOID) dump_folder,
110- &dump_folder_len);
111- if (ret != ERROR_SUCCESS) {
112- /* Default value for `dump_folder` is `%LOCALAPPDATA%\CrashDumps`. */
113- WCHAR* localappdata;
114- SHGetKnownFolderPath(&FOLDERID_LocalAppData, 0, NULL, &localappdata);
115- _snwprintf_s(dump_folder,
116- sizeof(dump_folder),
117- _TRUNCATE,
118- L"%ls\\CrashDumps",
119- localappdata);
120- CoTaskMemFree(localappdata);
121- }
122- RegCloseKey(registry_key);
123-
124- /* Create dump folder if it doesn't already exist. */
125- CreateDirectoryW(dump_folder, NULL);
126-
127- /* Construct dump filename from process name and PID. */
128- _snwprintf_s(dump_name,
129- sizeof(dump_name),
130- _TRUNCATE,
131- L"%ls\\%ls.%d.dmp",
132- dump_folder,
133- basename,
134- pid);
135-
136- hDumpFile = CreateFileW(dump_name,
137- GENERIC_WRITE,
138- 0,
139- NULL,
140- CREATE_NEW,
141- FILE_ATTRIBUTE_NORMAL,
142- NULL);
143- if (hDumpFile != INVALID_HANDLE_VALUE) {
144- DWORD dump_options, sym_options;
145- FILE_DISPOSITION_INFO DeleteOnClose = { TRUE };
146-
147- /* If something goes wrong while writing it out, delete the file. */
148- SetFileInformationByHandle(hDumpFile,
149- FileDispositionInfo,
150- &DeleteOnClose,
151- sizeof(DeleteOnClose));
152-
153- /* Tell wine to dump ELF modules as well. */
154- sym_options = SymGetOptions();
155- SymSetOptions(sym_options | 0x40000000);
156-
157-/* MiniDumpWithAvxXStateContext might be undef in server2012r2 or mingw < 12 */
158-#ifndef MiniDumpWithAvxXStateContext
159-#define MiniDumpWithAvxXStateContext 0x00200000
160-#endif
161- /* We default to a fairly complete dump. In the future, we may want to
162- * allow clients to customize what kind of dump to create. */
163- dump_options = MiniDumpWithFullMemory |
164- MiniDumpIgnoreInaccessibleMemory |
165- MiniDumpWithAvxXStateContext;
166-
167- if (MiniDumpWriteDump(process_handle,
168- pid,
169- hDumpFile,
170- dump_options,
171- NULL,
172- NULL,
173- NULL)) {
174- /* Don't delete the file on close if we successfully wrote it out. */
175- FILE_DISPOSITION_INFO DontDeleteOnClose = { FALSE };
176- SetFileInformationByHandle(hDumpFile,
177- FileDispositionInfo,
178- &DontDeleteOnClose,
179- sizeof(DontDeleteOnClose));
180- }
181- SymSetOptions(sym_options);
182- CloseHandle(hDumpFile);
183- }
184- }
185- }
186-
187 switch (signum) {
188- case SIGQUIT:
189 case SIGTERM:
190 case SIGKILL:
191 case SIGINT: {