Repository navigation
Conversation
When a curl binary is built with Visual Studio in debug mode, it uses the matching, debug-enabled CRT. The debug CRT by default pops up an interactive GUI popup by default, also on CI machines, e.g. on AppVeyor CI, on `assert()` and other low-level failures. This causes the CI job to appear hung, with nothing printed to the CI log, waiting on someone clicking on a GUI MessageBox. On a CI machine this is not desired. The job then quits on timeout, blocking other queued tasks (for 1 hours on AppVeyor CI). To make such failures CI-friendly, fix it by configuring this behavior in curl.exe, servers.exe and unit test binaries, to output all errors to stderr, overiding the GUI popup. This can potentially save a lot of hair-pulling. Example output, after this patch: ``` Assertion failed: r == 10, file C:\projects\curl\tests\libtest\first.c, line 272 abort() has been called ``` In theory, this issue may also apply to mingw-w64 builds (they use the same UCRT as VS2015+ builds), but I could not make the configuation code link correctly. (in practice I haven't seen mingw-w64 builds hanging in CI, but that's more like a coincidence.) Feel free to extend this to mingw-w64 if there is a sensible way to do it. Refs: https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportfile https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportmode https://learn.microsoft.com/cpp/c-runtime-library/reference/set-error-mode Ref: curl#23336 Ref: edfa537 curl#16456 Cherry-picked from curl#23306
I prefer _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);Another thing is crtdbg usually needs to be included first to get line numbers for memory leaks, /FI"crtdbg.h" and IIRC it may interfere with curl memory tracking or can give extra warnings because of the stuff it overrides so it's not really a clean solution. For the file and line numbers I have this in my notes: /*
For file and line numbers in libcurl:
- Add _CRTDBG_MAP_ALLOC; to preprocessor definitions.
- Add crtdbg.h; to forced includes.
*/then you could enable automatic leak check at program end if necessary, ...but that finds a lot of "leaks" that may not be curl leaks, maybe in openssl etc which you'd need the same crtdbg and map things for every library to find the leaks, if there are any. So it's of limited use here but I figure you may be interested on the background. |
|
@jay: The extra output to the debugger cannot hurt AFAICT, and As for the place of include for Nothing else stands out in that header that would cause issues, on |
This comment was marked as outdated.
This comment was marked as outdated.
🔒 Aisle Security Analysis✅ Aisle scan complete — no security issues detected. Aisle supplements but does not replace security review. Last updated on: 2026-10-14T22:46:13Z |
I thought we got free copilot credits for the organization but looking into it just now it looks like we get $15 in credits per individual and org billing says AI usage not found. I don't know if that's expected or not.. So we as individuals "pay" the AI out of our accounts, and not the organization? |
To avoid the hang reproduced in CI: https://ci.appveyor.com/project/curlorg/curl/builds/54901507/job/rqqwd6tggvq0pdl3
1bd0b43 to
8dbbb35
Compare
I find it super opaque, as of now, if my personal account does not have I had found Balanced reviews very useful in both projects. 5/12 days of Thanks for pinging Copilot for this PR! |
- in jobs building tests, also run them. - to maintain CI cycle times, only run unit tests by default, and run all (supported) tests in just one job, carefully selected to be the one running them the fastest. Per job, it takes ~15 seconds to run ~80 unit tests. It takes 5 minutes to run all (~1600) tests. Total job time 5.5-6 minutes. If the full test run turns out to be annoying or grow slow, we disable or limit it to a subset of tests. - run tests with `-j10` parallelism. It results in the fastest runs, based on tests. - to avoid the MSBuild test breaker heuristics, and to improve performance, run tests by directly invoking `runtests.pl` (not via CMake -> MSBuild -> `runtests.pl`). It saves 10-40 seconds per full test run. - when running directly via `runtests.pl`, exclude test 1119 and 1167. It's not compatible with Visual Studio generator builds. - run the artifact upload in parallel with running tests. Running Windows tests in multiple environments makes it more likely they can run on local machines, too, also making them easier to debug. AppVeyor also supports remote access via RDP, which may help debugging notorious Windows issues live, with some luck of reproducing it in a run with RDP access explicitly enabled beforehand. Fixes/improvements via this PR, merged separately: dc99e12 #23467 processhelp.pm: improve task info in trace output (Windows) 70f3f85 #23471 test1488: drop unused C preprocessor logic af9d2dd #23336 cmake: fix preconditions for option `CURL_STATIC_CRT=ON` adf8b78 #23428 setopt: fix setting `CURLWS_NOAUTOPONG` with compilers lacking C99 bool type 780405b #23416 tests: add `--dump-module-paths` debug option (Windows) bc22977 #23400 msvc: replace debug CRT GUI popups with stderr output 87a1dc7 #23396 appveyor: minor improvements 67f3510 #23381 runtests: add `-S` option to show success logs e9af987 #23378 tests/server: fix crashing with VS2013 and earlier 8cdee8a #23377 lib557: exclude three floating point test cases for VS2013 and earlier 1aac64a #23375 test1119, 1167: disable MSYS2 argument conversion narrowly 49f003f #23337 unit1664: add workaround for VS2019 16.3 - VS2022 17.4 x64 miscompile b8f71d6 #23345 test428: skip when running on older MSYS2 versions 2f3f99d #23339 test1119, 1167: disable MSYS2 argument conversion 098d3a0 #23332 runtests: unset `CURL_MEMDEBUG` for curl requests made to the CI API d3e7caf #23335 GHA/windows: drop unused `-ac` runtests options 2874cc6 #23317 mqttd: work around bogus VS2019 32-bit compiler warning e8adc72 #23315 schannel: fix guard for old MSVC workaround Follow-up to 41198e0 #20390 Closes #23306
When a curl binary is built with Visual Studio in debug mode, it uses
the matching, debug-enabled CRT. The debug CRT by default pops up an
interactive GUI dialog by default, also on CI machines, both on AppVeyor
CI and GHA, on
assert()and other low-level failures. This causes theCI job to appear hung, with nothing printed to the CI log, invisibly
waiting for someone clicking on a GUI MessageBox. On a remote/headless
CI machine this is unworkable. The job then quits on timeout, after
blocking other queued tasks (for 1 hour on AppVeyor CI, 10-15 minutes in
GHA/windows).
To make such failures CI-friendly, fix by configuring this behavior in
curl.exe,servers.exeand unit test binaries, to output all errorsto stderr, and to
OutputDebugString(), overiding the GUI popup.This can save a lot of hair-pulling.
Example output, after this patch:
Note, the default debug CRT behavior depends on a number of things, e.g.
on a Server Core (or similar) Windows edition, or when run under a
debugger. Assuming the default behavior is the expected one in most
cases, this patch only reconfigures it for builds made in the curl CI.
If you want to enable it, set the
CURL_CIenv to non-empty atconfigure time, or build with the
-DCURL_DEBUG_MSVC_CRTDBGC macro.This issue does not apply to mingw-w64 builds, as tested with both UCRT
and MSVCRT. They output the assert text to the CI logs out-of-the-box.
Refs:
https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportfile
https://learn.microsoft.com/cpp/c-runtime-library/reference/crtsetreportmode
https://learn.microsoft.com/cpp/c-runtime-library/reference/set-error-mode
Ref: #23336
Ref: edfa537 #16456
Ref: #14854
Cherry-picked from #23306
https://github.com/curl/curl/actions/runs/38648076702/job/116139873659?pr=23400
Not affected, as tested with both UCRT and MSVCRT builds, with a force assert in libtests and unit tests.
https://github.com/curl/curl/actions/runs/38627468078/job/116070229636?pr=23400
Hang reproduces in GHA jobs too:
https://github.com/curl/curl/actions/runs/38608737512/job/116006685394?pr=23400