From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B06FE3858410; Mon, 22 Jan 2024 10:11:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B06FE3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705918304; bh=MJAEyccv412EmN+wjQunLNTw7oigijLgss6mOS8xrWE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Zwnu8KHpO0ViwAomPx7ryE4hL45ygwvMV55hxHSFbLWJ/yaOcqLjARCpUR+PGVY2B oxDocuN+mEdsHo4bR0QXrCSS0/MC2hmS5XAXWbFRfwXMHd/TZL0/fzv9cqWZggGidm y8t76YACMhGiwnkCJ25kLJFwi1NC7qefZy7OMRbs= From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgcc/113401] Memory (resource) leak in -ftrampoline-impl=heap Date: Mon, 22 Jan 2024 10:11:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgcc X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113401 --- Comment #5 from Iain Sandoe --- (In reply to Florian Weimer from comment #4) > (In reply to Iain Sandoe from comment #3) > > for platforms using pthreads as the underlying resource, then perhaps w= e can > > do this without thread_atexit (which I do not see in many places) by us= ing > > pthread_cleanup_push () >=20 > The current implementation already uses the same underlying mechanism as > pthread_cleanup_push if building with -fexceptions. It does not solve the > leak because the outermost handler deliberately does not perform a full > deallocation of the thread state. hmm.. I'm slightly confused here. We certainly make the __gcc_nested_func_ptr_deleted () call a cleanup attac= hed to scope exits and certainly the last page of trampolines is not deallocated (as you note for the sake of avoiding churn in m-mapping). However, in the current code the only pthread-specific stuff I see (in, say config/i386/heap-trampoline.c) is specific to changing protections on the mapped pages. What I was thinking of is attaching a thread exit cleanup using pthread_cleanup_push() for platforms with pthreads but without Libc support= for _thread_atexit - I guess I'm missing something :)=