dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.42k stars 4.76k forks source link

Fix `-Wunsafe-buffer-usage` warnings #81577

Open am11 opened 1 year ago

am11 commented 1 year ago

Clang 16 has introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734 which https://github.com/dotnet/runtime/pull/81573 is suppressing. Filing this issue so we remember to fix the violations and remove suppression.

dotnet-issue-labeler[bot] commented 1 year ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 1 year ago

Tagging subscribers to this area: @hoyosjs See info in area-owners.md if you want to be subscribed.

Issue Details
Clang 16 has introduced buffer hardening https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734 which https://github.com/dotnet/runtime/pull/81573 is suppressing. Filing this issue so we remember to fix the violations and remove suppression.
Author: am11
Assignees: -
Labels: `area-Infrastructure-coreclr`, `untriaged`
Milestone: -
ayakael commented 1 year ago

On Alpine edge (clang 16), I also get:

/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/openssl.c(1444,12): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5587/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/openssl.c(1444,12): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5588/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/openssl.c(1510,37): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5589/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/openssl.c(1510,37): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5590/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Native/pal_console.c(122,38): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'ConsoleSigTtouHandler' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5591/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Native/pal_console.c(122,38): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'ConsoleSigTtouHandler' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5592/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Native/pal_console.c(122,38): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'ConsoleSigTtouHandler' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5593/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Native/pal_console.c(122,38): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'ConsoleSigTtouHandler' (aka 'void (*)(void)') [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5594/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c(136,34): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]
5595/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/System.Security.Cryptography.Native/opensslshim.c(136,34): error G6B6F0AA2: incompatible function pointer types passing 'void ()' to parameter of type 'void (*)(void)' [-Wincompatible-function-pointer-types-strict] [/var/lib/gitlab-runner/builds/ayakael/user-aports/user/dotnet7-stage0/src/dotnet-v7.0.104/src/runtime/src/native/libs/build-native.proj]

Applied the following workaround:

diff --git a/src/runtime/eng/native/configurecompiler.cmake b/src/runtime/eng/native/configurecompiler.cmake
index c9a54547c0a..931da2cae5b 100644
--- a/src/runtime/eng/native/configurecompiler.cmake
+++ b/src/runtime/eng/native/configurecompiler.cmake
@@ -488,6 +488,7 @@ if (CLR_CMAKE_HOST_UNIX)
     # other clang 16.0 suppressions
     add_compile_options(-Wno-single-bit-bitfield-constant-conversion)
     add_compile_options(-Wno-cast-function-type-strict)
+    add_compile_options(-Wno-incompatible-function-pointer-types-strict)
   else()
     add_compile_options(-Wno-uninitialized)
     add_compile_options(-Wno-strict-aliasing)