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

clang18 + libc++abi unittest failure #607

Open
sternezsl opened this issue Jun 7, 2024 · 1 comment
Open

clang18 + libc++abi unittest failure #607

sternezsl opened this issue Jun 7, 2024 · 1 comment

Comments

@sternezsl
Copy link

sternezsl commented Jun 7, 2024

When running unittest thrift/lib/cpp2/test/FutureTest.cpp

# ./bin/cpp2_test_FutureTest
[==========] Running 8 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 8 tests from ThriftServer
[ RUN      ] ThriftServer.FutureExceptions
*** Aborted at 1717719275 (Unix time, try 'date -d @1717719275') ***
*** Signal 11 (SIGSEGV) (0x399f5aa1403e8) received by PID 2529977 (pthread TID 0xffff257aa180) (linux TID 2529977) (c
ode: address not mapped to object), stack trace: ***
/usr/lib64/libfolly.so.1(_ZN5folly10symbolizer21SafeStackTracePrinter15printStackTraceEb+0x3b) [0xffff2236fa07]
/usr/lib64/libfolly.so.1(_ZN5folly10symbolizer21SafeStackTracePrinter15printStackTraceEb+0x3b) [0xffff2236fa07]
/usr/lib64/libfolly.so.1(+0x3ed8cb) [0xffff2236d8cb]
linux-vdso.so.1(__kernel_rt_sigreturn+0) [0xffff257f8820]
/opt/llvm/18.1.6/lib/aarch64-unknown-linux-gnu/libc++abi.so.1(__dynamic_cast+0x1f) [0xffff2172075b]
/usr/lib64/libthriftcpp2.so.1.0.0(_ZN6apache6thrift12Thr
iftServer19setProcessorFactoryENSt3__110shared_ptrINS0_21AsyncProcessorFactoryEEE+0xf7) [0xffff236dcd1b]
./bin/cpp2_test_FutureTest(_ZN6apache6thrift23TestThriftServerFactoryI13TestInterfaceE6createEv+0x293) [0xaaab7c00a8d
b]
./bin/cpp2_test_FutureTest(_ZN34ThriftServer_FutureExceptions_Test8TestBodyEv+0x43) [0xaaab7c00453b]
/usr/lib64/libgtest.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x6f\
) [0xffff21915f1f]
/usr/lib64/libgtest.so(_ZN7testing4Test3RunEv+0xe3) [0xffff218f8047]
/usr/lib64/libgtest.so(_ZN7testing8TestInfo3RunEv+0x103) [0xffff218f94eb]
/usr/lib64/libgtest.so(_ZN7testing9TestSuite3RunEv+0x13b) [0xffff218f9daf]
/usr/lib64/libgtest.so(_ZN7testing8internal12UnitTestImpl11RunAllTestsEv+0x413) [0xffff2190772f]
/usr/lib64/libgtest.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_\
vEPKc+0x6f) [0xffff21916d97]
/usr/lib64/libgtest.so(_ZN7testing8UnitTest3RunEv+0x7f) [0xffff219072e3]
/usr/lib64/libfolly_test_support.so(main+0x3b) [0xffff23a957cf]
/lib64/libc.so.6(+0x30a1b) [0xffff21a10a1b]
/lib64/libc.so.6(+0x30a1b) [0xffff21a10a1b]
(safe mode, symbolizer not available)

It crashed on

if (auto serverInterface = dynamic_cast<ServerInterface*>(serviceHandler)) {

Simple demo built with c++20 works well. The platform is linux aarch64(same segmentfault on macOS m1), LLVM version is 18.1.6

@sternezsl
Copy link
Author

The reason is that there is a change related dynamic_cast in LLVM 17.0.1
https://releases.llvm.org/17.0.1/tools/clang/docs/ReleaseNotes.html

Improved code generation for dynamic_cast to a final type. Instead of dispatching to the runtime library to compare the RTTI data, Clang now generates a direct comparison of the vtable pointer in cases where the ABI requires the vtable for a class to be unique. This optimization can be disabled with -fno-assume-unique-vtables. This optimization is not yet implemented for the MS C++ ABI.

After add the compile option -fno-assume-unique-vtables, everything works now.

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