You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET crashes when compiled with clang 21.1 on Fedora 43 #119706
Our Fedora 43 CI shows some issues when trying to compile runtime repo with clang 21.1
/home/tester/workdir/runtime/src/native/libs/System.Net.Security.Native/pal_gssapi.c:247:11: error: implicit conversion when initializing 'char *' with an expression of type 'void *' is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
247 | char* ptrSlash = memchr(inputName, '/', inputNameLen);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tester/workdir/runtime/src/native/libs/System.Native/pal_networking.c:396:17: error: jump from this goto statement to its label is incompatible with C++ [-Werror,-Wjump-misses-init]
396 | goto cleanup;
| ^
/home/tester/workdir/runtime/src/native/libs/System.Native/pal_networking.c:411:10: note: jump bypasses variable initialization
411 | bool includeIPv6Loopback = true;
| ^
/home/tester/workdir/runtime/src/native/libs/System.Native/pal_networking.c:410:10: note: jump bypasses variable initialization
410 | bool includeIPv4Loopback = true;
| ^
/home/tester/workdir/runtime/src/native/libs/System.Native/pal_networking.c:1518:34: error: implicit conversion when assigning to 'uint8_t *' (aka 'unsigned char *') from type 'void *' is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
1518 | messageHeader->ControlBuffer = (void*)buffer;
| ^ ~~~~~~~~~~~~~
/root/runtime/src/coreclr/debug/di/rspriv.h:6380:36: error: in-class initializer for static data member is not a constant expression
6380 | static const CorDebugUserState kInvalidUserState = CorDebugUserState(-1);
| ^ ~~~~~~~~~~~~~~~~~~~~~
/root/runtime/src/coreclr/debug/di/rspriv.h:6380:56: note: integer value -1 is outside the valid range of values [0, 511] for the enumeration type 'CorDebugUserState'
6380 | static const CorDebugUserState kInvalidUserState = CorDebugUserState(-1);
|
Yes. It might have been reported for an older clang. I didn't run into the CorDebugUserState error until after addressing the 21.1 c++-compat warnings.
These are the changes I made to deal with the compiler errors:
I ran into this when trying to compile #117405 locally the other day btw - only just found this issue with the solution - would be nice if it was in normal dotnet/runtime so it can be compiled on macOS when the llvm homebrew package is installed :)
We hit this in nixpkgs for the darwin runtime/sdk, presumably after a clang update (NixOS/nixpkgs#449614).
Applying the CORDEBUG_INVALID change above fixes the build, but for whatever reason I didn't have to add -Wno-c++-compat.
I'm getting intermittent segfaults from the runtime, for example when running dotnet new console. I'm not sure if this is related. Has anyone been able to test a runtime built with clang-21? I'll try to verify that it's clang version related, but I don't have root access on the darwin machine I'm testing, so my debugging options are a little limited.
I'm getting intermittent segfaults from the runtime, for example when running dotnet new console. I'm not sure if this is related. Has anyone been able to test a runtime built with clang-21
Same here. Any runtime (8.0, 9.0, 10.0) built with clang-21 (or something else new enough in Fedora 34 and later) is failing with consistent segfaults when running dotnet new console.
Segfault seems to be related to the first-run setup too, because I need to rm -rf some stuff to reproduce it with a follow-on dotnet console new. Full test case for me:
I'll also let the CI do builds for vmr .NET 10 branch + #120775, and check it no longer crashes.
No more crashes with these changes. 🎉 🎉
@AaronRobinsonMSFT when the changes are completed for .NET 10, could you also backport them to .NET 8 and .NET 9? These versions are also crashing when compiled with clang 21.1 on Fedora 43.
@tmds That is great to hear! Thank you for confirming.
[...] when the changes are completed for .NET 10, could you also backport them to .NET 8 and .NET 9?
This is more complicated. I'm going to need to defer to @jkotas or @jeffschwMSFT on doing that. I can put up a PR, but I'm dubious these changes meet the bar for servicing either of those releases.
@AaronRobinsonMSFT@jkotas now that dotnet/runtime changes are in vmr our regular suite of tests is running against the Fedora 43 .NET build. One test is failing. It checks sos debugging with lldb. The test hangs when executing some sos command, and the sos command that hangs seems to differ from run to run. I guess it might be fixed by dotnet/diagnostics#5618, which isn't in the vmr yet. I'm going to check again when that is merged (dotnet/dotnet#3172).
I can't even build. Without add_compile_options(-Wno-c++-compat) I get errors still:
/opt/homebrew/opt/icu4c/include/unicode/ptypes.h:62:26: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
62 | In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_common.c:2:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:29:
In file included from /opt/homebrew/opt/icu4c/include/unicode/ucurr.h:12:
In file included from /opt/homebrew/opt/icu4c/include/unicode/utypes.h:38:
In file included from /opt/homebrew/opt/icu4c/include/unicode/umachine.h typedef uint16_t char16_t;
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_idna.c:7:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:29:
In file included from /opt/homebrew/opt/icu4c/include/unicode/ucurr.h:12:
In file included from /opt/homebrew/opt/icu4c/include/unicode/utypes.h:38:
/opt/homebrew/opt/icu4c/include/unicode/umachine.h:378:13: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
378 | typedef char16_t UChar;
| ^
:46:
/opt/homebrew/opt/icu4c/include/unicode/ptypes.h:62:26: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
62 | typedef uint16_t char16_t;
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_common.c:2:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:29:
In file included from /opt/homebrew/opt/icu4c/include/unicode/ucurr.h:12:
In file included from /opt/homebrew/opt/icu4c/include/unicode/utypes.h:38:
/opt/homebrew/opt/icu4c/include/unicode/umachine.h:378:13: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
378 | typedef char16_t UChar;
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_calendarData.c:8:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_locale_internal.h:6:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:29:
In file included from /opt/homebrew/opt/icu4c/include/unicode/ucurr.h:12:
In file included from /opt/homebrew/opt/icu4c/include/unicode/utypes.h:38:
In file included from /opt/homebrew/opt/icu4c/include/unicode/umachine.h:46:
/opt/homebrew/opt/icu4c/include/unicode/ptypes.h:62:26: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
62 | typedef uint16_t char16_t;
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_calendarData.c:8:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_locale_internal.h:6:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:29:
In file included from /opt/homebrew/opt/icu4c/include/unicode/ucurr.h:12:
In file included from /opt/homebrew/opt/icu4c/include/unicode/utypes.h:38:
/opt/homebrew/opt/icu4c/include/unicode/umachine.h:378:13: error: identifier 'char16_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
378 | typedef char16_t UChar;
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_idna.c:7:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:47:
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1199:8: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1199 | U_CAPI wchar_t* U_EXPORT2
| ^
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1200:12: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1200 | u_strToWCS(wchar_t *dest,
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_common.c:2:
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1232:20: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1232 | const wchar_t *src,
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:47:
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1199:8: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1199 | U_CAPI wchar_t* U_EXPORT2
| ^
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1200:12: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1200 | u_strToWCS(wchar_t *dest,
| ^
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1232:20: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1232 | const wchar_t *src,
| ^
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_calendarData.c:8:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_locale_internal.h:6:
In file included from /Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Globalization.Native/pal_icushim_internal.h:47:
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1199:8: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1199 | U_CAPI wchar_t* U_EXPORT2
| ^
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1200:12: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1200 | u_strToWCS(wchar_t *dest,
| ^
/opt/homebrew/opt/icu4c/include/unicode/ustring.h:1232:20: error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword]
1232 | const wchar_t *src,
| ^
5 errors generated.
5 errors generated.
make[2]: *** [libs-native/System.Globalization.Native/CMakeFiles/System.Globalization.Native-Static.dir/pal_common.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [libs-native/System.Globalization.Native/CMakeFiles/System.Globalization.Native-Static.dir/pal_idna.c.o] Error 1
5 errors generated.
make[2]: *** [libs-native/System.Globalization.Native/CMakeFiles/System.Globalization.Native-Static.dir/pal_calendarData.c.o] Error 1
make[1]: *** [libs-native/System.Globalization.Native/CMakeFiles/System.Globalization.Native-Static.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 4%] Building C object libs-native/System.Native/CMakeFiles/System.Native-Static.dir/pal_maphardwaretype.c.o
/Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Native/pal_interfaceaddresses.c:564:14: error: implicit conversion when initializing 'uint8_t *' (aka 'unsigned char *') with an expression of type 'void *' is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
564 | uint8_t* buffer = malloc(byteCount);
| ^ ~~~~~~~~~~~~~~~~~
/Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Native/pal_interfaceaddresses.c:590:16: error: implicit conversion when assigning to 'uint8_t *' (aka 'unsigned char *') from type 'void *' is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
590 | buffer = malloc(byteCount);
| ^ ~~~~~~~~~~~~~~~~~
[ 4%] Generating dummy/eventprovdotnetruntime.cpp, dummy/eventprovdotnetruntimerundown.cpp, dummy/eventprovdotnetruntimestress.cpp, dummy/eventprovdotnetruntimeprivate.cpp, dummy/eventprovdotnetruntimemonoprofiler.cpp
2 errors generated.
[ 5%] Building C object shared_minipal/CMakeFiles/minipal_objects.dir/descriptorlimit.c.o
make[2]: *** [libs-native/System.Native/CMakeFiles/System.Native-Static.dir/pal_interfaceaddresses.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 5%] Building C object libs-native/System.Security.Cryptography.Native.Apple/CMakeFiles/System.Security.Cryptography.Native.Apple-Static.dir/pal_ssl.c.o
[ 5%] Building CXX object pal/src/CMakeFiles/coreclrpal_objects.dir/cruntime/wchar.cpp.o
[ 5%] Building C object /Users/Hamish/Projects/Clones/runtime26/artifacts/obj/external/libunwind/CMakeFiles/libunwind_dac.dir/Users/Hamish/Projects/Clones/runtime26/src/native/external/libunwind/src/mi/init.c.o
[ 5%] Building C object shared_minipal/CMakeFiles/minipal_objects.dir/memorybarrierprocesswide.c.o
[ 5%] Building C object shared_minipal/CMakeFiles/minipal_objects.dir/mutex.c.o
[ 5%] Building CXX object pal/src/CMakeFiles/coreclrpal_objects.dir/debug/debug.cpp.o
/Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ecc.c:62:17: error: implicit conversion when initializing 'CFNumberRef' (aka 'const struct __CFNumber *') with an expression of type 'const void *' is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
62 | CFNumberRef cfSize = CFDictionaryGetValue(attributes, kSecAttrKeySizeInBits);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [libs-native/System.Security.Cryptography.Native.Apple/CMakeFiles/System.Security.Cryptography.Native.Apple-Static.dir/pal_ecc.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 5%] Building C object /Users/Hamish/Projects/Clones/runtime26/artifacts/obj/external/libunwind/CMakeFiles/libunwind_dac.dir/Users/Hamish/Projects/Clones/runtime26/src/native/external/libunwind/src/mi/flush_cache.c.o
[ 5%] Building C object /Users/Hamish/Projects/Clones/runtime26/artifacts/obj/external/libunwind/CMakeFiles/libunwind_dac.dir/Users/Hamish/Projects/Clones/runtime26/src/native/external/libunwind/src/mi/mempool.c.o
[ 5%] Building C object shared_minipal/CMakeFiles/minipal_objects.dir/guid.c.o
make[1]: *** [libs-native/System.Native/CMakeFiles/System.Native-Static.dir/all] Error 2
[ 5%] Building CXX object pal/src/CMakeFiles/coreclrpal_objects.dir/exception/seh.cpp.o
[ 5%] Building C object /Users/Hamish/Projects/Clones/runtime26/artifacts/obj/external/libunwind/CMakeFiles/libunwind_dac.dir/Users/Hamish/Projects/Clones/runtime26/src/native/external/libunwind/src/mi/strerror.c.o
/Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c:238:55: error: implicit conversion when passing 'void *' to parameter of type 'const UInt8 *' (aka 'const unsigned char *') is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
238 | CFStringRef value = CFStringCreateWithBytes(NULL, protocol, length, kCFStringEncodingASCII, 0);
| ^~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:186:72: note: passing argument to parameter 'bytes' here
186 | CFStringRef CFStringCreateWithBytes(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation);
| ^
/Users/Hamish/Projects/Clones/runtime26/src/native/libs/System.Security.Cryptography.Native.Apple/pal_ssl.c:297:56: error: implicit conversion when passing 'const void *' to parameter of type 'CFStringRef' (aka 'const struct __CFString *') is not permitted in C++ [-Werror,-Wimplicit-void-ptr-cast]
297 | CFStringCreateExternalRepresentation(NULL, CFArrayGetValueAtIndex(protocols, 0), kCFStringEncodingASCII, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:339:82: note: passing argument to parameter 'theString' here
339 | CFDataRef CFStringCreateExternalRepresentation(CFAllocatorRef alloc, CFStringRef theString, CFStringEncoding encoding, UInt8 lossByte); /* May return NULL on conversion error */
| ^
2 errors generated.
Activity
dotnet-policy-service commentedon Sep 15, 2025
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.
tmds commentedon Sep 15, 2025
From https://releases.llvm.org/21.1.0/tools/clang/docs/ReleaseNotes.html, the C compiler is now emitting some warnings for C++ incompatibilities (
-Wc++-compat), like-Wimplicit-void-ptr-castand-Wjump-misses-init.When I ignore those with
-Wno-c++-compat, then it issues one more error for:runtime/src/coreclr/debug/di/rspriv.h
Line 6380 in c1b153a
omajid commentedon Sep 15, 2025
Duplicate of #116997 ?
tmds commentedon Sep 15, 2025
Yes. It might have been reported for an older clang. I didn't run into the
CorDebugUserStateerror until after addressing the 21.1 c++-compat warnings.These are the changes I made to deal with the compiler errors:
hamarb123 commentedon Oct 7, 2025
I ran into this when trying to compile #117405 locally the other day btw - only just found this issue with the solution - would be nice if it was in normal dotnet/runtime so it can be compiled on macOS when the llvm homebrew package is installed :)
tmds commentedon Oct 7, 2025
I put it here as a patch tot help people unblock themselves. I think the actual fix might be a bit more refined.
jkotas commentedon Oct 7, 2025
Yeah, I think we want to add the casts to make compilers happy instead of warning disable.
Are you interested in submitting PR with the fix?
corngood commentedon Oct 7, 2025
We hit this in nixpkgs for the darwin runtime/sdk, presumably after a clang update (NixOS/nixpkgs#449614).
Applying the
CORDEBUG_INVALIDchange above fixes the build, but for whatever reason I didn't have to add-Wno-c++-compat.I'm getting intermittent segfaults from the runtime, for example when running
dotnet new console. I'm not sure if this is related. Has anyone been able to test a runtime built with clang-21? I'll try to verify that it's clang version related, but I don't have root access on the darwin machine I'm testing, so my debugging options are a little limited.omajid commentedon Oct 10, 2025
Same here. Any runtime (8.0, 9.0, 10.0) built with clang-21 (or something else new enough in Fedora 34 and later) is failing with consistent segfaults when running
dotnet new console.Segfault seems to be related to the first-run setup too, because I need to
rm -rfsome stuff to reproduce it with a follow-ondotnet console new. Full test case for me:Fix build breaks with clang 21
43 remaining items
tmds commentedon Oct 28, 2025
No more crashes with these changes. 🎉 🎉
@AaronRobinsonMSFT when the changes are completed for .NET 10, could you also backport them to .NET 8 and .NET 9? These versions are also crashing when compiled with clang 21.1 on Fedora 43.
AaronRobinsonMSFT commentedon Oct 28, 2025
@tmds That is great to hear! Thank you for confirming.
This is more complicated. I'm going to need to defer to @jkotas or @jeffschwMSFT on doing that. I can put up a PR, but I'm dubious these changes meet the bar for servicing either of those releases.
tmds commentedon Nov 3, 2025
@AaronRobinsonMSFT @jkotas now that dotnet/runtime changes are in vmr our regular suite of tests is running against the Fedora 43 .NET build. One test is failing. It checks sos debugging with lldb. The test hangs when executing some sos command, and the sos command that hangs seems to differ from run to run. I guess it might be fixed by dotnet/diagnostics#5618, which isn't in the vmr yet. I'm going to check again when that is merged (dotnet/dotnet#3172).
jkotas commentedon Nov 3, 2025
vmr is not building sos.
tmds commentedon Nov 3, 2025
I guess there may be something in dotnet/diagnostics which sos relies on?
It could also be a regression in how llvm 21 lldb and sos interact.
If dotnet/dotnet#3172 doesn't change the behavior, I'll create an issue for it.
[release/10.0] Apply changes for building with clang-21 (#121124)
[release/9.0-staging] Add flags when the clang's major version is > 2…
[release/8.0-staging] Add flags when the clang's major version is > 2…
AaronRobinsonMSFT commentedon Jan 14, 2026
This should be handled now. @tmds I'm closing this again. Please let me know if there are still issues here.
AaronRobinsonMSFT commentedon Mar 27, 2026
@hamarb123 Looks like we've just hit all this with the latest update to XCode.
I'll put up a PR shortly.
/cc @jkotas