From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128960 invoked by alias); 7 Apr 2017 22:02:55 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 128937 invoked by uid 89); 7 Apr 2017 22:02:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=U*newlib, sk:newlib@, newlib@sourceware.org, newlibsourcewareorg X-HELO: fllnx210.ext.ti.com Received: from fllnx210.ext.ti.com (HELO fllnx210.ext.ti.com) (198.47.19.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Apr 2017 22:02:53 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v37M2r8P032058 for ; Fri, 7 Apr 2017 17:02:53 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v37M2qSX026087 for ; Fri, 7 Apr 2017 17:02:53 -0500 Received: from DFLE08.ent.ti.com ([fe80::187f:8c86:2b7:ef9f]) by DLEE70.ent.ti.com ([fe80::c4c6:f618:54e7:ad11%28]) with mapi id 14.03.0294.000; Fri, 7 Apr 2017 17:02:52 -0500 From: "Kapania, Ashish" To: "newlib@sourceware.org" Subject: RE: Possible bug in __sfp() libc routine Date: Fri, 07 Apr 2017 22:02:00 -0000 Message-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00287.txt.bz2 Slight correction in my previous email. __sfp() is in "libc/stdio/findfp.c"= not "libc/findfp.c". > -----Original Message----- > From: Kapania, Ashish > Sent: Friday, April 07, 2017 2:58 PM > To: newlib@sourceware.org > Subject: Possible bug in __sfp() libc routine >=20 > Hi All, >=20 > In the __sfp() function in "libc/findfp.c" file, I see that if no free FI= LE object is > found, one is allocated and put on a list in the global re-entrancy struc= ture > (_GLOBAL_REENT). This seems like a bug to me. I believe the FILE object s= hould > be put on a list in the thread specific reentrancy structure. If I create= a thread, > do a fopen, do a fwrite (invokes __sfp which in turn allocates the FILE o= bject), > do a fclose and then delete the thread, the FILE object allocated by __sf= p() is not > freed. If a do this sequence repeatedly, I see memory keeps leaking until= my app > runs out of heap. I have a separate re-entrancy structure for each thread= but > because the FILE object is not in a list on the local re-entrancy structu= re, it does > not get freed when I delete the thread and run _reclaim_reent() on the lo= cal > reentrancy structure. >=20 > Any thoughts ? >=20 > Best, > Ashish