[llvm-bugs] [Bug 40979] New: [coroutines] ICE when co_await appears in unreachable code after catch-block

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 6 09:09:38 PST 2019


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

            Bug ID: 40979
           Summary: [coroutines] ICE when co_await appears in unreachable
                    code after catch-block
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lewissbaker at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

If I compile a coroutine that contains a try/catch and the body throws an
exception that is caught by the catch-block and the catch-block then performs a
co_return.

If the user then places a co_await expression after the catch block then this
unreachable co_await expression seems to cause an ICE.

https://godbolt.org/z/mUWACH

Compile the following with '-std=c++2a -stdlib=libc++'

#include <experimental/coroutine>

using namespace std::experimental;

struct task {
    struct promise_type {
        suspend_never initial_suspend();
        suspend_never final_suspend();
        task get_return_object();
        void return_void();
        void unhandled_exception();
    };
};

struct awaitable {
    bool await_ready();
    void await_suspend(coroutine_handle<>);
    void await_resume();
};

struct X {};

awaitable foo();

task example() {
    try {
        throw X{};
    } catch (const X& e) {
        co_return;
    }
    co_await foo();
}

Causes the following output:


#1 with x86-64 clang (trunk)
Call parameter type does not match function signature!

Stack dump:

0.      Program arguments:
/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9 -cc1 -triple
x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name example.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 -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -coverage-notes-file
/tmp/compiler-explorer-compiler11926-52-pl0bb1.orpd/output.gcno -resource-dir
/opt/compiler-explorer/clang-trunk-20190306/lib/clang/9.0.0 -internal-isystem
/opt/compiler-explorer/clang-trunk-20190306/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/opt/compiler-explorer/clang-trunk-20190306/lib/clang/9.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-std=c++2a -fdeprecated-macro -fdebug-compilation-dir
/tmp/compiler-explorer-compiler11926-52-pl0bb1.orpd -ferror-limit 19
-fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -o
/tmp/compiler-explorer-compiler11926-52-pl0bb1.orpd/output.s -x c++ <source>
-faddrsig 

1.      <eof> parser at end of file

2.      Per-module optimization passes

3.      Running pass 'CallGraph Pass Manager' on module '<source>'.

4.      Running pass 'Module Verifier' on function '@_Z7examplev.resume'

 #0 0x000055b5f83684ca llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x254f4ca)

 #1 0x000055b5f83664a4 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x254d4a4)

 #2 0x000055b5f83665e2 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x254d5e2)

 #3 0x00007fbe9fb67890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)

 #4 0x000055b5f7cc921e (anonymous namespace)::TypePrinting::print(llvm::Type*,
llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1eb021e)

 #5 0x000055b5f7cce3af llvm::Value::printAsOperand(llvm::raw_ostream&, bool,
llvm::ModuleSlotTracker&) const
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1eb53af)

 #6 0x000055b5f7dd34d5 llvm::VerifierSupport::Write(llvm::Value const&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1fba4d5)

 #7 0x000055b5f7de7dd0 (anonymous
namespace)::Verifier::visitCallBase(llvm::CallBase&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1fcedd0)

 #8 0x000055b5f7ded5a3 (anonymous namespace)::Verifier::verify(llvm::Function
const&) (.part.1280)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1fd45a3)

 #9 0x000055b5f7deff85 (anonymous
namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1fd6f85)

#10 0x000055b5f7d8e739 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1f75739)

#11 0x000055b5f7d8e84c
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1f7584c)

#12 0x000055b5f7d8eb32 llvm::legacy::FunctionPassManager::run(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1f75b32)

#13 0x000055b5f8fe638d postSplitCleanup(llvm::Function&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x31cd38d)

#14 0x000055b5f8fe6f9b (anonymous
namespace)::CoroSplit::runOnSCC(llvm::CallGraphSCC&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x31cdf9b)

#15 0x000055b5f77a5487 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x198c487)

#16 0x000055b5f7d8dae9 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x1f74ae9)

#17 0x000055b5f8579dc1 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x2760dc1)

#18 0x000055b5f857bbf6 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x2762bf6)

#19 0x000055b5f8fd3a4c
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x31baa4c)

#20 0x000055b5f9758e19 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x393fe19)

#21 0x000055b5f8fd2947 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x31b9947)

#22 0x000055b5f89fbdd6 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x2be2dd6)

#23 0x000055b5f89beecc
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x2ba5ecc)

#24 0x000055b5f8ab7773
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0x2c9e773)

#25 0x000055b5f6a1d378 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0xc04378)

#26 0x000055b5f697771d main
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0xb5e71d)

#27 0x00007fbe9ea25b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)

#28 0x000055b5f6a1a66a _start
(/opt/compiler-explorer/clang-trunk-20190306/bin/clang-9+0xc0166a)

clang-9: error: unable to execute command: Segmentation fault (core dumped)

clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)

Compiler returned: 254

-- 
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/20190306/f6fb736f/attachment-0001.html>


More information about the llvm-bugs mailing list