-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Fix typeinfo for undefined sanitizer #121228
base: main
Are you sure you want to change the base?
Conversation
This happened to me when I compiled my code on x86_64 linux (ubuntu 24.04) with clang-18 and everything except glibc built from source (llvm 19, llvm source) I found this solution and luckily it works! emscripten-core/emscripten#13367 emscripten-core/emscripten#13330 I saw that issue is abandoned, so I decided to try to push it in upstream
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 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. |
@llvm/pr-subscribers-libcxx Author: Valery Mironov (MBkkt) ChangesThis happened to me when I compiled my code on x86_64 linux (ubuntu 24.04) with clang-18 and everything except glibc built from source (llvm 19, llvm source) I found this solution and luckily it works! I saw that issue is abandoned, so I decided to try to push it in upstream Full diff: https://github.com/llvm/llvm-project/pull/121228.diff 1 Files Affected:
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 799c6ebd5ecbbf..a900ccaf7e24bb 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -315,7 +315,8 @@ public:
_LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
+ // We need to inline this code because otherwise we will get a stack overflow with undefined sanitizer.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
// When evaluated in a constant expression, both type infos simply can't come
// from different translation units, so it is sufficient to compare their addresses.
if (__libcpp_is_constant_evaluated()) {
|
You can test this locally with the following command:git-clang-format --diff 815343e7dd32cc4c5c903ac52daf87aaa4e4cd6e 3d8fb18949dba038667e6d8983948b85a73cefdb --extensions -- libcxx/include/typeinfo View the diff from clang-format here.diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index a900ccaf7e..6bca852e21 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -316,7 +316,8 @@ public:
_LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __impl::__hash(__type_name); }
// We need to inline this code because otherwise we will get a stack overflow with undefined sanitizer.
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR_SINCE_CXX23 bool operator==(const type_info& __arg) const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR_SINCE_CXX23 bool
+ operator==(const type_info& __arg) const _NOEXCEPT {
// When evaluated in a constant expression, both type infos simply can't come
// from different translation units, so it is sufficient to compare their addresses.
if (__libcpp_is_constant_evaluated()) {
|
This happened to me when I compiled my code on x86_64 linux (ubuntu 24.04) with clang-18 and everything except clang, compiler_rt, glibc built from source (llvm 19, llvm source) in debug (
-O1
)I found this solution and luckily it works!
emscripten-core/emscripten#13367 emscripten-core/emscripten#13330
I saw that issue is abandoned, so I decided to try to push it in upstream