From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AF3CE3858C74; Thu, 15 Sep 2022 08:18:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF3CE3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663229887; bh=qlUimJETP6p6TQxQzl3nUcru/A10YCph8ORf1BKobT4=; h=From:To:Subject:Date:From; b=k/MICBOV/rOCw5tUlFFyWMOprAhL+wjuCw5ZaXTpuVMdFi/poCWe7bj/DQ4aUBCy5 7TXznk0X2ffnC63ybNnOkRE0gZU9/FCIIEg78QMdHy6QJTvEHDRNXY4dz3QTjDBemo RnX8pt+lG6DtXnK9Mtw29xa5D/F/2rvHwesMeHtU= From: "iam at datacompboy dot ru" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgcc/106949] New: Memory leak using VLA with -fsplit-stack Date: Thu, 15 Sep 2022 08:18:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgcc X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iam at datacompboy dot ru 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=3D106949 Bug ID: 106949 Summary: Memory leak using VLA with -fsplit-stack Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcc Assignee: unassigned at gcc dot gnu.org Reporter: iam at datacompboy dot ru Target Milestone: --- Created attachment 53575 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53575&action=3Dedit minimal repro case Having a function with couple of VLA arrays enough to cause a memory leak. If you run the function in a loop, memory leak only grows. ``` $ gcc -fsplit-stack -g b.c && valgrind ./a.out =3D=3D6861=3D=3D HEAP SUMMARY: =3D=3D6861=3D=3D in use at exit: 20,040 bytes in 2 blocks =3D=3D6861=3D=3D total heap usage: 2 allocs, 0 frees, 20,040 bytes alloca= ted =3D=3D6861=3D=3D =3D=3D6861=3D=3D LEAK SUMMARY: =3D=3D6861=3D=3D definitely lost: 24 bytes in 1 blocks =3D=3D6861=3D=3D indirectly lost: 20,016 bytes in 1 blocks ``` With a loop running function 10k times: ``` $ gcc -fsplit-stack -g c.c && valgrind ./a.out =3D=3D6931=3D=3D HEAP SUMMARY: =3D=3D6931=3D=3D in use at exit: 569,801,800 bytes in 32,162 blocks =3D=3D6931=3D=3D total heap usage: 32,162 allocs, 0 frees, 569,801,800 by= tes allocated =3D=3D6931=3D=3D =3D=3D6931=3D=3D LEAK SUMMARY: =3D=3D6931=3D=3D definitely lost: 385,944 bytes in 16,081 blocks =3D=3D6931=3D=3D indirectly lost: 569,121,904 bytes in 16,072 blocks =3D=3D6931=3D=3D possibly lost: 293,952 bytes in 9 blocks ```=