Repository navigation
Conversation
This reverts commit 6784601. All MSVC.
This caused no error, but it's incorrect and introduced a potential difference to builds without `STDERR_FILENO`, which in practice means MSVC. The macro's only use needs to use `stderr` always. Follow-up to e5bb88b curl#11958
bagder
approved these changes
Mar 28, 2025
This reverts commit 35d8821. Same.
pps83
pushed a commit
to pps83/curl
that referenced
this pull request
Apr 26, 2025
Before this patch the signal handler called `logmsg()` which in turn called `printf()` variants (internal implementations), and `FILE *` functions, `localtime()`. Some of these called `malloc`/`free`, which isn't supported in s signal handler. Replace them with `write` calls, losing some logging functionality. Also: - De-dupe and move `STD*_FILENO` macros to `lib/curl_setup.h`. Revert the `src` definition to point to `stderr`, instead of `tool_stderr`. Follow-up to e5bb88b curl#11958 POSIX specs with list of functions allowed in a signal handler: 2004: https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03 2017: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03 2024: https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04_03 Linux CI run with the thread sanitizer going crazy when hitting the signal handler in test 1238 and 1242 (TFTP): ``` WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=12582) #0 malloc <null> (servers+0x5ed70) #1 _IO_file_doallocate <null> (libc.so.6+0x851b4) curl#2 formatf /home/runner/work/curl/curl/bld/tests/server/../../lib/../../lib/mprintf.c:886:9 (servers+0xdff77) [...] WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=12582) #0 free <null> (servers+0x5f453) #1 fclose <null> (libc.so.6+0x8532f) curl#2 logmsg /home/runner/work/curl/curl/bld/tests/server/../../../tests/server/util.c:134:5 (servers+0xe684d) ``` Ref: https://github.com/curl/curl/actions/runs/14118903372/job/39555309490?pr=16851 Closes curl#16852
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Sep 29, 2025
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 a local implementation, which does memory allocations and possibly other things that are not signal safe. Ref: curl#18634 Follow-up e95f509 curl#16852
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Sep 29, 2025
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 a local implementation, which does memory allocations and possibly other things that are not signal safe. Ref: curl#18634 Follow-up e95f509 curl#16852
1 task
vszakats
added a commit
that referenced
this pull request
Sep 29, 2025
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 e95f509 #16852 Closes #18774
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Jun 15, 2026
Follow-up to c8d8f08 curl#22023 Follow-up to e95f509 curl#16852
vszakats
added a commit
that referenced
this pull request
Jun 15, 2026
In some configurations the `write()` functions gets the
`warn_unused_result` attribute, that makes casting to `(void)`
ineffective to silence this warning. Seen with glibc, in 5 CI jobs.
The warning option appeared in GCC 4.5 and comes enabled by default.
```
tests/server/util.c:329:5: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
329 | write(STDERR_FILENO, msg, sizeof(msg) - 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Ref: https://github.com/curl/curl/actions/runs/27548333990/job/81427544632
Refs:
#22023 (comment)
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Warning-Options.html#index-Wunused-result
https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Common-Attributes.html#index-warn_005funused_005fresult
https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result
Follow-up to c8d8f08 #22023
Follow-up to e95f509 #16852
Closes #22034
vszakats
added a commit
that referenced
this pull request
Aug 5, 2026
`strlen()` is only guaranteed to be signal-safe since POSIX.1-2008. Ref: https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03 Reported by Copilot Bug: #22487 (review) Follow-up to e95f509 #16852 Closes #22491
1 task done
vszakats
added a commit
that referenced
this pull request
Aug 6, 2026
In year 2020 the Unixy signal handler received a `logmsg()` call to log the signal number, but at the same time it already saved it to a global variable and logged it on exit, meaning this extra `logmsg()` was redundant. Because `logmsg()` is not signal-safe, this call was replaced in 2025 with signal-safe logging, but without the signal number, while also adding complexity, spent on trying to open the log file and handle errors. All for nothing, because the signal number was logged all along. This patch removes all this, and simplifies it to a single, signal-safe `write()` to STDERR to say that the signal handler triggered. This is also non-critical, but may help debugging. Also: point the POSIX documentation to the 2004 revision, which has a shorter list of safe functions. (was: 2018) Follow-up to e95f509 #16852 Follow-up to 9869f6d #5218 Closes #22507
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this patch the signal handler called
logmsg()which in turncalled
printf()variants (internal implementations), andFILE *functions,
localtime(). Some of these calledmalloc/free, whichisn't supported in s signal handler. Replace them with
writecalls,losing some logging functionality.
Also:
STD*_FILENOmacros tolib/curl_setup.h. Revertthe
srcdefinition to point tostderr, instead oftool_stderr.Follow-up to e5bb88b tool: use our own stderr variable #11958
POSIX specs with list of functions allowed in a signal handler:
2004: https://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
2017: https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04_03
2024: https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04_03
Linux CI run with the thread sanitizer going crazy when
hitting the signal handler in test 1238 and 1242 (TFTP):
Ref: https://github.com/curl/curl/actions/runs/14118903372/job/39555309490?pr=16851