From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D43E23858C60; Wed, 17 Jan 2024 20:57:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D43E23858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705525048; bh=Mh1IVM1y2LrahpqdZAJb1nih7XXIi0rI5JZjdEWdp+g=; h=From:To:Subject:Date:From; b=IEGWn+rik3F+N+hz+uX1GAsUWYHgQNWKe/WvMVgjrYWQz6JUT93AKlub5WD5SKCw5 aaARpyKcB37ebdyeHawwY45ibHBjdgaoTKxdfufGYPmDriD9UB9eA6CvICEkI1Vo+4 UN8b+2Jf7hZINrEDV5Ihw3SDK3gW9DWb3crcliCc= From: "dboles.src at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113460] New: Segfault in __builtin_coro_destroy when using std::generator to concate ranges Date: Wed, 17 Jan 2024 20:57:28 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dboles.src at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113460 Bug ID: 113460 Summary: Segfault in __builtin_coro_destroy when using std::generator to concate ranges Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: dboles.src at gmail dot com Target Milestone: --- Created attachment 57120 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57120&action=3Dedit .ii, .o, .s files Using g++ (Debian 20240101-1) 14.0.0 20240101 (experimental) [master r14-6875-g3a7dd24eade]=20 Running this: ```cpp #include #include #include #include using namespace std; template [[nodiscard]] auto concat(Ranges&&... ranges) -> generator { (co_yield ranges::elements_of(ranges), ...); } auto main() -> int { auto const numbers1 =3D array{0}; auto const numbers2 =3D vector{0}; for (auto const _: concat(numbers1, numbers2) ) {} } ``` gives this: ```none Program received signal SIGSEGV, Segmentation fault. 0x0000000000403e8e in std::__n4861::coroutine_handle >::promise_type>::destroy (this=3D0x41c320) = at /usr/lib/gcc-snapshot/include/c++/14/coroutine:244 244 void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } (ins)(gdb) bt #0 0x0000000000403e8e in std::__n4861::coroutine_handle >::promise_type>::destroy (this=3D0x41c320) at /usr/lib/gcc-snapshot/include/c++/14/coroutine:244 #1 0x000000000040367c in std::generator >::~generator (this=3D0x41c320,=20 __in_chrg=3D) at /usr/lib/gcc-snapshot/include/c++/14/generator:700 #2 0x0000000000402cd0 in std::__gen::_Promise_erased::_Recursive_awaiter > >::~_Recursive_awaiter (this=3D0x41c320, __in_chrg=3D) at /usr/lib/gcc-snapshot/include/c++/14/generator:360 #3 0x0000000000401b8a in concat(_Z6concatITpTkNSt6ranges11input_rangeEJRKSt5arrayIiLm1EERKSt6vectorI= iSaIiEEEESt9generatorIiivEDpOT_.Frame *) (frame_ptr=3D0x41c2d0) at concatWC.cpp:13 #4 0x000000000040186f in operator()(_ZZNSt5__gen15_Promise_erasedIRKiE11yield_valueIRKSt6vectorIiSaI= iEESaISt4byteEEEDaNSt6ranges11elements_ofIT_T0_EEENKUlSt15allocator_arg_tSB= _N9__gnu_cxx17__normal_iteratorIPS1_S7_EESL_E_clESH_SB_SL_SL_.Frame *) (frame_ptr=3D0x41c3e0) at /usr/lib/gcc-snapshot/include/c++/14/generator:160 #5 0x000000000040409b in std::__n4861::coroutine_handle >::resume (this=3D0x41c2e0) at /usr/lib/gcc-snapshot/include/c++/14/coroutine:242 #6 0x0000000000403b62 in std::generator::_Iterator::_M_next (this=3D0x7fffffffdd58) at /usr/lib/gcc-snapshot/include/c++/14/generator:793 #7 0x00000000004032e6 in std::generator::_Iterator::operat= or++ (this=3D0x7fffffffdd58) at /usr/lib/gcc-snapshot/include/c++/14/generator:767 #8 0x00000000004012e4 in main () at concatWC.cpp:20 (ins)(gdb)=20 ``` Outputs of -freport-bug -save-temps are attached. Let me know if I can help with any more info. Thanks for implementing std::generator and all the other work on GCC and C+= +!=