Repository navigation
compat.c-ares: CARES_STATICLIB reaches the consumer (gRPC's Windows startup crash) - #856
Merged
Merged
Conversation
…port slot lld-link discards under /OPT:REF)
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.
compat.c-ares:
CARES_STATICLIBreaches the consumer. Root cause of grpc-m's Windows startup crash ("exit 133").Only the package's own translation units were compiled with
CARES_STATICLIB; a consumer's<ares.h>declared every entry point__declspec(dllimport), so gRPC called the static library through an__imp_slot lld-link fills locally (LNK4217). Under/OPT:REF— lld-link's default without/DEBUG— that slot does not keep its definition alive: when the object was pulled in only by code that is later discarded, the definition is dropped and the slot holds the image base.grpc_init→AresInit→ares_library_initjumped to the PE header (0xC0000005, execute atMZ).Evidence (mcpplibs/grpc-m#10, diagnostic draft):
/opt:norefor-gpass,/opt:reffails,/opt:noicfstill fails;AresInit+0x46(ares_resolver.cc:960), target = image base;__imp_foo=0x140000000under/opt:ref).Fix: upstream propagates the define (Bazel
defines, CMake's INTERFACE definition); here a feature'sdefinesreach consumers anddefaultimplies it unconditionally — compat.curl'sCURL_STATICLIBpattern. Verified: gRPC's module test passes on windows-2025 with default link flags, on a home that already had the old compat.c-ares installed (so no packaging revision is needed); a Linux consumer sees the define.Not in this PR: gRPC code generation on Windows (compat.protobuf's protoc host tool) is a separate open issue; grpc-m will claim Windows only with it or with codegen explicitly excluded.