[llvm-bugs] [Bug 27994] New: clang crashes on valid C++11 code: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 3 10:58:39 PDT 2016


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

            Bug ID: 27994
           Summary: clang crashes on valid C++11 code: Assertion
                    `!isNull() && "Cannot retrieve a NULL type pointer"'
                    failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following valid C++11 test
case on x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.8.x.


$ clang++-trunk -v
clang version 3.9.0 (trunk 271236)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-3.8 -std=c++11 small.cpp -c
$ g++-6.1 small.cpp -c
$
$ clang++-trunk -std=c++11 small.cpp -c
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/include/clang/AST/Type.h:612:
const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
#0 0x0000000001dfd8b5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfd8b5)
#1 0x0000000001dfb846 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfb846)
#2 0x0000000001dfba64 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1dfba64)
#3 0x00007fbbcd04a340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007fbbcc268cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fbbcc26c0d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fbbcc261b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fbbcc261c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002cef033 (/usr/local/clang-trunk/bin/clang-3.9+0x2cef033)
#9 0x0000000002d042c7 clang::Sema::getCurrentThisType()
(/usr/local/clang-trunk/bin/clang-3.9+0x2d042c7)
#10 0x0000000002efeb8c clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCXXThisExpr(clang::CXXThisExpr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2efeb8c)
#11 0x0000000002f09568 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f09568)
#12 0x0000000002f26640 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformMemberExpr(clang::MemberExpr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f26640)
#13 0x0000000002f090b2 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f090b2)
#14 0x0000000002f0ab88 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f0ab88)
#15 0x0000000002f0af04 clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f0af04)
#16 0x0000000002f381f1
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f381f1)
#17 0x0000000002f40784 clang::Sema::BuildVariableInstantiation(clang::VarDecl*,
clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::DeclContext*, clang::LocalInstantiationScope*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f40784)
#18 0x0000000002f40fd7
clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f40fd7)
#19 0x0000000002f43bc5 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f43bc5)
#20 0x0000000002f06abc clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f06abc)
#21 0x0000000002f1c123 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f1c123)
#22 0x0000000002f1ce54 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*,
bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2f1ce54)
#23 0x0000000002f1cf8b clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f1cf8b)
#24 0x0000000002f1c173 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformStmt(clang::Stmt*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f1c173)
#25 0x0000000002f082ef clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformLambdaExpr(clang::LambdaExpr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f082ef)
#26 0x0000000002f091c4 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f091c4)
#27 0x0000000002f0ab88 clang::TreeTransform<(anonymous
namespace)::TemplateInstantiator>::TransformInitializer(clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f0ab88)
#28 0x0000000002f0af04 clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2f0af04)
#29 0x0000000002f0b1a8
clang::Sema::InstantiateInClassInitializer(clang::SourceLocation,
clang::FieldDecl*, clang::FieldDecl*, clang::MultiLevelTemplateArgumentList
const&) (/usr/local/clang-trunk/bin/clang-3.9+0x2f0b1a8)
#30 0x0000000002c0afa0
clang::Sema::BuildCXXDefaultInitExpr(clang::SourceLocation, clang::FieldDecl*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2c0afa0)
#31 0x0000000002c283e5 CollectFieldInitializer(clang::Sema&, (anonymous
namespace)::BaseAndFieldInfo&, clang::FieldDecl*, clang::IndirectFieldDecl*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2c283e5)
#32 0x0000000002c458fb
clang::Sema::SetCtorInitializers(clang::CXXConstructorDecl*, bool,
llvm::ArrayRef<clang::CXXCtorInitializer*>)
(/usr/local/clang-trunk/bin/clang-3.9+0x2c458fb)
#33 0x0000000002c46f88
clang::Sema::DefineImplicitDefaultConstructor(clang::SourceLocation,
clang::CXXConstructorDecl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2c46f88)
#34 0x0000000002cb9fa4
clang::Sema::MarkFunctionReferenced(clang::SourceLocation,
clang::FunctionDecl*, bool) (/usr/local/clang-trunk/bin/clang-3.9+0x2cb9fa4)
#35 0x0000000002c0abaf
clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType,
clang::NamedDecl*, clang::CXXConstructorDecl*, bool,
llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, unsigned int,
clang::SourceRange) (/usr/local/clang-trunk/bin/clang-3.9+0x2c0abaf)
#36 0x0000000002c0acf0
clang::Sema::BuildCXXConstructExpr(clang::SourceLocation, clang::QualType,
clang::NamedDecl*, clang::CXXConstructorDecl*,
llvm::MutableArrayRef<clang::Expr*>, bool, bool, bool, bool, unsigned int,
clang::SourceRange) (/usr/local/clang-trunk/bin/clang-3.9+0x2c0acf0)
#37 0x0000000002d60ab6 PerformConstructorInitialization(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step
const&, bool&, bool, bool, clang::SourceLocation, clang::SourceLocation)
(/usr/local/clang-trunk/bin/clang-3.9+0x2d60ab6)
#38 0x0000000002d6fc14 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2d6fc14)
#39 0x0000000002bbfd41 clang::Sema::ActOnUninitializedDecl(clang::Decl*, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x2bbfd41)
#40 0x000000000290aa56
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-3.9+0x290aa56)
#41 0x0000000002918d95 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2918d95)
#42 0x00000000028f53bd
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x28f53bd)
#43 0x00000000028f5a61
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.222]
(/usr/local/clang-trunk/bin/clang-3.9+0x28f5a61)
#44 0x00000000028f5a9f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/clang-trunk/bin/clang-3.9+0x28f5a9f)
#45 0x00000000028fa850
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x28fa850)
#46 0x00000000028fb020
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x28fb020)
#47 0x00000000028f25fb clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x28f25fb)
#48 0x0000000002593d0e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x2593d0e)
#49 0x0000000002271c5e clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x2271c5e)
#50 0x0000000002247ba6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2247ba6)
#51 0x00000000022feb72
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x22feb72)
#52 0x0000000000ae2fc8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xae2fc8)
#53 0x0000000000a9c8ae main (/usr/local/clang-trunk/bin/clang-3.9+0xa9c8ae)
#54 0x00007fbbcc253ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#55 0x0000000000adf034 _start (/usr/local/clang-trunk/bin/clang-3.9+0xadf034)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb
-coverage-file /data2/small.cpp -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.9.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 /data2 -ferror-limit 19 -fmessage-length 144
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      small.cpp:13:12: current parser token ';'
2.      small.cpp:10:5: instantiating default member init 'B<int>::f'
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 271236)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.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-3.9: note: diagnostic msg: /tmp/small-44614f.cpp
clang-3.9: note: diagnostic msg: /tmp/small-44614f.sh
clang-3.9: note: diagnostic msg:

********************
$


-----------------------------------


struct A
{ 
  template < typename F > A (F);
};

template < typename T >
class B
{ 
  int x;
  A f = [&] { int y = x; };
};

B < int > b;

-- 
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/20160603/b70e47c5/attachment-0001.html>


More information about the llvm-bugs mailing list