Skip to content

__config: also ignore shift-out-of-bounds error with ubsan checks #146688

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

Closed
wants to merge 1 commit into from

Conversation

jcelerier
Copy link

Otherwise functions such as __hash_len_16 in hash.h still trigger harmless but frustrating ubsan warnings despite being marked as _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK.

Otherwise functions such as __hash_len_16 in hash.h still trigger harmless but frustrating ubsan warnings despite being marked as _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK.
@jcelerier jcelerier requested a review from a team as a code owner July 2, 2025 13:11
Copy link

github-actions bot commented Jul 2, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2025

@llvm/pr-subscribers-libcxx

Author: Jean-Michaël Celerier (jcelerier)

Changes

Otherwise functions such as __hash_len_16 in hash.h still trigger harmless but frustrating ubsan warnings despite being marked as _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK.


Full diff: https://github.com/llvm/llvm-project/pull/146688.diff

1 Files Affected:

  • (modified) libcxx/include/__config (+1-1)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index af8a297fdf3fd..b8331a2b4f63a 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1155,7 +1155,7 @@ typedef __char32_t char32_t;
 
 // Allow for build-time disabling of unsigned integer sanitization
 #  if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
-#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
+#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow", "shift-out-of-bounds")))
 #  else
 #    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #  endif

Copy link

github-actions bot commented Jul 2, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions  -- libcxx/include/__config
View the diff from clang-format here.
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b8331a2b4..e8177cde8 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1155,7 +1155,8 @@ typedef __char32_t char32_t;
 
 // Allow for build-time disabling of unsigned integer sanitization
 #  if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
-#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow", "shift-out-of-bounds")))
+#    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK                                                               \
+      __attribute__((__no_sanitize__("unsigned-integer-overflow", "shift-out-of-bounds")))
 #  else
 #    define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #  endif

@jcelerier
Copy link
Author

@cor3ntin

@jcelerier jcelerier closed this Jul 2, 2025
@jcelerier
Copy link
Author

well that was worth a try!

@cor3ntin
Copy link
Contributor

cor3ntin commented Jul 2, 2025

@jcelerier, I suspect there is a reason this was closed just after being open?

@jcelerier
Copy link
Author

yes, my patch was wrong (for some reason it did not fail on my local build but Werror here made it very apparent)

Correct patch is #146715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants