Repository navigation
Conversation
…are cases [WIP] While trying to enable tests for MSVC build, Websocket tests 2700, 2709, 2711, 2712 failed unexpecedly for VS2010 and VS2012. The root cause turned out to be one specific bit flag to bit field conversion, which failed on certain conditions: The original Websocket code assigned `arg & CURLWS_RAW_MODE` to a bit field, after casting to bool. This worked because `CURLWS_RAW_MODE` equals 1. Later this line was cloned when adding support for `CURLWS_NOAUTOPONG`, but the new bit flag's value was 2, and casting it to any other type than a native bool, or not casting at all, then assigning it to a bit field, ends up storing a _0_, when the flag is set. This isn't compiler specific. The actual interim type we cast to also does not matter, only the native bool type seems to work. The reason it came up with <=VS2012 is because these are the only compilers in curl CI that do not provide a native bool type, and happened to also run tests. It also needed the earlier update that enabled bit fields for MSVC. The combination of this code line + no native bool type + storing a non-0/1 value in a bit field was necessary to produce this issue, and running websocket tests for this build in CI was needed to detect it. Fix by replacing the `(bool)` cast with `!!`. Also for `CURLWS_RAW_MODE` to not rely on the value of `CURLWS_RAW_MODE`. There are no other places in the codebase with this pattern. The rest use either `!!` or ternary expression for this type of conversion. Demo on godbolt: https://godbolt.org/z/3h5zMfePq Follow-up to 85c841c curl#20142 Follow-up to c0df01f curl#16744 Cherry-picked from curl#23306
vszakats
marked this pull request as draft
October 15, 2026 23:29
vszakats
marked this pull request as ready for review
October 15, 2026 23:56
CURLWS_NOAUTOPONG for compilers without native bool typeCURLWS_NOAUTOPONG with compilers lacking native bool type
CURLWS_NOAUTOPONG with compilers lacking native bool typeCURLWS_NOAUTOPONG with compilers lacking C99 bool type
9 of 10 tasks
vszakats
added a commit
that referenced
this pull request
Oct 18, 2026
- 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
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.
Setting the
CURLWS_NOAUTOPONGflag via theCURLOPT_WS_OPTIONScurl_easy_setopt()API failed to enable this flag in libcurl buildsusing a compiler without a native C99 bool type. This in turn caused
2700, 2709, 2711, 2712 WebSocket tests to fail.
The initial WebSocket code assigned
arg & CURLWS_RAW_MODEto abit-field, after casting the expression to
bool. This worked becauseCURLWS_RAW_MODEequals 1. Later this line was cloned when addingsupport for
CURLWS_NOAUTOPONG, but this new bit flag's value was 2.Casting it to
booland then assigning it to a bit-field worked asexpected, as long as the bool type was the C99 one. On compilers without
the C99 bool type, the interim cast did not work, and when assigning the
value 2 to the bit-field, it ended up storing zero/false
unconditionally.
Such compilers are VS2012 and VS2010. For them, another trigger was a
subsequent update that enabled bit-field support for MSVC compilers.
Fix by replacing the
(bool)cast with!!. Also forCURLWS_RAW_MODE, to not rely on the literal value of this macro, andto avoid reusing this pattern in future code.
There were no other places in the codebase with this pattern. The rest
use either
!!or ternary expression for this type of conversion.Discovered while trying to enable tests for MSVC builds in AppVeyor CI,
causing test failures with VS2012 and VS2010.
Refs:
https://en.cppreference.com/c/language/arithmetic_types#Boolean_type
https://en.cppreference.com/c/language/conversion
https://godbolt.org/z/3h5zMfePq
Bug: #23306 (comment)
Bug: #23306 (comment)
Follow-up to 85c841c #20142
Follow-up to c0df01f #16744
Follow-up to 664249d #8995
Cherry-picked from #23306