Repository navigation
Conversation
Seen in VS2019 Release x64 build in AppVeyor CI. - CM VS2019, Debug , x64, OpenSSL 3.0 + Schannel, Shared, !verbose, Build-tests: PASS - CM VS2019, Release, x64, OpenSSL 3.0 + Schannel, Shared, !verbose, Build-tests: FAIL test1664 - CM VS2019, Release, x86, OpenSSL 3.0 + Schannel, Shared, !verbose, Build-tests: PASS Visual Studio Community 2019 v16.11.50 ``` -- Building for: Visual Studio 16 2019 -- Using CMake version 4.1.0 -- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.17763. -- The C compiler identification is MSVC 19.29.30159.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped -- CMake platform flags: WIN32 MSVC-1929 [...] -- Found _WIN32_WINNT=0x0a00 -- Picky compiler options: -W4 -Wall -wd4061 -wd4191 -wd4255 -wd4464 -wd4548 -wd4574 -wd4668 -wd4710 -wd4711 -wd4746 -wd4820 -wd5045 [...] test 1664 [unit tests for strparse.c string parsing functions] 1664: stdout FAILED: --- log/check-expected 2026-10-09 08:50:52.895380000 +0000 +++ log/check-generated 2026-10-09 08:50:52.895380000 +0000 @@ -154,9 +154,9 @@ 3: (%62) 6, line 0[LF] 4: (%5c) 6, line 0[LF] 5: (%20) 6, line 0[LF] -6: (%0a) 0, line 1[LF] -7: (%0d) 0, line 1[LF] -8: (%0d) 0, line 1[LF] +6: (%00) 0, line 1[LF] +7: (%00) 0, line 1[LF] +8: (%0a) 0, line 1[LF] 9: (%0c) 6, line 0[LF] 10: (%00) 6, line 0[LF] curlx_str_hex[LF] ``` Ref: https://ci.appveyor.com/project/curlorg/curl/builds/54864988/job/m823tifoodo7tt1a Does not reproduce in this isolated example: https://godbolt.org/z/n5jYPKWsM Bug: curl#23306 (comment) Bug: curl#23306 (comment) Bug: curl#23306 (comment) Cherry-picked from curl#23306
This reverts commit 67e1207.
|
I thought from the other bug that you traced this to dual CRTs mixing their output? Also would it be better to exclude this test rather than add the workaround? If we don't know the cause of this then we can't say for certain it's the compiler. It looks likely but it can't be reproduced in a self contained example without curl. Maybe there is some undefined behavior causing it. |
This is not related to the CRT issue. Would it be a better workaround to disable this test? I'm not so sure, this workaround seems to explain this better, and where the issue happens, than a comment somewhere else. To exclude it dynamically, we'd pbly need clumsy and verbose detection code somewhere in runtests. I did not make a great effort with the minimal example so perhaps I just remove it and leave it to someone expert in this (or somebody with this compiler version installed locally). To me this seems not specifically curl related but rather related to the larger generated code context. (The actual tested function and the test itself are generic and simple.) One more thing to be done if someone feels like digging: downloading the object/binary as an artifact and peeking into the disassembly. |
This comment was marked as outdated.
This comment was marked as outdated.
|
Diff of a reduced-units.c assembly output, master (failing) vs this patch (passing): --- units.cod
+++ units-workaround.cod
--- units.cod
+++ units-patched.cod
@@ -130,13 +130,13 @@
; COMDAT pdata
pdata SEGMENT
$pdata$1$test_unit1664 DD imagerel test_unit1664+20
- DD imagerel test_unit1664+124
+ DD imagerel test_unit1664+121
DD imagerel $chain$1$test_unit1664
pdata ENDS
; COMDAT pdata
pdata SEGMENT
-$pdata$2$test_unit1664 DD imagerel test_unit1664+124
- DD imagerel test_unit1664+132
+$pdata$2$test_unit1664 DD imagerel test_unit1664+121
+ DD imagerel test_unit1664+129
DD imagerel $chain$2$test_unit1664
pdata ENDS
; COMDAT pdata
@@ -495,7 +495,7 @@
00 00 mov r8, QWORD PTR ?newl@?1??test_unit1664@@9@9
0000d 33 db xor ebx, ebx
0000f 4d 85 c0 test r8, r8
- 00012 74 68 je SHORT $LN10@test_unit1
+ 00012 74 65 je SHORT $LN10@test_unit1
00014 48 89 74 24 40 mov QWORD PTR [rsp+64], rsi
00019 48 8d 35 00 00
00 00 lea rsi, OFFSET FLAT:?newl@?1??test_unit1664@@9@9
@@ -515,21 +515,20 @@
; 62 : printf("%d: (%%%02x) %d, line %d\n",
- 0003f 48 8b 4c 24 48 mov rcx, QWORD PTR line$1[rsp]
- 00044 44 8b c8 mov r9d, eax
- 00047 8b d1 mov edx, ecx
- 00049 41 2b d0 sub edx, r8d
- 0004c 89 54 24 20 mov DWORD PTR [rsp+32], edx
- 00050 8b d3 mov edx, ebx
- 00052 44 0f be 01 movsx r8d, BYTE PTR [rcx]
- 00056 48 8d 0d 00 00
+ 0003f 8b 4c 24 48 mov ecx, DWORD PTR line$1[rsp]
+ 00043 44 8b c8 mov r9d, eax
+ 00046 41 2b c8 sub ecx, r8d
+ 00049 8b d3 mov edx, ebx
+ 0004b 45 0f be 00 movsx r8d, BYTE PTR [r8]
+ 0004f 89 4c 24 20 mov DWORD PTR [rsp+32], ecx
+ 00053 48 8d 0d 00 00
00 00 lea rcx, OFFSET FLAT:??_C@_0BK@DKNMMGEI@?$CFd?3?5?$CI?$CF?$CF?$CF02x?$CJ?5?$CFd?0?5line?5?$CFd?6@
- 0005d e8 00 00 00 00 call printf
- 00062 4c 8b 44 fe 08 mov r8, QWORD PTR [rsi+rdi*8+8]
- 00067 48 8d 7f 01 lea rdi, QWORD PTR [rdi+1]
- 0006b ff c3 inc ebx
- 0006d 4d 85 c0 test r8, r8
- 00070 75 be jne SHORT $LL4@test_unit1
+ 0005a e8 00 00 00 00 call printf
+ 0005f 4c 8b 44 fe 08 mov r8, QWORD PTR [rsi+rdi*8+8]
+ 00064 48 8d 7f 01 lea rdi, QWORD PTR [rdi+1]
+ 00068 ff c3 inc ebx
+ 0006a 4d 85 c0 test r8, r8
+ 0006d 75 c1 jne SHORT $LL4@test_unit1
; 63 : /* Workaround for the expression erroneously returning the byte from the next
; 64 : address for inputs \n, \r and \r\n. Thus returning NUL, NUL, \n instead of
@@ -544,16 +543,16 @@
; 73 :
; 74 : return (CURLcode)0;
- 00072 48 8b 7c 24 50 mov rdi, QWORD PTR [rsp+80]
- 00077 48 8b 74 24 40 mov rsi, QWORD PTR [rsp+64]
+ 0006f 48 8b 7c 24 50 mov rdi, QWORD PTR [rsp+80]
+ 00074 48 8b 74 24 40 mov rsi, QWORD PTR [rsp+64]
$LN10@test_unit1:
; 75 : }
- 0007c 33 c0 xor eax, eax
- 0007e 48 83 c4 30 add rsp, 48 ; 00000030H
- 00082 5b pop rbx
- 00083 c3 ret 0
+ 00079 33 c0 xor eax, eax
+ 0007b 48 83 c4 30 add rsp, 48 ; 00000030H
+ 0007f 5b pop rbx
+ 00080 c3 ret 0
test_unit1664 ENDP
_TEXT ENDS
; Function compile flags: /Ogtpyvia: |
|
Godbolt reproducer: It required /O1 (or /O2) combined with /Ob0 on godbolt. (In curl it seems to happen with /O2 /Ob2. This still needs to be cleared up.) |
Thanks for figuring this out. I played around with it in a VM image that has a not-up-to-date VS 2022 17.1 and I saw the same thing. In the debug profile I disabled runtime checks and enabled maximum optimization /O1 and that was enough to do it. The inline function expansion optimization setting (/Ob0, /Ob1 etc) had no effect. I found that if the for loop is removed or condition omitted (like i = 6 for ;; followed by break before the end of the block) then the bug does not occur. However if the for loop has even one condition/iteration like |
The exact option combo is kind of murky, yes. In CI, Release builds CMake (as of 4.4.3) config options for MSVC, FTR: |
- 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
It affects
_MSC_VER >= 1923 && _MSC_VER <= 1934, combined with-O1or
-O2, and inlining reduced via-Ob0or-Ob1(CMakeRelWithDebInfo config). Also with
-O2 -Ob2(CMake Release config), incurl
units.execontext.Introduced in: Visual Studio 2019 v16.3 (~2019-09-23)
Fixed in: Visual Studio 2022 v17.5 (~2023-02-21)
Godbolt reproducer: https://godbolt.org/z/T78GWxzeT
As seen in AppVeyor CI:
Fixing:
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/54864988/job/m823tifoodo7tt1a
Bug: #23306 (comment)
Bug: #23306 (comment)
Bug: #23306 (comment)
Ref: #23347 (seeking a minimal reproducer)
Cherry-picked from #23306
Reproduced in this PR:
https://ci.appveyor.com/project/curlorg/curl/builds/54868446/job/q8575pmwne0av023 (!verbose-strings)
https://ci.appveyor.com/project/curlorg/curl/builds/54868446/job/os8tdx8dgqrhbb3b (verbose-strings; default)
Code snipped causing the issue extracted here (not reproducing the
issue in this isolated case):
https://godbolt.org/z/n5jYPKWsM