Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang crash on printing type size of incomplete template type [crash in clang::ASTContext::getASTRecordLayout] #31615

Open Quuxplusone opened 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR32643
Status NEW
Importance P enhancement
Reported by Kevin Funk (kfunk@kde.org)
Reported on 2017-04-12 13:36:19 -0700
Last modified on 2020-03-01 02:51:59 -0800
Version 4.0
Hardware PC Linux
CC dgregor@apple.com, john@mcfarlane.name, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments source-file.cpp (1012559 bytes, text/plain)
Blocks
Blocked by
See also
Clang 4.0 from Ubuntu 17.04 packages.

Downstream issue from the KDevelop IDE:
  https://bugs.kde.org/show_bug.cgi?id=376084

Test case:

$ cat ~/test.cpp
template<typename T> using crash = struct : public virtual T {}

$ c-index-test -test-print-type-size ~/test.cpp
0  libLLVM-4.0.so.1  0x00007f72756b3488
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 56
1  libLLVM-4.0.so.1  0x00007f72756b156e llvm::sys::RunSignalHandlers() + 62
2  libLLVM-4.0.so.1  0x00007f72756b16aa
3  libpthread.so.0   0x00007f727969a670
4  libclang-4.0.so.1 0x00007f72782dfeea
5  libclang-4.0.so.1 0x00007f72782e05ec
6  libclang-4.0.so.1 0x00007f7278212ca2
7  libclang-4.0.so.1 0x00007f727820b40c
8  libclang-4.0.so.1 0x00007f727820b6e5
9  libclang-4.0.so.1 0x00007f727820b790
10 libclang-4.0.so.1 0x00007f727820b7a9
11 libclang-4.0.so.1 0x00007f72781d9cdb clang_Type_getSizeOf + 219
12 c-index-test      0x0000559bf1bb6e92
13 libclang-4.0.so.1 0x00007f72781aa235
14 libclang-4.0.so.1 0x00007f72781adc1d
15 libclang-4.0.so.1 0x00007f72781add46
16 libclang-4.0.so.1 0x00007f72781a9f20
17 libclang-4.0.so.1 0x00007f72781b2cd4 clang_visitChildren + 340
18 c-index-test      0x0000559bf1bb8e9f
19 c-index-test      0x0000559bf1bb935a
20 c-index-test      0x0000559bf1bbd48f
21 c-index-test      0x0000559bf1bb1dad
22 libLLVM-4.0.so.1  0x00007f72756b49ad
23 libpthread.so.0   0x00007f72796906da
24 libc.so.6         0x00007f727476717f clone + 95
zsh: segmentation fault  c-index-test -test-print-type-size ~/test.cpp

Full backtrace:
#1  0x00007ffff68105ec in
clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const () at
/build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/lib/AST/RecordLayoutBuilder.cpp:192
#2  0x00007ffff6742ca2 in clang::ASTContext::getTypeInfoImpl(clang::Type
const*) const () at /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-
4.0/tools/clang/lib/AST/ASTContext.cpp:1869
#3  0x00007ffff673b40c in clang::ASTContext::getTypeInfo(clang::Type const*)
const () at /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-
4.0/tools/clang/lib/AST/ASTContext.cpp:1608
#4  0x00007ffff673b6e5 in clang::ASTContext::getTypeInfoInChars(clang::Type
const*) const () at /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-
4.0/tools/clang/lib/AST/ASTContext.cpp:1560
#5  0x00007ffff673b790 in
clang::ASTContext::getTypeInfoInChars(clang::QualType) const () at /build/llvm-
toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/lib/AST/ASTContext.cpp:1567
warning: (Internal error: pc 0x7ffff673b78f in read in psymtab, but not in
symtab.)
#6  0x00007ffff673b7a9 in
clang::ASTContext::getTypeSizeInChars(clang::QualType) const () at /build/llvm-
toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/lib/AST/ASTContext.cpp:1973
warning: (Internal error: pc 0x7ffff673b7a8 in read in psymtab, but not in
symtab.)
#7  0x00007ffff6709cdb in clang_Type_getSizeOf () at /build/llvm-toolchain-4.0-
Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/tools/libclang/CXType.cpp:807
#8  0x0000555555721e92 in ?? ()
#9  0x00007ffff66da235 in clang::cxcursor::CursorVisitor::Visit(CXCursor, bool)
() at /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-
4.0/tools/clang/tools/libclang/CIndex.cpp:209
#10 0x00007ffff66ddc1d in
clang::cxcursor::CursorVisitor::handleDeclForVisitation(clang::Decl const*) ()
at /build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-
4.0/tools/clang/tools/libclang/CIndex.cpp:666
#11 0x00007ffff66ddd46 in
clang::cxcursor::CursorVisitor::VisitDeclContext(clang::DeclContext*) () at
/build/llvm-toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/tools/libclang/CIndex.cpp:627
#12 0x00007ffff66d9f20 in
clang::cxcursor::CursorVisitor::VisitChildren(CXCursor) () at /build/llvm-
toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/tools/libclang/CIndex.cpp:532
#13 0x00007ffff66e2cd4 in clang_visitChildren () at /build/llvm-toolchain-4.0-
Ha24C1/llvm-toolchain-4.0-4.0/tools/clang/tools/libclang/CIndex.cpp:4159
#14 0x0000555555723e9f in ?? ()
#15 0x000055555572435a in ?? ()
#16 0x000055555572848f in ?? ()
#17 0x000055555571cdad in ?? ()
warning: Could not find DWO CU
CMakeFiles/LLVMSupport.dir/Threading.cpp.dwo(0x363818461f04e17a) referenced by
CU at offset 0x8a05 [in module /usr/lib/debug/.build-
id/d2/9e710b4569fee5ee81383b192fd42e974908c0.debug]
#18 0x00007ffff3be49ad in ExecuteOnThread_Dispatch(void*) () at /build/llvm-
toolchain-4.0-Ha24C1/llvm-toolchain-4.0-4.0/lib/Support/Threading.cpp:42
#19 0x00007ffff7bc06da in start_thread (arg=0x7ffff1dfd700) at
pthread_create.c:456
#20 0x00007ffff2c9717f in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:105
Quuxplusone commented 4 years ago
Comment on attachment 23190
Preprocessed output (-E) from one of the TUs exhibiting the issue

Sorry, attached file to the wrong issue. Please ignore/delete!
Quuxplusone commented 4 years ago

Attached source-file.cpp (1012559 bytes, text/plain): Preprocessed output (-E) from one of the TUs exhibiting the issue