From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78429 invoked by alias); 16 Mar 2015 11:03:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 77693 invoked by uid 48); 16 Mar 2015 11:03:20 -0000 From: "mitya57 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65434] New: Memory leak in pool constructor Date: Mon, 16 Mar 2015 11:03:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mitya57 at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01569.txt.bz2 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).