[llvm-bugs] [Bug 41909] New: Compiler crash when compiling generic lambda coroutine

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 16 07:37:00 PDT 2019


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

            Bug ID: 41909
           Summary: Compiler crash when compiling generic lambda coroutine
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: adi at thingdust.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 21955
  --> https://bugs.llvm.org/attachment.cgi?id=21955&action=edit
reproducing file

$ /usr/bin/clang++ -std=c++17 -fcoroutines-ts -c reproducer.cpp 
Stack dump:
0.      Program arguments: /usr/lib/llvm-8/bin/clang -cc1 -triple
x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name reproducer.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
/home/thingdust/workdir/tmp/bug/reproducer.gcno -nostdinc++ -resource-dir
/usr/lib/llvm-8/lib/clang/8.0.0 -isystem /usr/llvm/asan/include/c++/v1/
-internal-isystem /usr/local/include -internal-isystem
/usr/lib/llvm-8/lib/clang/8.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -std=c++17 -fdeprecated-macro
-fdebug-compilation-dir /home/thingdust/workdir/tmp/bug -ferror-limit 19
-fmessage-length 424 -fcoroutines-ts -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o reproducer.o -x
c++ reproducer.cpp -faddrsig 
1.      <eof> parser at end of file
2.      reproducer.cpp:28:10: instantiating function definition
'Test_Newtask<DefaultCoroConfig>::test_async'
 #0 0x00007f1fedad7dff llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib/x86_64-linux-gnu/libLLVM-8.so.1+0x975dff)
 #1 0x00007f1fedad6250 llvm::sys::RunSignalHandlers()
(/lib/x86_64-linux-gnu/libLLVM-8.so.1+0x974250)
 #2 0x00007f1fedad8208 (/lib/x86_64-linux-gnu/libLLVM-8.so.1+0x976208)
 #3 0x00007f1ff0db6f40 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x13f40)
 #4 0x00000000015d0934 clang::Sema::LookupQualifiedName(clang::LookupResult&,
clang::DeclContext*, bool) (/usr/lib/llvm-8/bin/clang+0x15d0934)
 #5 0x000000000135a892 (/usr/lib/llvm-8/bin/clang+0x135a892)
 #6 0x00000000013580b6 clang::CoroutineStmtBuilder::makeOnException()
(/usr/lib/llvm-8/bin/clang+0x13580b6)
 #7 0x0000000001358029 clang::CoroutineStmtBuilder::buildDependentStatements()
(/usr/lib/llvm-8/bin/clang+0x1358029)
 #8 0x000000000178cd51 (/usr/lib/llvm-8/bin/clang+0x178cd51)
 #9 0x00000000017885d2 (/usr/lib/llvm-8/bin/clang+0x17885d2)
#10 0x0000000001777ec3 (/usr/lib/llvm-8/bin/clang+0x1777ec3)
#11 0x0000000001775b4c clang::Sema::SubstInitializer(clang::Expr*,
clang::MultiLevelTemplateArgumentList const&, bool)
(/usr/lib/llvm-8/bin/clang+0x1775b4c)
#12 0x00000000017a6363
clang::Sema::InstantiateVariableInitializer(clang::VarDecl*, clang::VarDecl*,
clang::MultiLevelTemplateArgumentList const&)
(/usr/lib/llvm-8/bin/clang+0x17a6363)
#13 0x0000000001798a7d clang::Sema::BuildVariableInstantiation(clang::VarDecl*,
clang::VarDecl*, clang::MultiLevelTemplateArgumentList const&,
llvm::SmallVector<clang::Sema::LateInstantiatedAttribute, 16u>*,
clang::DeclContext*, clang::LocalInstantiationScope*, bool)
(/usr/lib/llvm-8/bin/clang+0x1798a7d)
#14 0x00000000017983c1
clang::TemplateDeclInstantiator::VisitVarDecl(clang::VarDecl*, bool,
llvm::ArrayRef<clang::BindingDecl*>*) (/usr/lib/llvm-8/bin/clang+0x17983c1)
#15 0x00000000017a3b10 clang::Sema::SubstDecl(clang::Decl*,
clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&)
(/usr/lib/llvm-8/bin/clang+0x17a3b10)
#16 0x000000000178ce88 (/usr/lib/llvm-8/bin/clang+0x178ce88)
#17 0x0000000001788e36 (/usr/lib/llvm-8/bin/clang+0x1788e36)
#18 0x000000000177726f clang::Sema::SubstStmt(clang::Stmt*,
clang::MultiLevelTemplateArgumentList const&)
(/usr/lib/llvm-8/bin/clang+0x177726f)
#19 0x00000000017a530f
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool) (/usr/lib/llvm-8/bin/clang+0x17a530f)
#20 0x00000000017a7aaf clang::Sema::PerformPendingInstantiations(bool)
(/usr/lib/llvm-8/bin/clang+0x17a7aaf)
#21 0x00000000012acc96 clang::Sema::ActOnEndOfTranslationUnit()
(/usr/lib/llvm-8/bin/clang+0x12acc96)
#22 0x00000000011e0322
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/lib/llvm-8/bin/clang+0x11e0322)
#23 0x00000000011dbcb6 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/lib/llvm-8/bin/clang+0x11dbcb6)
#24 0x0000000000ae75cf clang::FrontendAction::Execute()
(/usr/lib/llvm-8/bin/clang+0xae75cf)
#25 0x0000000000aa51c8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/lib/llvm-8/bin/clang+0xaa51c8)
#26 0x0000000000b6da56
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/lib/llvm-8/bin/clang+0xb6da56)
#27 0x00000000006a2bfa cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-8/bin/clang+0x6a2bfa)
#28 0x00000000006a10f6 main (/usr/lib/llvm-8/bin/clang+0x6a10f6)
#29 0x00007f1fecc54b6b __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x26b6b)
#30 0x000000000069e7ea _start (/usr/lib/llvm-8/bin/clang+0x69e7ea)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.0-1ubuntu1 (tags/RELEASE_800/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg: 
********************

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

********************


Simple reproducer:
#include <experimental/coroutine>

struct DefaultCoroConfig {};

struct task {};

template <typename... Args>
struct std::experimental::coroutine_traits<task, Args...> {
    struct promise_type {
        std::experimental::suspend_never initial_suspend() {
            return {};
        }
        std::experimental::suspend_never final_suspend() {
            return {};
        }
        void return_void() {
        }
        task get_return_object() {
            return {};
        }
        void unhandled_exception() {
        }
    };
};

template <typename CoroConfig>
struct Test_Newtask {
    void test_async() {
        // this would work:
        // auto local_sum = [](std::function<void(int)> set) -> task {
        auto local_sum = [](auto set) -> task {
            set(5);
            co_return;
        };
        (void)local_sum;
    }
};

void foo();
void foo() {
    Test_Newtask<DefaultCoroConfig> a;
    a.test_async();
}

-- 
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/20190516/e7b6615f/attachment-0001.html>


More information about the llvm-bugs mailing list