[llvm-bugs] [Bug 30314] New: clang crashes on invalid C++ code (use of undeclared variable): Assertion `TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 7 13:19:33 PDT 2016


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

            Bug ID: 30314
           Summary: clang crashes on invalid C++ code (use of undeclared
                    variable): Assertion `TyposInContext < ~0U &&
                    "Recursive call of CorrectDelayedTyposInExpr"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang crashes on the given code without issuing any proper diagnostics. This
affects 3.6.x and later; 3.5.x properly rejects the code. 

It is interesting that the crash appears to be sensitive to the choices of
identifier names for "end" and "bend". 


$ clang++ -v
clang version 4.0.0 (trunk 280730)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/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
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
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.1.1
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++ -c small.cpp
clang-4.0:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/SemaExprCXX.cpp:6958:
clang::ExprResult clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*,
llvm::function_ref<clang::ActionResult<clang::Expr*>(clang::Expr*)>): Assertion
`TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"' failed.
#0 0x0000000001e484f5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-4.0+0x1e484f5)
#1 0x0000000001e465de llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-4.0+0x1e465de)
#2 0x0000000001e46740 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-4.0+0x1e46740)
#3 0x00007f42abd63340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f42aab54cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f42aab580d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f42aab4db86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f42aab4dc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000002db3822 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true>
(clang::Expr*)>) (/usr/local/clang-trunk/bin/clang-4.0+0x2db3822)
#9 0x0000000002d65058 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*,
clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::Expr*, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2d65058)
#10 0x0000000002dcc02d clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformCallExpr(clang::CallExpr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2dcc02d)
#11 0x0000000002db4fcf clang::TreeTransform<(anonymous
namespace)::TransformTypos>::TransformExpr(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2db4fcf)
#12 0x0000000002db5bf9 (anonymous
namespace)::TransformTypos::TryTransform(clang::Expr*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2db5bf9)
#13 0x0000000002db263d clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*,
clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true>
(clang::Expr*)>) (/usr/local/clang-trunk/bin/clang-4.0+0x2db263d)
#14 0x0000000002db3963 clang::Sema::ActOnFinishFullExpr(clang::Expr*,
clang::SourceLocation, bool, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2db3963)
#15 0x0000000002ee1900
clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>)
(/usr/local/clang-trunk/bin/clang-4.0+0x2ee1900)
#16 0x00000000029ffa3d clang::Parser::ParseExprStatement()
(/usr/local/clang-trunk/bin/clang-4.0+0x29ffa3d)
#17 0x00000000029fce5f
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-4.0+0x29fce5f)
#18 0x00000000029fd03e
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
(/usr/local/clang-trunk/bin/clang-4.0+0x29fd03e)
#19 0x0000000002a019b9 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a019b9)
#20 0x0000000002a041f9 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-4.0+0x2a041f9)
#21 0x0000000002980a97
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2980a97)
#22 0x0000000002a119a8
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a119a8)
#23 0x0000000002a12627
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a12627)
#24 0x0000000002a1299a
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-4.0+0x2a1299a)
#25 0x00000000029a3694 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-4.0+0x29a3694)
#26 0x0000000002981402
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-4.0+0x2981402)
#27 0x0000000002981f12
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-4.0+0x2981f12)
#28 0x0000000002979393 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-4.0+0x2979393)
#29 0x00000000025ea82e clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-4.0+0x25ea82e)
#30 0x00000000022e8cce clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-4.0+0x22e8cce)
#31 0x00000000022be326
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-4.0+0x22be326)
#32 0x00000000023783d2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-4.0+0x23783d2)
#33 0x0000000000b567a0 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb567a0)
#34 0x0000000000b0123f main (/usr/local/clang-trunk/bin/clang-4.0+0xb0123f)
#35 0x00007f42aab3fec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#36 0x0000000000b528fe _start (/usr/local/clang-trunk/bin/clang-4.0+0xb528fe)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-4.0 -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-notes-file
/data2/c-hunter/test/fun/try5b/RES8/LATERCLANG/20160730-clang++-trunk-O3-m32-build-232354/small.gcno
-resource-dir /usr/local/clang-trunk/bin/../lib/clang/4.0.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/4.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir
/data2/c-hunter/test/fun/try5b/RES8/LATERCLANG/20160730-clang++-trunk-O3-m32-build-232354
-ferror-limit 19 -fmessage-length 166 -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c++
small.cpp
1.      small.cpp:12:1: current parser token '}'
2.      small.cpp:9:1: parsing function body 'A::operator='
3.      small.cpp:9:1: in compound statement ('{}')
clang-4.0: error: unable to execute command: Aborted (core dumped)
clang-4.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 4.0.0 (trunk 280730)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
clang-4.0: 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-4.0: note: diagnostic msg:
********************

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

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


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


template < typename T > struct A
{ 
  A &operator= (const A &);
  void end ();
  void foo (int, T);
};

template < typename T > A < T > & A < T >::operator= (const A &)
{ 
  T t;
  foo (bend, t);
}

-- 
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/20160907/02eac8f7/attachment-0001.html>


More information about the llvm-bugs mailing list