-
Notifications
You must be signed in to change notification settings - Fork 11.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang crashes when compiling coroutine on Windows #109253
Comments
Note that this is a regression between 17.0.6 and 19.1.0 (we skipped the 18 release, and hence don't know if it also reproduces there) |
Confirmed on Clang 20.0 (trunk): https://godbolt.org/z/YxKseEGzv namespace std {
template <class _Ret>
struct coroutine_traits : _Ret {};
template <class = void>
struct coroutine_handle {
static coroutine_handle from_address(void *);
operator coroutine_handle<>();
};
struct suspend_always {
int await_ready();
void await_suspend(coroutine_handle<>);
void await_resume();
};
struct ostream;
template <class _Ty2>
struct _Compressed_pair {
_Ty2 _Myval2;
};
struct default_delete {
void operator()(int *_Ptr) {
delete _Ptr;
}
};
struct _Get_deleter_pointer_type {
using type = int *;
};
struct unique_ptr {
using pointer = _Get_deleter_pointer_type::type;
~unique_ptr() {
default_delete __trans_tmp_1;
__trans_tmp_1(_Mypair._Myval2);
}
_Compressed_pair<pointer> _Mypair;
};
template <class>
unique_ptr make_unique();
template <class _Traits>
void operator<<(_Traits &, int);
extern ostream cerr;
} // namespace std
using namespace std;
struct AsyncFunctionPromise {
auto initial_suspend() {
return suspend_always();
}
struct FinalAwaitable {
int await_ready() noexcept;
void await_resume() noexcept;
template <typename Promise>
void await_suspend(Promise) noexcept;
};
auto final_suspend() noexcept {
return FinalAwaitable();
}
auto get_return_object() {
return coroutine_handle<AsyncFunctionPromise>();
}
void return_value(int);
void unhandled_exception();
};
struct AsyncFunction {
using promise_type = AsyncFunctionPromise;
using Handle = coroutine_handle<promise_type>;
AsyncFunction(Handle);
};
AsyncFunction asyncInit() {
try {
unique_ptr mem;
try {
mem = make_unique<int>();
} catch (int) {
}
cerr << 0;
} catch (int) {
}
co_return 0;
} Clang 20.0 crash:
|
Well, the reduction above reproduces all the way to Clang 14, which appears to be the first supporting C++20 coroutines. |
@llvm/issue-subscribers-coroutines Author: Florian Scheibner (flode) We observed a crash on Windows in coroutine code after upgrading to 19.1. Needs at least /O1. Compiling the attached repro code, crashes. Clang-cl 19.1
|
Well, the original reproducer crashes Clang 17, too. I guess something has changed in MS STL's |
This looks like a bad interaction between C++ coroutines and C++ EH under the MSVC ABI. There are at least a few tests for this in the LLVM coroutine test suite, so there is some hope that this can be made to work without too much effort:
|
We observed a crash on Windows in coroutine code after upgrading to 19.1. Needs at least /O1.
Compiling the attached repro code, crashes.
Clang-cl 19.1
msvc-14.39.33519
windows sdk 10.0.22621.0
clangcl19windowscoroutinecrash.zip
The text was updated successfully, but these errors were encountered: