New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang crashes on valid C++ code: Assertion `Permissive || !(!LabelAndGotoScopes.count(TheLabel->getStmt()))' failed #29669
Comments
The issue is that JumpDiagnostics doesn't know that errors occurred in this function prior to template instatiation: #define CHECK_PERMISSIVE(x) (assert(Permissive || !(x)), (Permissive && (x))) JumpScopeChecker::JumpScopeChecker(Stmt *Body, Sema &s) I don't know a good way to check if there were errors while processing the template prior to instantiation. We could get away with setting Permissive to true if the current function is an instantiation, but then we might blind ourselves to some bugs. |
Still crashes on current |
@llvm/issue-subscribers-clang-frontend |
Still crashing as of post-16 trunk (checked via the link above):
|
CC @cor3ntin |
FYI, this seems unrelated to #63682 |
Extended Description
The code is accepted by GCC. It crashes at least all versions of Clang since 2.9.
$ 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
$
$ g++-6.2 -c small.cpp
$
$ clang++ -c small.cpp
small.cpp:4:15: error: use of undeclared label 'T'
void p = &&T;
^
clang-4.0: /tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/JumpDiagnostics.cpp:678: void {anonymous}::JumpScopeChecker::VerifyIndirectJumps(): Assertion `Permissive || !(!LabelAndGotoScopes.count(TheLabel->getStmt()))' 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 0x00007f1a160f2340 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f1a14ee3cc9 gsignal /build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f1a14ee70d8 abort /build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f1a14edcb86 __assert_fail_base /build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f1a14edcc32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x0000000003037468 (anonymous namespace)::JumpScopeChecker::VerifyIndirectJumps() (/usr/local/clang-trunk/bin/clang-4.0+0x3037468)
#9 0x0000000003039970 clang::Sema::DiagnoseInvalidJumps(clang::Stmt) (/usr/local/clang-trunk/bin/clang-4.0+0x3039970)
#10 0x0000000002c48a8f clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2c48a8f)
#11 0x0000000002fe3791 clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2fe3791)
#12 0x0000000002fe20e7 clang::Sema::PerformPendingInstantiations(bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2fe20e7)
#13 0x0000000002b9080c clang::Sema::ActOnEndOfTranslationUnit() (/usr/local/clang-trunk/bin/clang-4.0+0x2b9080c)
#14 0x0000000002982085 clang::Parser::ParseTopLevelDecl(clang::OpaquePtrclang::DeclGroupRef&) (/usr/local/clang-trunk/bin/clang-4.0+0x2982085)
#15 0x0000000002979393 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/clang-trunk/bin/clang-4.0+0x2979393)
#16 0x00000000025ea82e clang::CodeGenAction::ExecuteAction() (/usr/local/clang-trunk/bin/clang-4.0+0x25ea82e)
#17 0x00000000022e8cce clang::FrontendAction::Execute() (/usr/local/clang-trunk/bin/clang-4.0+0x22e8cce)
#18 0x00000000022be326 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/clang-trunk/bin/clang-4.0+0x22be326)
#19 0x00000000023783d2 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/clang-trunk/bin/clang-4.0+0x23783d2)
#20 0x0000000000b567a0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/clang-trunk/bin/clang-4.0+0xb567a0)
#21 0x0000000000b0123f main (/usr/local/clang-trunk/bin/clang-4.0+0xb0123f)
#22 0x00007f1a14eceec5 __libc_start_main /build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#23 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/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 -ferror-limit 19 -fmessage-length 153 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o small.o -x c++ small.cpp
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-b2f8d1.cpp
clang-4.0: note: diagnostic msg: /tmp/small-b2f8d1.sh
clang-4.0: note: diagnostic msg:
$
template < typename T > void f ()
{
T:
void *p = &&T;
goto *p;
}
int main ()
{
f < int > ();
return 0;
}
The text was updated successfully, but these errors were encountered: