<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clang crashes on passing a coro param to operator new"
href="https://bugs.llvm.org/show_bug.cgi?id=36521">36521</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang crashes on passing a coro param to operator new
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Transformation Utilities
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>superjoe30@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19964" name="attach_19964" title="test.sh">attachment 19964</a> <a href="attachment.cgi?id=19964&action=edit" title="test.sh">[details]</a></span>
test.sh
#include <experimental/coroutine>
struct Allocator {
void *(*alloc)(unsigned long x);
void (*free)(void *ptr);
};
struct ResumableThing {
struct promise_type {
void *operator new(unsigned long size, Allocator *allocator) {
return allocator->alloc(size);
}
auto initial_suspend() { return std::experimental::suspend_never{}; }
auto final_suspend() { return std::experimental::suspend_never{}; }
void return_void() {}
ResumableThing get_return_object() {
return
ResumableThing(std::experimental::coroutine_handle<promise_type>::from_promise(*this));
}
auto unhandled_exception() { abort(); }
};
std::experimental::coroutine_handle<promise_type> m_coroutine = nullptr;
ResumableThing() = default;
ResumableThing(ResumableThing const &) = default;
explicit ResumableThing(std::experimental::coroutine_handle<promise_type>
coroutine) :
m_coroutine(coroutine) {}
};
static char some_bytes[2000];
static void *global_alloc(unsigned long x) {
return &some_bytes[0];
}
static void global_free(void *ptr) { }
static Allocator allocator = { global_alloc, global_free };
static ResumableThing foo(Allocator *a) {
co_return;
}
void entry() {
auto p = foo(&allocator);
}
$ ~/llvm6-release/bin/clang -c -fcoroutines-ts test.cpp -stdlib=libc++
-std=c++1z
test.cpp:36:23: error: no matching function for call to 'operator new'
static ResumableThing foo(Allocator *a) {
^
test.cpp:10:15: note: candidate function not viable: requires 2 arguments, but
1 was provided
void *operator new(unsigned long size, Allocator *allocator) {
^
#0 0x0000000001f7841a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/andy/llvm6-release/bin/clang-6.0+0x1f7841a)
#1 0x0000000001f7656e llvm::sys::RunSignalHandlers()
(/home/andy/llvm6-release/bin/clang-6.0+0x1f7656e)
#2 0x0000000001f76692 SignalHandler(int)
(/home/andy/llvm6-release/bin/clang-6.0+0x1f76692)
#3 0x00007fb2fe531dd0 __restore_rt
(/nix/store/z0b60y0khix9jb74ka56gw7b7n9s8awx-glibc-2.26-131/lib/libpthread.so.0+0x11dd0)
#4 0x0000000002e7f527 clang::CoroutineStmtBuilder::makeNewAndDeleteExpr()
(/home/andy/llvm6-release/bin/clang-6.0+0x2e7f527)
#5 0x0000000002e803cc clang::CoroutineStmtBuilder::buildDependentStatements()
(/home/andy/llvm6-release/bin/clang-6.0+0x2e803cc)
#6 0x0000000002e80416 clang::CoroutineStmtBuilder::buildStatements()
(/home/andy/llvm6-release/bin/clang-6.0+0x2e80416)
#7 0x0000000002e80780
clang::Sema::CheckCompletedCoroutineBody(clang::FunctionDecl*, clang::Stmt*&)
(/home/andy/llvm6-release/bin/clang-6.0+0x2e80780)
#8 0x0000000002ea34ae clang::Sema::ActOnFinishFunctionBody(clang::Decl*,
clang::Stmt*, bool) (/home/andy/llvm6-release/bin/clang-6.0+0x2ea34ae)
#9 0x0000000002c5e0a4 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/home/andy/llvm6-release/bin/clang-6.0+0x2c5e0a4)
#10 0x0000000002bced0b
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bced0b)
#11 0x0000000002bf0053 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bf0053)
#12 0x0000000002bc9270
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bc9270)
#13 0x0000000002bc99d1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) [clone .part.160]
(/home/andy/llvm6-release/bin/clang-6.0+0x2bc99d1)
#14 0x0000000002bc99ff
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bc99ff)
#15 0x0000000002bd0e34
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/home/andy/llvm6-release/bin/clang-6.0+0x2bd0e34)
#16 0x0000000002bd18be
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bd18be)
#17 0x0000000002bc5d0b clang::ParseAST(clang::Sema&, bool, bool)
(/home/andy/llvm6-release/bin/clang-6.0+0x2bc5d0b)
#18 0x000000000280f961 clang::CodeGenAction::ExecuteAction()
(/home/andy/llvm6-release/bin/clang-6.0+0x280f961)
#19 0x00000000024e8fb6 clang::FrontendAction::Execute()
(/home/andy/llvm6-release/bin/clang-6.0+0x24e8fb6)
#20 0x00000000024b2a56
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/andy/llvm6-release/bin/clang-6.0+0x24b2a56)
#21 0x000000000257a20b
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/andy/llvm6-release/bin/clang-6.0+0x257a20b)
#22 0x0000000000a53358 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/andy/llvm6-release/bin/clang-6.0+0xa53358)
#23 0x00000000009ca7f0 main (/home/andy/llvm6-release/bin/clang-6.0+0x9ca7f0)
#24 0x00007fb2fd28c020 __libc_start_main
(/nix/store/z0b60y0khix9jb74ka56gw7b7n9s8awx-glibc-2.26-131/lib/libc.so.6+0x21020)
#25 0x0000000000a50a8a _start
/build/glibc-2.26/csu/../sysdeps/x86_64/start.S:122:0
Stack dump:
0. Program arguments: /home/andy/llvm6-release/bin/clang-6.0 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name test.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/andy/tmp/test.gcno -resource-dir /home/andy/llvm6-release/lib/clang/6.0.0
-I /nix/store/aficfjm81yiklfygq03y87vp5k8h28mr-glibc-2.26-131-dev/include
-internal-isystem /home/andy/llvm6-release/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/home/andy/llvm6-release/lib/clang/6.0.0/include -internal-externc-isystem
/include -internal-externc-isystem /usr/include -std=c++1z -fdeprecated-macro
-fdebug-compilation-dir /home/andy/tmp -ferror-limit 19 -fmessage-length 107
-fcoroutines-ts -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o test.o -x c++ test.cpp
1. test.cpp:40:1: current parser token 'void'
2. test.cpp:36:41: parsing function body 'foo'
clang-6.0: error: unable to execute command: Segmentation fault (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0 (branches/release_60 324533) (llvm/branches/release_60
324525)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/andy/llvm6-release/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to and include the
crash backtrace, preprocessed source, and associated run script.
clang-6.0: note: diagnostic msg:</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>