google / google/googletest

UBSan: Invalid vptr when compiling with no-rtti

Open
#4,116 4 comments 0 reactions 1 assignee Claimed by @derekmauro View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

```
src/googletest/src/gtest.cc:2727:32: runtime error: member call on address 0x55ef35a2f690 which does not point to an object of type 'TestFactoryBase'
0x55ef35a2f690: note: object has invalid vptr
00 00 00 00 70 7a c7 34 ef 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00
^~~~~~~~~~~~~~~~~~~~~~~
invalid vptr
```

### Steps to reproduce the problem

Here is a CI run that produced the problem: https://github.com/JuliaSIMD/LoopModels/actions/runs/3849067677/jobs/6557615496

[CMakeLists.txt](https://github.com/JuliaSIMD/LoopModels/blob/0597b18d27be2e7cc28dab005c071b850fd4978f/test/CMakeLists.txt)
```cmake
CPMFindPackage(
NAME googletest
GITHUB_REPOSITORY google/googletest
GIT_TAG release-1.12.1
VERSION 1.12.1
OPTIONS "INSTALL_GTEST OFF" "BUILD_GMOCK OFF" "gtest_hide_internal_symbols ON"
)
```
This failure appears consistently across computers.

### What version of GoogleTest are you using?

1.12.1, but I also tried main.

### What operating system and version are you using?

Fedora 37, and Ubuntu 22.04 (CI).

### What compiler and version are you using?

Problem appears with both.
```
> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-12.2.1-20221121/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.1 20221121 (Red Hat 12.2.1-4) (GCC)

> clang -v
clang version 15.0.6 (Fedora 15.0.6-2.fc37)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-redhat-linux/12
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/12
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
```

### What build system are you using?

```
> cmake --version
cmake version 3.25.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
```

### Additional context

I spent a little time trying to produce a minimal example, but could not reproduce the problem yet.

Note that the error points to [this destructor](https://github.com/google/googletest/blob/58d77fa8070e8cec2dc1ed015d66b454c8d78850/googletest/src/gtest.cc#L2727).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.