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