[llvm-bugs] [Bug 45236] New: clang crashes in AST/CanonicalType.h:641

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 18 07:23:34 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45236

            Bug ID: 45236
           Summary: clang crashes in AST/CanonicalType.h:641
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tangyixuan at mail.dlut.edu.cn
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, please consider the following piece of code. Clang falls to compile, while
gcc successfully without any issue.

$ cat s.C
template <typename T, int N>
using V [[gnu::vector_size (sizeof (T) * N)]] = T;

void *foo ();


template <typename T, int N>
__attribute__((noipa)) void
test ()
{
  V<T, N> *x = (V<T, N> *) foo ();
}

$ clang++ -c -std=c++11 s.C

s.C:7:16: warning: unknown attribute 'noipa' ignored [-Wunknown-attributes]
__attribute__((noipa)) void
               ^
clang-9:
/home/oscar/compiler/llvm-project/clang/include/clang/AST/CanonicalType.h:641:
static clang::CanQual<T> clang::CanQual< <template-parameter-1-1>
>::CreateUnsafe(clang::QualType) [with T = clang::Type]: Assertion
`(Other.isNull() || Other.isCanonical()) && "Type is not canonical!"' failed.
Stack dump:
0.      Program arguments: /usr/local/bin/clang-9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
s.C -mrelocation-model static -mthread-model posix -mframe-pointer=all
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-resource-dir /usr/local/lib/clang/10.0.0 -internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/x86_64-pc-linux-gnu
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/lib/clang/10.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro
-fdebug-compilation-dir
/media/oscar/xuaner1/autogeneration/testsuitC++/compileinformation/gcc10-20191110-crash-testsuit/clang
-ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fobjc-runtime=gcc
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics
-faddrsig -o s.o -x c++ s.C 
1.      s.C:10:3: at annotation token
2.      s.C:9:1: parsing function body 'test_uns'
3.      s.C:9:1: in compound statement ('{}')
 #0 0x000056195d36f05f llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/home/oscar/compiler/llvm-project/llvm/lib/Support/Unix/Signals.inc:544:0
 #1 0x000056195d36f0f2 PrintStackTraceSignalHandler(void*)
/home/oscar/compiler/llvm-project/llvm/lib/Support/Unix/Signals.inc:605:0
 #2 0x000056195d36cf55 llvm::sys::RunSignalHandlers()
/home/oscar/compiler/llvm-project/llvm/lib/Support/Signals.cpp:68:0
 #3 0x000056195d36e9ea SignalHandler(int)
/home/oscar/compiler/llvm-project/llvm/lib/Support/Unix/Signals.inc:391:0
 #4 0x00007f422bccf890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #5 0x00007f422adc7e97 raise (/lib/x86_64-linux-gnu/libc.so.6+0x3ee97)
 #6 0x00007f422adc9801 abort (/lib/x86_64-linux-gnu/libc.so.6+0x40801)
 #7 0x00007f422adb939a (/lib/x86_64-linux-gnu/libc.so.6+0x3039a)
 #8 0x00007f422adb9412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #9 0x000056195d6da966
clang::CanQual<clang::Type>::CreateUnsafe(clang::QualType)
/home/oscar/compiler/llvm-project/clang/include/clang/AST/CanonicalType.h:641:0
#10 0x000056195d734280 clang::ASTContext::getCanonicalType(clang::QualType)
const
/home/oscar/compiler/llvm-project/clang/include/clang/AST/ASTContext.h:2291:0
#11 0x0000561960c04dc0
clang::ASTContext::getTemplateSpecializationType(clang::TemplateName,
llvm::ArrayRef<clang::TemplateArgument>, clang::QualType) const
/home/oscar/compiler/llvm-project/clang/lib/AST/ASTContext.cpp:4211:0
#12 0x0000561960c04bfa
clang::ASTContext::getTemplateSpecializationType(clang::TemplateName,
clang::TemplateArgumentListInfo const&, clang::QualType) const
/home/oscar/compiler/llvm-project/clang/lib/AST/ASTContext.cpp:4183:0
#13 0x000056196073a026 clang::Sema::CheckTemplateIdType(clang::TemplateName,
clang::SourceLocation, clang::TemplateArgumentListInfo&)
/home/oscar/compiler/llvm-project/clang/lib/Sema/SemaTemplate.cpp:3387:0
#14 0x000056196073abc1 clang::Sema::ActOnTemplateIdType(clang::Scope*,
clang::CXXScopeSpec&, clang::SourceLocation,
clang::OpaquePtr<clang::TemplateName>, clang::IdentifierInfo*,
clang::SourceLocation, clang::SourceLocation,
llvm::MutableArrayRef<clang::ParsedTemplateArgument>, clang::SourceLocation,
bool, bool)
/home/oscar/compiler/llvm-project/clang/lib/Sema/SemaTemplate.cpp:3518:0
#15 0x000056195fdfe55c clang::Parser::AnnotateTemplateIdTokenAsType(bool)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseTemplate.cpp:1227:0
#16 0x000056195fd2bcf7
clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(clang::CXXScopeSpec&,
bool) /home/oscar/compiler/llvm-project/clang/lib/Parse/Parser.cpp:1975:0
#17 0x000056195fd2a3fd
clang::Parser::TryAnnotateName(clang::CorrectionCandidateCallback*)
/home/oscar/compiler/llvm-project/clang/lib/Parse/Parser.cpp:1579:0
#18 0x000056195fdeb766
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseStmt.cpp:190:0
#19 0x000056195fdeb20b
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseStmt.cpp:107:0
#20 0x000056195fdeeb2d clang::Parser::ParseCompoundStatementBody(bool)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseStmt.cpp:1079:0
#21 0x000056195fdf28fd clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseStmt.cpp:2092:0
#22 0x000056195fd29500
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
/home/oscar/compiler/llvm-project/clang/lib/Parse/Parser.cpp:1325:0
#23 0x000056195fdfb358
clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseTemplate.cpp:311:0
#24 0x000056195fdfa7d6
clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseTemplate.cpp:163:0
#25 0x000056195fdfa243
clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext,
clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseTemplate.cpp:36:0
#26 0x000056195fd45544
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseDecl.cpp:1758:0
#27 0x000056195fd276e7
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/home/oscar/compiler/llvm-project/clang/lib/Parse/Parser.cpp:864:0
#28 0x000056195fd26d5c
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/home/oscar/compiler/llvm-project/clang/lib/Parse/Parser.cpp:682:0
#29 0x000056195fd22b5c clang::ParseAST(clang::Sema&, bool, bool)
/home/oscar/compiler/llvm-project/clang/lib/Parse/ParseAST.cpp:157:0
#30 0x000056195ddf233b clang::ASTFrontendAction::ExecuteAction()
/home/oscar/compiler/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1042:0
#31 0x000056195e69bbe2 clang::CodeGenAction::ExecuteAction()
/home/oscar/compiler/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1089:0
#32 0x000056195ddf1c9c clang::FrontendAction::Execute()
/home/oscar/compiler/llvm-project/clang/lib/Frontend/FrontendAction.cpp:939:0
#33 0x000056195dd89f17
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/oscar/compiler/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:956:0
#34 0x000056195df59a9b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/oscar/compiler/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:290:0
#35 0x000056195aa460bf cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /home/oscar/compiler/llvm-project/clang/tools/driver/cc1_main.cpp:250:0
#36 0x000056195aa3b613 ExecuteCC1Tool(llvm::ArrayRef<char const*>,
llvm::StringRef)
/home/oscar/compiler/llvm-project/clang/tools/driver/driver.cpp:309:0
#37 0x000056195aa3bd09 main
/home/oscar/compiler/llvm-project/clang/tools/driver/driver.cpp:382:0
#38 0x00007f422adaab97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#39 0x000056195aa39dea _start (/usr/local/bin/clang-9+0x2b39dea)
clang-9: error: unable to execute command: Aborted (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
722b61892454b3217d73ec486e52156c5a92b5b3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-9: note: diagnostic msg: /tmp/s-301759.cpp
clang-9: note: diagnostic msg: /tmp/s-301759.sh
clang-9: note: diagnostic msg: 

********************

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200318/941bc54f/attachment-0001.html>


More information about the llvm-bugs mailing list