[llvm-bugs] [Bug 43071] New: Segmentation Fault when throwing exceptions from ternary conditional with -Wunreachable-code enabled

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 21 03:16:47 PDT 2019


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

            Bug ID: 43071
           Summary: Segmentation Fault when throwing exceptions from
                    ternary conditional with -Wunreachable-code enabled
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tony.wasserka at gmx.de
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Clang crashes on lines such as 'false ? 0 : throw std::runtime_error("b")' if
-Wunreachable-code is used: https://godbolt.org/z/RKDwVc



Stack dump:
0.      Program arguments: /usr/bin/clang-8.0.1 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name crash.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 -resource-dir
/usr/lib64/clang/8.0.1 -internal-isystem
/usr/bin/../lib64/gcc/x86_64-suse-linux/9/../../../../include/c++/9
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-suse-linux/9/../../../../include/c++/9/x86_64-suse-linux
-internal-isystem
/usr/bin/../lib64/gcc/x86_64-suse-linux/9/../../../../include/c++/9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/lib64/clang/8.0.1/include -internal-externc-isystem /include
-internal-externc-isystem /usr/include -Wunreachable-code -fdeprecated-macro
-fdebug-compilation-dir /home/tony/creatorcrash -ferror-limit 19
-fmessage-length 262 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/crash-266244.o -x c++
crash.cpp -faddrsig 
1.      <eof> parser at end of file
2.      crash.cpp:3:13: parsing function body 'func'
 #0 0x00007fa710f8fe7d llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/bin/../lib64/libLLVM.so.8+0xa84e7d)
 #1 0x00007fa710f8e0e0 llvm::sys::RunSignalHandlers()
(/usr/bin/../lib64/libLLVM.so.8+0xa830e0)
 #2 0x00007fa710f90298 (/usr/bin/../lib64/libLLVM.so.8+0xa85298)
 #3 0x00007fa714ebb630 __restore_rt (/lib64/libpthread.so.0+0x13630)
 #4 0x00007fa70ee56858
(/usr/bin/../lib64/../lib64/../lib64/libclangAnalysis.so.8+0x92858)
 #5 0x00007fa70ee5608c
clang::reachable_code::FindUnreachableCode(clang::AnalysisDeclContext&,
clang::Preprocessor&, clang::reachable_code::Callback&)
(/usr/bin/../lib64/../lib64/../lib64/libclangAnalysis.so.8+0x9208c)
 #6 0x00007fa70f3fe497
clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy,
clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::BlockExpr const*)
(/usr/bin/../lib64/../lib64/libclangSema.so.8+0xba497)
 #7 0x00007fa70f45c86a
clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy
const*, clang::Decl const*, clang::BlockExpr const*)
(/usr/bin/../lib64/../lib64/libclangSema.so.8+0x11886a)
 #8 0x00007fa70f55c5d5 clang::Sema::ActOnFinishFunctionBody(clang::Decl*,
clang::Stmt*, bool) (/usr/bin/../lib64/../lib64/libclangSema.so.8+0x2185d5)
 #9 0x00007fa70fb2ce40 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xb9e40)
#10 0x00007fa70fb438cc
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xd08cc)
#11 0x00007fa70fab6d16 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0x43d16)
#12 0x00007fa70fb42ada
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xcfada)
#13 0x00007fa70fb424d9
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xcf4d9)
#14 0x00007fa70fb413b7
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xce3b7)
#15 0x00007fa70fb4016e
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0xcd16e)
#16 0x00007fa70faa36c6 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/../lib64/../lib64/libclangParse.so.8+0x306c6)
#17 0x00007fa714a5c7f2 clang::CodeGenAction::ExecuteAction()
(/usr/bin/../lib64/libclangCodeGen.so.8+0x2c57f2)
#18 0x00007fa7145620cf clang::FrontendAction::Execute()
(/usr/bin/../lib64/libclangFrontend.so.8+0xc90cf)
#19 0x00007fa714518c18
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/../lib64/libclangFrontend.so.8+0x7fc18)
#20 0x00007fa714495dde
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/../lib64/libclangFrontendTool.so.8+0x3dde)
#21 0x00000000004a02c9 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-8.0.1+0x4a02c9)
#22 0x000000000049e74c main (/usr/bin/clang-8.0.1+0x49e74c)
#23 0x00007fa710046bcb __libc_start_main (/lib64/libc.so.6+0x26bcb)
#24 0x000000000049bd9a _start (/usr/bin/clang-8.0.1+0x49bd9a)
clang-8.0: error: unable to execute command: Segmentation fault (core dumped)
clang-8.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.1 (tags/RELEASE_801/final 366581)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

-- 
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/20190821/9b0d3c5f/attachment-0001.html>


More information about the llvm-bugs mailing list