Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when enable -Wthread-safety-analysis #1056

Open
sayboras opened this issue Dec 11, 2024 · 0 comments
Open

Error when enable -Wthread-safety-analysis #1056

sayboras opened this issue Dec 11, 2024 · 0 comments

Comments

@sayboras
Copy link
Member

sayboras commented Dec 11, 2024

When -Wthread-safety-analysis flag is enabled, the below error occurs.

Thanks to @tcnghia for reporting the issue.

Patch

diff --git a/bazel/toolchains/BUILD b/bazel/toolchains/BUILD
index a7bc5ac7..e371b51f 100644
--- a/bazel/toolchains/BUILD
+++ b/bazel/toolchains/BUILD
@@ -39,6 +39,7 @@ cc_toolchain_config(
         "-Wunused-but-set-parameter",
         "-Wno-free-nonheap-object",
         "-fno-omit-frame-pointer",
+        "-Wthread-safety-analysis",
         # Needed by Envoy dependencies to build:
         "-Wno-unused-command-line-argument",  # tcmalloc needs this since -fuse-ld was added above
         "-Wno-deprecated-builtins",
@@ -137,6 +138,7 @@ cc_toolchain_config(
         "-Wunused-but-set-parameter",
         "-Wno-free-nonheap-object",
         "-fno-omit-frame-pointer",
+        "-Wthread-safety-analysis",
         # Needed by Envoy dependencies to build:
         "-Wno-unused-command-line-argument",  # tcmalloc needs this since -fuse-ld was added above
         "-Wno-deprecated-builtins",

Error

...
ERROR: /home/tammach/go/src/github.com/cilium/proxy/cilium/BUILD:172:17: Compiling cilium/uds_client.cc failed: (Exit 1): clang-17 failed: error executing command (from target //cilium:uds_client_lib) /usr/bin/clang-17 '--target=x86_64-unknown-linux-gnu' '-fuse-ld=lld' -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer ... (remaining 196 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
cilium/uds_client.cc:62:7: error: reading variable 'logging_limiter_' requires holding mutex 'fd_mutex_' [-Werror,-Wthread-safety-analysis]
   62 |   if (logging_limiter_->consume(1, false)) {
      |       ^
cilium/uds_client.cc:63:85: error: reading variable 'errno_' requires holding mutex 'fd_mutex_' [-Werror,-Wthread-safety-analysis]
   63 |     ENVOY_LOG(warn, "Logging to {} failed: {}", asStringView(), Envoy::errorDetails(errno_));
      |                                                                                     ^
cilium/uds_client.cc:63:85: error: reading variable 'errno_' requires holding mutex 'fd_mutex_' [-Werror,-Wthread-safety-analysis]
3 errors generated.
Target //:cilium-envoy failed to build
tcnghia added a commit to wolfi-dev/os that referenced this issue Dec 11, 2024
Upgrade Cilium to 1.16.4. As part of this change we also:
* use `--config=libc++` to match what our other Envoys (`envoy`,
`istio-proxy`...) do for easier maintenance.
* unregister upstream's toolchain that is Ubuntu specific (this helped
address the build issues in #34699 )

The thread-safety analysis flagged some issue in upstream code (see
cilium/proxy#1056). We will need to turn this
on again after the issue is fixed.

Signed-off-by: Nghia Tran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant