public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppluzhnikov at google dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/60308] New: [4.9 Regression] std::deque leaks memory
Date: Fri, 21 Feb 2014 23:31:00 -0000	[thread overview]
Message-ID: <bug-60308-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60308

            Bug ID: 60308
           Summary: [4.9 Regression] std::deque leaks memory
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

std::deque currently leaks memory. Test case:

#include <deque>

int main()
{
  for (int j = 0; j < 10; ++j)
    {
      const int ia[] = { 2, 3, 1, 4, 2, 1, 3, 0 };
      std::deque<int> d(ia, ia + sizeof (ia) / sizeof (ia[0]));
    }
}

Using current trunk:
g++ (GCC) 4.9.0 20140221 (experimental)

g++ -g t.cc

Valgrind says:
 valgrind --leak-check=yes ./a.out


==24027== HEAP SUMMARY:
==24027==     in use at exit: 5,760 bytes in 20 blocks
==24027==   total heap usage: 40 allocs, 20 frees, 11,520 bytes allocated
==24027== 
==24027== 5,760 (640 direct, 5,120 indirect) bytes in 10 blocks are definitely
lost in loss record 2 of 2
==24027==    at 0x402F2A9: operator new(unsigned long)
(valgrind/coregrind/m_replacemalloc/vg_replace_malloc.c:298)
==24027==    by 0x401531: __gnu_cxx::new_allocator<int*>::allocate(unsigned
long, void const*) (/gcc-svn-install/include/c++/4.9.0/ext/new_allocator.h:104)
==24027==    by 0x4011C3: std::_Deque_base<int, std::allocator<int>
>::_M_allocate_map(unsigned long)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:549)
==24027==    by 0x400DDC: std::_Deque_base<int, std::allocator<int>
>::_M_initialize_map(unsigned long)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:594)
==24027==    by 0x400B54: std::_Deque_base<int, std::allocator<int>
>::_Deque_base(std::allocator<int> const&)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:470)
==24027==    by 0x400A27: std::deque<int, std::allocator<int> >::deque<int
const*>(int const*, int const*, std::allocator<int> const&)
(/gcc-svn-install/include/c++/4.9.0/bits/stl_deque.h:909)
==24027==    by 0x40094C: main (/tmp/t.cc:8)
==24027== 
==24027== LEAK SUMMARY:
==24027==    definitely lost: 640 bytes in 10 blocks
==24027==    indirectly lost: 5,120 bytes in 10 blocks
==24027==      possibly lost: 0 bytes in 0 blocks
==24027==    still reachable: 0 bytes in 0 blocks
==24027==         suppressed: 0 bytes in 0 blocks

Same test shows no leaks with gcc-4.8:
g++ (GCC) 4.8.3 20140109 (prerelease)


             reply	other threads:[~2014-02-21 23:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21 23:31 ppluzhnikov at google dot com [this message]
2014-02-22  0:03 ` [Bug libstdc++/60308] " glisse at gcc dot gnu.org
2014-02-22  0:14 ` glisse at gcc dot gnu.org
2014-02-22  0:20 ` glisse at gcc dot gnu.org
2014-02-22 10:24 ` glisse at gcc dot gnu.org
2014-02-22 10:28 ` glisse at gcc dot gnu.org
2014-02-22 13:56 ` rguenth at gcc dot gnu.org

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-60308-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).