Open
Description
When trying a 2-stage build on 32-bit Solaris/SPARC, clang
dies in stage 2 compiling gtest-all.cc
:
FAILED: projects/compiler-rt/lib/sanitizer_common/tests/SANITIZER_TEST_OBJECTS.gtest-all.cc.sparcv9.o /var/llvm/dist-sparc-release-stage2-A/tools/clang/stage2-bins/projects/compiler-rt/lib/sanitizer_common/tests/SANITIZER_TEST_OBJECTS.gtest-all.cc.sparcv9.o
cd /var/llvm/dist-sparc-release-stage2-A/tools/clang/stage2-bins/projects/compiler-rt/lib/sanitizer_common/tests && /var/llvm/dist-sparc-release-stage2-A/tools/clang/stage2-bins/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -g -Wno-covered-switch-default -Wno-suggest-override -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest/include -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googlemock/include -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googlemock -I/vol/llvm/src/llvm-project/dist/compiler-rt/include -I/vol/llvm/src/llvm-project/dist/compiler-rt/lib -I/vol/llvm/src/llvm-project/dist/compiler-rt/lib/sanitizer_common -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Werror=sign-compare -Wno-gnu-zero-variadic-macro-arguments -gline-tables-only -O0 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -m32 -c -o SANITIZER_TEST_OBJECTS.gtest-all.cc.sparc.o /vol/llvm/src/llvm-project/dist/third-party/unittest/googletest/src/gtest-all.cc
Stack dump:
0. Program arguments: /var/llvm/dist-sparc-release-stage2-A/tools/clang/stage2-bins/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -g -Wno-covered-switch-default -Wno-suggest-override -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest/include -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googlemock/include -I/vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googlemock -I/vol/llvm/src/llvm-project/dist/compiler-rt/include -I/vol/llvm/src/llvm-project/dist/compiler-rt/lib -I/vol/llvm/src/llvm-project/dist/compiler-rt/lib/sanitizer_common -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Werror=sign-compare -Wno-gnu-zero-variadic-macro-arguments -gline-tables-only -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -m32 -c -o SANITIZER_TEST_OBJECTS.gtest-all.cc.sparc.o /vol/llvm/src/llvm-project/dist/third-party/unittest/googletest/src/gtest-all.cc
1. /usr/include/sys/fcntl.h:26:1: current parser token 'extern'
2. /vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest/src/gtest.cc:141:11: LLVM IR generation of declaration 'testing'
3. /vol/llvm/src/llvm-project/dist/llvm/../third-party/unittest/googletest/src/gtest.cc:523:23: Generating code for declaration 'testing::internal::UnitTestOptions::FilterMatchesTest'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 clang-18 0x07af8604 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 36
1 clang-18 0x07af78bc llvm::sys::CleanupOnSignal(unsigned int) + 440
2 clang-18 0x07a49128 CrashRecoverySignalHandler(int) + 176
3 libc.so.1 0xfe9644d0 __sighndlr + 12
4 libc.so.1 0xfe956460 call_user_handler + 1044
5 libc.so.1 0xfe956814 sigacthandler + 172
6 clang-18 0x0822a208 clang::CodeGen::CodeGenFunction::pushLifetimeExtendedDestroy(clang::CodeGen::CleanupKind, clang::CodeGen::Address, clang::QualType, void (*)(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType), bool) + 836
7 clang-18 0x0824b680 pushTemporaryCleanup(clang::CodeGen::CodeGenFunction&, clang::MaterializeTemporaryExpr const*, clang::Expr const*, clang::CodeGen::Address) + 868
8 clang-18 0x0824a6c8 clang::CodeGen::CodeGenFunction::EmitMaterializeTemporaryExpr(clang::MaterializeTemporaryExpr const*) + 2972
9 clang-18 0x08255048 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) + 2472
10 clang-18 0x08254d64 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) + 1732
11 clang-18 0x0824cf44 clang::CodeGen::CodeGenFunction::EmitReferenceBindingToExpr(clang::Expr const*) + 40
12 clang-18 0x082281cc clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) + 124
13 clang-18 0x08224f04 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) + 1836
14 clang-18 0x0821ef84 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) + 372
15 clang-18 0x0821ec08 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) + 1788
16 clang-18 0x07e21c04 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) + 252
17 clang-18 0x07e168a8 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 1016
18 clang-18 0x07e14fc4 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) + 132
19 clang-18 0x07e22ea8 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) + 312
20 clang-18 0x07e98f80 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) + 260
21 clang-18 0x07e99ff0 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 2044
22 clang-18 0x07ecdd98 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 604
23 clang-18 0x07ec2550 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) + 724
24 clang-18 0x07ec7f2c clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 1596
25 clang-18 0x07ec0d20 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 1252
26 clang-18 0x07ed6ef8 clang::CodeGen::CodeGenModule::EmitDeclContext(clang::DeclContext const*) + 88
27 clang-18 0x07ec1000 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 1988
28 clang-18 0x07ed6ef8 clang::CodeGen::CodeGenModule::EmitDeclContext(clang::DeclContext const*) + 88
29 clang-18 0x07ec1000 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 1988
30 clang-18 0x08fed448 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 196
31 clang-18 0x08fe8e64 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 216
32 clang-18 0x0a7b8a20 clang::ParseAST(clang::Sema&, bool, bool) + 1064
33 clang-18 0x086d83d8 clang::ASTFrontendAction::ExecuteAction() + 212
34 clang-18 0x08fe6efc clang::CodeGenAction::ExecuteAction() + 168
35 clang-18 0x086d79c8 clang::FrontendAction::Execute() + 100
36 clang-18 0x0861a930 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 976
37 clang-18 0x087e9df0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 640
38 clang-18 0x04af0100 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 3044
39 clang-18 0x04aecd38 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) + 1284
40 clang-18 0x08447664 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(int) + 16
41 clang-18 0x07a48da8 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 200
42 clang-18 0x08446c20 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 324
43 clang-18 0x08404234 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 696
44 clang-18 0x084045fc clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 140
45 clang-18 0x08423a38 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 348
46 clang-18 0x04aec220 clang_main(int, char**, llvm::ToolContext const&) + 14192
47 clang-18 0x04afd2e4 main + 28
48 clang-18 0x04ae8468 _start + 92
This only happens with a Release
(or RelWithDebInfo
) build, not in a Debug
build. Likewise, a gcc
-compiled clang
in stage 1 is fine, too.
I could reduce the testcase to
$ cat gtest-all.ii
inline namespace __cxx11 {
struct basic_string {
~basic_string();
};
} // namespace __cxx11
basic_string GetOutputFormat() {
const basic_string &output_format = GetOutputFormat();
}
$ clang -m32 -O2 -w gtset-all.ii
gdb
shows this is an unaligned access:`
Thread 2 received signal SIGBUS, Bus error.
[Switching to Thread 1 (LWP 1)]
0x0822b328 in (anonymous namespace)::DestroyObject::DestroyObject (
this=0xffbfacb4, type=...,
destroyer=0x82045e8 <clang::CodeGen::CodeGenFunction::destroyCXXObject(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType)>,
addr=..., useEHCleanupForArray=<optimized out>)
at /vol/llvm/src/llvm-project/dist/clang/lib/CodeGen/CGDecl.cpp:502
502 : addr(addr), type(type), destroyer(destroyer),
1: x/i $pc
=> 0x822b328 <_ZN5clang7CodeGen15CodeGenFunction27pushLifetimeExtendedDestroyENS0_11CleanupKindENS0_7AddressENS_8QualTypeEPFvRS1_S3_S4_Eb+836>:
sttw %i0, [ %i3 + 0x10 ]
(gdb) p/x $i3 + 0x10
$6 = 0xffbfacbc
The target isn't 8-byte aligned as it should.