public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/111728] New: C++ 20 coroutine segmentation fault in generic lambda @ 2023-10-08 17:03 yunus at ayar dot eu 2023-10-08 17:08 ` [Bug c++/111728] " pinskia at gcc dot gnu.org 2023-10-08 21:55 ` pinskia at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: yunus at ayar dot eu @ 2023-10-08 17:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111728 Bug ID: 111728 Summary: C++ 20 coroutine segmentation fault in generic lambda Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: yunus at ayar dot eu Target Milestone: --- Created attachment 56074 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56074&action=edit Compressed version of main.cpp.ii (~ 5.5 MB) from g++ -save-temps The following code causes a segmentation fault with ASIO 1.28, C++ 20's coroutines and evaluating of expressions inside a generic coroutine lambda. I tried to strip the test case as much as possible: ```cpp #include <asio.hpp> #include <cstddef> inline asio::awaitable<std::size_t> write_fields() { std::byte static_buffer[10]; co_await [&](auto field) -> asio::awaitable<int> { // Next line is not ok. if (0 == sizeof(static_buffer)); co_return 0; }(0); co_return 0; } int main() { static_cast<void>(write_fields()); } ``` My exact version: ```txt Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20230728/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.2.1 20230728 (Red Hat 13.2.1-1) (GCC) ``` I compiled the attached (main.cpp.ii) with: g++ main.cpp.ii -std=gnu++20 The following output was generated: ```txt /home/yunus/Projects/terraqtt/examples/main.cpp: In instantiation of ‘write_fields(write_fields()::_Z12write_fieldsv.Frame*)::<lambda(auto:50)> [with auto:50 = int]’: /home/yunus/Projects/terraqtt/examples/main.cpp:12:4: required from here /home/yunus/Projects/terraqtt/examples/main.cpp:12:3: internal compiler error: Segmentation fault 12 | }(0); | ^ Please submit a full bug report, with preprocessed source. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/cchUnOPu.out file, please attach this to your bugreport. ``` ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/111728] C++ 20 coroutine segmentation fault in generic lambda 2023-10-08 17:03 [Bug c++/111728] New: C++ 20 coroutine segmentation fault in generic lambda yunus at ayar dot eu @ 2023-10-08 17:08 ` pinskia at gcc dot gnu.org 2023-10-08 21:55 ` pinskia at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-10-08 17:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111728 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- [apinski@xeond2 upstream-gcc-git]$ ~/upstream-gcc/bin/gcc main.cpp.ii -std=gnu++20 /home/yunus/Projects/terraqtt/examples/main.cpp: In instantiation of ‘write_fields(write_fields()::_Z12write_fieldsv.Frame*)::<lambda(auto:50)> [with auto:50 = int]’: /home/yunus/Projects/terraqtt/examples/main.cpp:12:4: required from here /home/yunus/Projects/terraqtt/examples/main.cpp:12:3: internal compiler error: in rewrite_param_uses, at cp/coroutines.cc:3798 0x792564 rewrite_param_uses /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/coroutines.cc:3798 0x1613da4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11400 0x1613ef8 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11634 0xad2426 rewrite_param_uses /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/coroutines.cc:3786 0x1613da4 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11400 0xccfdcc cp_walk_subtrees(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*) /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/tree.cc:5591 0x1613e13 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11424 0x1613ef8 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11634 0x16144a3 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*)) /home/apinski/src/upstream-gcc-git/gcc/gcc/tree.cc:11516 0xaca338 coro_rewrite_function_body /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/coroutines.cc:4205 0xacf3f5 morph_fn_to_coro(tree_node*, tree_node**, tree_node**) /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/coroutines.cc:4485 0xb24b59 finish_function(bool) /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/decl.cc:18168 0xc700a6 instantiate_body /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/pt.cc:27110 0xc81bcb instantiate_decl(tree_node*, bool, bool) /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/pt.cc:27379 0xc92d5b instantiate_pending_templates(int) /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/pt.cc:27457 0xb3b2d1 c_parse_final_cleanups() /home/apinski/src/upstream-gcc-git/gcc/gcc/cp/decl2.cc:5060 0xd7bfc0 c_common_parse_file() /home/apinski/src/upstream-gcc-git/gcc/gcc/c-family/c-opts.cc:1296 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/111728] C++ 20 coroutine segmentation fault in generic lambda 2023-10-08 17:03 [Bug c++/111728] New: C++ 20 coroutine segmentation fault in generic lambda yunus at ayar dot eu 2023-10-08 17:08 ` [Bug c++/111728] " pinskia at gcc dot gnu.org @ 2023-10-08 21:55 ` pinskia at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-10-08 21:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111728 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-10-08 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Reduced to just using coroutine header file: ``` #include <coroutine> struct promise; struct coroutine : std::coroutine_handle<promise> { using promise_type = ::promise; bool await_ready() { return false; } void await_suspend( coroutine_handle h) {} int await_resume() {} }; struct promise { coroutine get_return_object() { return {coroutine::from_promise(*this)}; } std::suspend_always initial_suspend() noexcept { return {}; } std::suspend_always final_suspend() noexcept { return {}; } void return_void() {} void unhandled_exception() {} }; coroutine write_fields() { int static_buffer[10]; co_await [](auto) -> coroutine { if (sizeof(static_buffer)); co_return; }(0); } ``` Confirmed. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-08 21:55 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-10-08 17:03 [Bug c++/111728] New: C++ 20 coroutine segmentation fault in generic lambda yunus at ayar dot eu 2023-10-08 17:08 ` [Bug c++/111728] " pinskia at gcc dot gnu.org 2023-10-08 21:55 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).