libco: select the fiber backend on Windows - #12
Open
hjiawei wants to merge 1 commit into
Open
Conversation
On x86_64 the GNU/Clang branch tests __amd64__ before _WIN32 and pulls in amd64.c. Its co_swap executes a machine-code blob stored in a read-only array, which faults under Data Execution Prevention on the first coroutine switch on Windows -- the same failure the MSVC branch already avoids by disabling amd64.c "due to SIGSEGV bug". Check _WIN32 first so Windows targets use the fiber backend (CreateFiber/SwitchToFiber) that MSVC uses, regardless of the compiler (MSVC or MinGW-w64/GCC). Signed-off-by: Jiawei Huang <jiawei@tigera.io>
This was referenced Jul 7, 2026
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.
On x86_64 the GNU/Clang branch of
libco.ctests__amd64__before_WIN32, so it includesamd64.c. That backend'sco_swapexecutes a machine-code blob held in a read-only array, which faults under Data Execution Prevention on the first coroutine switch on Windows — exactly the failure the MSVC branch already sidesteps by disablingamd64.c"due to SIGSEGV bug" and falling back to fibers.This moves the
_WIN32check ahead of the architecture checks so any Windows target (MSVC or MinGW-w64/GCC) uses thefiber.cbackend (CreateFiber/SwitchToFiber). Non-Windows targets are unaffected; the later_WIN32#elif(previously unreachable on x86_64) is removed.Surfaced while cross-compiling a downstream consumer (fluent-bit) for Windows with the MinGW-w64 toolchain, where GCC defines
__amd64__and the old order silently selected the faulting backend.