public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iam at datacompboy dot ru" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-106949-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106949

            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=53575&action=edit
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
==6861== HEAP SUMMARY:
==6861==     in use at exit: 20,040 bytes in 2 blocks
==6861==   total heap usage: 2 allocs, 0 frees, 20,040 bytes allocated
==6861==
==6861== LEAK SUMMARY:
==6861==    definitely lost: 24 bytes in 1 blocks
==6861==    indirectly lost: 20,016 bytes in 1 blocks
```

With a loop running function 10k times:
```
$ gcc -fsplit-stack -g c.c && valgrind ./a.out
==6931== HEAP SUMMARY:
==6931==     in use at exit: 569,801,800 bytes in 32,162 blocks
==6931==   total heap usage: 32,162 allocs, 0 frees, 569,801,800 bytes
allocated
==6931==
==6931== LEAK SUMMARY:
==6931==    definitely lost: 385,944 bytes in 16,081 blocks
==6931==    indirectly lost: 569,121,904 bytes in 16,072 blocks
==6931==      possibly lost: 293,952 bytes in 9 blocks
```

             reply	other threads:[~2022-09-15  8:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  8:18 iam at datacompboy dot ru [this message]
2022-09-15  8:21 ` [Bug libgcc/106949] " iam at datacompboy dot ru
2022-10-03 12:25 ` iam at datacompboy dot ru
2022-10-04  0:22 ` ian at airs dot com
2022-10-04 12:16 ` [Bug libgcc/106949] Memory leak using VLA/alloca " iam at datacompboy dot ru
2022-10-04 15:50 ` iam at datacompboy dot ru

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106949-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).