From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B0AB53858283 for ; Thu, 16 Nov 2023 09:15:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B0AB53858283 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B0AB53858283 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700126127; cv=none; b=Z6jziendbyAodQeqyzEI9zINbl6sB6IcBQa+5ip0peoH/PbwyZ9naOBrUkhx/vT72RwDTEER23joHC3jJ2Gr2N6XB5irLqdNSpkfja1obNqScY3sTqC/eTYT8vzQlW8sD/KUaeA6E6mxxJTerTpDfi4kWKYRGGeQgdqX0YNHAnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700126127; c=relaxed/simple; bh=eeoov2D4fCVy6wODAcllqin5G3BbkDlHzNNAMx8YqfQ=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=tzkPongCMy7D6eakfG7jZQIkXsi4+Vz18ZhevB2w+yfZrGV7LYqdOzlLY24SKao+U+oxtWnCkwFaAwMB1febXir0JZKu9FfKE7Sx2ZwqJOoIBXpp8A75OgEXJHItxgyhzlQngbyy/pp40FTEBxpG2tTAljF2GuDchmYA8EYj4H0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700126125; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=qEBAzLHUPW95pQvEc/TpzU3CQLPj18JjP6Groiqc7gs=; b=RTbUD331cxy7HbQsi5suPljQLLJFf0nPT69xqcCpY0ek3FF9yfWmAS6iNHbvFdmuCCb+Ec F0TGioM3rpw8Vkf34Pg95BEFXLa2SK+fjt8suWA6lhEiJ559V1BybXfwPV6N1DwEibrXf7 hMefpiyQVQxWGs16qWnX1IIsBo/b/qg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-XNggn2KLMrWB7YSHouiR0w-1; Thu, 16 Nov 2023 04:15:23 -0500 X-MC-Unique: XNggn2KLMrWB7YSHouiR0w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 875223C108C5 for ; Thu, 16 Nov 2023 09:15:23 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.192.128]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6559E1121307 for ; Thu, 16 Nov 2023 09:15:23 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 0E41FA80C84; Thu, 16 Nov 2023 10:15:22 +0100 (CET) Date: Thu, 16 Nov 2023 10:15:22 +0100 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH] Reclaim _REENT_MP_P5S in _reclaim_reent Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20231116011215.21144-1-chrisj@rtems.org> MIME-Version: 1.0 In-Reply-To: <20231116011215.21144-1-chrisj@rtems.org> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Nov 16 12:12, chrisj@rtems.org wrote: > From: Chris Johns > > The change fixes a memory leak in threads that clean up using > _reclaim_reent. > > RTEMS: Closes #4967 > --- > newlib/libc/reent/reent.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/newlib/libc/reent/reent.c b/newlib/libc/reent/reent.c > index db80ca06e..6bb271b9a 100644 > --- a/newlib/libc/reent/reent.c > +++ b/newlib/libc/reent/reent.c > @@ -59,6 +59,17 @@ _reclaim_reent (struct _reent *ptr) > } > if (_REENT_MP_RESULT(ptr)) > _free_r (ptr, _REENT_MP_RESULT(ptr)); > + if (_REENT_MP_P5S(ptr)) > + { > + struct _Bigint *thisone, *nextone; > + nextone = _REENT_MP_P5S(ptr); > + while (nextone) > + { > + thisone = nextone; > + nextone = nextone->_next; > + _free_r (ptr, thisone); > + } > + } The p5s data is allocated using Balloc, so the pointers are in freelist and should already be free'd at this point, starting at line 42. Please explain what happens and why free'ing the freelist is not sufficient in this case, preferredly as part of the commit message. Thanks, Corinna