From 10bac43b873fe45869e15b36aac1c1e5bc89b6e0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 29 Sep 2025 22:48:55 +0200 Subject: [PATCH] tests/server: drop unsafe `open()` override in signal handler (Windows) Turns out the signal handler on Windows still wasn't signal safe after the previous round of fix. There is an `open()` call made from there, and `open` happens to be unconditionally overridden via `curl_setup.h` on Windows, to its local implementation (`curlx_win32_open()`), which does memory allocations and potentially other things that are not signal safe. This is a temporary fix, till avoiding the override of system symbols `open` and `stat` on Windows. FTR this did not fix the CI 2304 errors, diskspace fail or job hangs due to 0xC0000142 fork failure (it's rare all three occurs in the same run): https://github.com/curl/curl/actions/runs/18110523584?pr=18774 Ref: #18634 Follow-up e95f509c66abdd88ae02e3243cdc217f19c4a330 #16852 Closes #18774 --- tests/server/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/server/util.c b/tests/server/util.c index 052effa895..41f42ca42e 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -373,12 +373,12 @@ static void exit_signal_handler(int signum) (void)!write(STDERR_FILENO, msg, sizeof(msg) - 1); } else { + int fd; #ifdef _WIN32 -#define OPENMODE S_IREAD | S_IWRITE + fd = _open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IREAD | S_IWRITE); #else -#define OPENMODE S_IRUSR | S_IWUSR + fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR | S_IWUSR); #endif - int fd = open(serverlogfile, O_WRONLY|O_CREAT|O_APPEND, OPENMODE); if(fd != -1) { static const char msg[] = "exit_signal_handler: called\n"; (void)!write(fd, msg, sizeof(msg) - 1); -- 2.47.3