[llvm-bugs] [Bug 49901] New: Compiler crash on simple coroutine code

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 8 13:08:04 PDT 2021


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

            Bug ID: 49901
           Summary: Compiler crash on simple coroutine code
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dascandy 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

Created attachment 24733
  --> https://bugs.llvm.org/attachment.cgi?id=24733&action=edit
Preprocessed source code, gzipped for size reasons

While writing a TLS library I was trying to wrap it into a HTTP client type
called SecureClient. Its constructor kept giving compiler crashes so I tried to
move it out to a separate file (hoping to circumvent any inlining errors) but
that had no effect. The code that causes the crash is the following lines:

future<SecureClient> SecureClient::create(tcp_socket sock,
Talos::TlsContextHandle& context) {
  tls client = co_await tls::createServer(context, std::move(sock), 0);
  co_return SecureClient(std::move(client));
}

The future type is a custom implementation but should not be *that* wrong. The
tls::createServer function returns a future<tls> so the co_await is there for
that; and then it co_returns a SecureClient move-constructed from that. This
used to be a oneliner but again, trying to circumvent the crash.

The future type and all other coroutine logic has been used in about 10k LoC
with no issues. I have no idea why this one crashes.

It crashes both on clang-10 and clang-11 for the Ubuntu 20.10 build of them.

Compiler output:

fatal error: error in backend: Cannot represent a difference across sections
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang++-11 -stdlib=libc++ -pthread -Wall -Wextra
-Wpedantic -Werror -std=c++2a -maes -mpclmul -g2 -fsanitize=address,undefined
-c -o build/clang11/obj/src/secure_connection.cpp.o src/secure_connection.cpp
-I./include -ICaligo/include -Imanto/include -Iserialize/include
-Italos/include 
1.      <eof> parser at end of file
2.      Code generation
 #0 0x00007f7fb065abbf llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa6bbf)
 #1 0x00007f7fb0658f20 llvm::sys::RunSignalHandlers()
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa4f20)
 #2 0x00007f7fb065a30d llvm::sys::CleanupOnSignal(unsigned long)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa630d)
 #3 0x00007f7fb05a27ca (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9ee7ca)
 #4 0x00007f7fb05a276b (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9ee76b)
 #5 0x00007f7fb06559ee (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xaa19ee)
 #6 0x0000000000412932 (/usr/lib/llvm-11/bin/clang+0x412932)
 #7 0x00007f7fb05ae82f llvm::report_fatal_error(llvm::Twine const&, bool)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9fa82f)
 #8 0x00007f7fb170d816 (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1b59816)
 #9 0x00007f7fb16f067c (/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1b3c67c)
#10 0x00007f7fb1705122 llvm::MCAssembler::handleFixup(llvm::MCAsmLayout const&,
llvm::MCFragment&, llvm::MCFixup const&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1b51122)
#11 0x00007f7fb1705572 llvm::MCAssembler::layout(llvm::MCAsmLayout&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1b51572)
#12 0x00007f7fb1705818 llvm::MCAssembler::Finish()
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1b51818)
#13 0x00007f7fb0d18fb7 llvm::AsmPrinter::doFinalization(llvm::Module&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x1164fb7)
#14 0x00007f7fb076f2d1 llvm::FPPassManager::doFinalization(llvm::Module&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbbb2d1)
#15 0x00007f7fb076a352 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0xbb6352)
#16 0x00007f7fb60d9916 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> >)
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1581916)
#17 0x00007f7fb6396d06 (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x183ed06)
#18 0x00007f7fb54620e3 clang::ParseAST(clang::Sema&, bool, bool)
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x90a0e3)
#19 0x00007f7fb6a2c198 clang::FrontendAction::Execute()
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1ed4198)
#20 0x00007f7fb69e2711
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1e8a711)
#21 0x00007f7fb6a922d0
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1f3a2d0)
#22 0x00000000004125ff cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/lib/llvm-11/bin/clang+0x4125ff)
#23 0x0000000000410a3e (/usr/lib/llvm-11/bin/clang+0x410a3e)
#24 0x00007f7fb6716a12 (/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1bbea12)
#25 0x00007f7fb05a274d
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/lib/x86_64-linux-gnu/libLLVM-11.so.1+0x9ee74d)
#26 0x00007f7fb6715f3f
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1bbdf3f)
#27 0x00007f7fb66edd5f
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1b95d5f)
#28 0x00007f7fb66edf07
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1b95f07)
#29 0x00007f7fb6701a6c
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/lib/x86_64-linux-gnu/libclang-cpp.so.11+0x1ba9a6c)
#30 0x00000000004104e3 main (/usr/lib/llvm-11/bin/clang+0x4104e3)
#31 0x00007f7faf6a5cb2 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x28cb2)
#32 0x000000000040dcde _start (/usr/lib/llvm-11/bin/clang+0x40dcde)

-- 
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/20210408/665274b4/attachment.html>


More information about the llvm-bugs mailing list