public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65434] New: Memory leak in pool constructor
@ 2015-03-16 11:03 mitya57 at gmail dot com
  2015-03-16 15:09 ` [Bug libstdc++/65434] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mitya57 at gmail dot com @ 2015-03-16 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65434
           Summary: Memory leak in pool constructor
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mitya57 at gmail dot com

Constructor of `pool' class in eh_alloc.c has the following code:

pool::pool()
  {
    // Allocate the arena - we could add a GLIBCXX_EH_ARENA_SIZE environment
    // to make this tunable.
    arena_size = (EMERGENCY_OBJ_SIZE * EMERGENCY_OBJ_COUNT
                  + EMERGENCY_OBJ_COUNT * sizeof (__cxa_dependent_exception));
    arena = (char *)malloc (arena_size);
    ....
  }

The memory allocated by `malloc (arena_size)' is never freed, because that
class does not have a destructor. This results in a memory leak. Valgrind
reports:

18,944 bytes in 1 blocks are still reachable in loss record 1 of 1
   at 0x40291CC: malloc (vg_replace_malloc.c:296)
   by 0x40D630A: pool (eh_alloc.cc:117)
   by 0x40D630A: __static_initialization_and_destruction_0 (eh_alloc.cc:244)
   by 0x40D630A: _GLOBAL__sub_I_eh_alloc.cc (eh_alloc.cc:307)
   by 0x400E86D: call_init.part.0 (dl-init.c:78)
   by 0x400E963: call_init (dl-init.c:36)
   by 0x400E963: _dl_init (dl-init.c:126)
   by 0x4000D3E: ??? (in /lib/i386-linux-gnu/ld-2.19.so)

This happens with the current gcc-5 snapshot, but did not happen with 4.9.

It was broken in revision 219988 (PR libstdc++/64535).


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-16 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 11:03 [Bug libstdc++/65434] New: Memory leak in pool constructor mitya57 at gmail dot com
2015-03-16 15:09 ` [Bug libstdc++/65434] " redi at gcc dot gnu.org
2015-03-16 15:33 ` mitya57 at gmail dot com
2015-03-16 16:00 ` redi at gcc dot gnu.org

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