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