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
It seems like the address sanitizer currently finds a false-positive in gtest regarding validation of vtable pointers. The code is correct but the compiler can't know this when RTTI is disabled. Other parts of the code already seem to work around lack of RTTI through GTEST_HAS_RTTI.
A simple fix or work around would be as described below and disable the sanitizer in the impacted areas of the code.
This is filed as an issue rather than a direct PR since:
There may be arguments to instead fix this on the Clang side
Since this is a somewhat minor issue then I didn't feel like going through the trouble of figuring out the CLA process described in CONTRIBUTING.md
in gtest.h
// Deletes self. We deliberately pick an unusual name for this
// internal method to avoid clashing with names used in user TESTs.
- void DeleteSelf_() { delete this; }
+ GTEST_ATTRIBUTE_NO_SANITIZE_VPTR void DeleteSelf_() { delete this; }
in gtest-port.h
+#if GTEST_HAS_RTTI && (defined(__clang__) || defined (__GNUC__))
+#define GTEST_ATTRIBUTE_NO_SANITIZE_VPTR __attribute__((no_sanitize("vptr")))
+#else
+#define GTEST_ATTRIBUTE_NO_SANITIZE_VPTR
+#endif
in gtest.cc
// exceptions in the same function. Therefore, we provide a separate
// wrapper function for handling SEH exceptions.)
template <class T, typename Result>
-Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
+GTEST_ATTRIBUTE_NO_SANITIZE_VPTR Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
const char* location) {
// Destructs a TestInfo object.
-TestInfo::~TestInfo() { delete factory_; }
+GTEST_ATTRIBUTE_NO_SANITIZE_VPTR TestInfo::~TestInfo() { delete factory_; }
-void TestInfo::Run() {
+GTEST_ATTRIBUTE_NO_SANITIZE_VPTR void TestInfo::Run() {
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
if (!should_run_) {
if (is_disabled_ && matches_filter_) repeater->OnTestDisabled(*this);
Steps to reproduce the problem
Simply create any gtest with the address sanitizer enabled and pass -fno-rtti into the build
What version of GoogleTest are you using?
Exactly 1.14.0
What operating system and version are you using?
Fedora
What compiler and version are you using?
clang version 18.1.8 (Fedora 18.1.8-1.fc40)
Target: x86_64-redhat-linux-gnu
Thread model: posix
What build system are you using?
cmake version 3.30.2
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the issue
It seems like the address sanitizer currently finds a false-positive in gtest regarding validation of vtable pointers. The code is correct but the compiler can't know this when RTTI is disabled. Other parts of the code already seem to work around lack of RTTI through
GTEST_HAS_RTTI
.A simple fix or work around would be as described below and disable the sanitizer in the impacted areas of the code.
This is filed as an issue rather than a direct PR since:
CONTRIBUTING.md
Steps to reproduce the problem
Simply create any gtest with the address sanitizer enabled and pass
-fno-rtti
into the buildWhat version of GoogleTest are you using?
Exactly 1.14.0
What operating system and version are you using?
Fedora
What compiler and version are you using?
clang version 18.1.8 (Fedora 18.1.8-1.fc40)
Target: x86_64-redhat-linux-gnu
Thread model: posix
What build system are you using?
cmake version 3.30.2
Additional context
No response
The text was updated successfully, but these errors were encountered: