From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C877D3858D28; Mon, 17 Oct 2022 08:31:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C877D3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665995480; bh=y1M5kfEALNs+eTA17LGvGd3OBziidRFWU2s9UIBjeyE=; h=From:To:Subject:Date:From; b=ZokS52EzKtvht5Aq6jJdeil7ukf+rhOpFKpBPKGwkPVocr/saj2EMcc47lJrpK64P AFBU+/KRmBPEhXMli6aYFwXVujj/MmeFzTxIge3dGQixDbzBsOC8u05OqFgUHX1rba S31D33XeE0nAclMK4RohzEIVWfPRBQ0Mvj7qwUcU= From: "hodges.r at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107288] New: Double-free of temporaries created in statement following co_await Date: Mon, 17 Oct 2022 08:31:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hodges.r 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 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=3D107288 Bug ID: 107288 Summary: Double-free of temporaries created in statement following co_await Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hodges.r at gmail dot com Target Milestone: --- Compiling the attached program results in a call to abort() due to a double free of the temporary `foo`. The problem is in this statement: ``` co_await chan.async_send({}, foo { .s =3D "hello world", .i =3D 1 }, asio::redirect_error(asio::use_awaitable, ec)); ``` Modifying the code to remove the temporary works around the issue: ``` auto f =3D foo { .s =3D "hello world", .i =3D 1 }; co_await chan.async_send({}, std::move(f), asio::redirect_error(asio::use_awaitable, ec)); ``` Compiler command line: ``` $ /usr/bin/c++ -DBOOST_SYSTEM_NO_LIB -DBOOST_THREAD_NO_LIB -DBOOST_URL_NO_L= IB=3D1 -DBOOST_URL_STATIC_LINK=3D1 -DCPP_JWT_USE_VENDORED_NLOHMANN_JSON -I/home/rhodges/github/Power-Trade/riskmon/apps/scratch2 -I/home/rhodges/github/Power-Trade/riskmon/build/apps/scratch2 -I/home/rhodges/github/Power-Trade/riskmon/libs -I/home/rhodges/github/Power-Trade/riskmon/build/_deps/boost_url-src/include -isystem /home/rhodges/work/gcc/include -g -save-temps -std=3Dgnu++20 scrat= ch2 /home/rhodges/github/Power-Trade/riskmon/apps/scratch2/main.cpp ``` Result of running the program: ``` $ ./scratch2=20 munmap_chunk(): invalid pointer Aborted (core dumped) ```=