From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120640 invoked by alias); 7 Apr 2017 21:58:01 -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 120579 invoked by uid 89); 7 Apr 2017 21:58:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:912, ashish, Ashish X-HELO: fllnx209.ext.ti.com Received: from fllnx209.ext.ti.com (HELO fllnx209.ext.ti.com) (198.47.19.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Apr 2017 21:57:58 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v37LvmFt011415 for ; Fri, 7 Apr 2017 16:57:48 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v37LvhG1019795 for ; Fri, 7 Apr 2017 16:57:43 -0500 Received: from DFLE08.ent.ti.com ([fe80::187f:8c86:2b7:ef9f]) by DLEE71.ent.ti.com ([fe80::4dce:5c82:1ad0:d462%28]) with mapi id 14.03.0294.000; Fri, 7 Apr 2017 16:57:43 -0500 From: "Kapania, Ashish" To: "newlib@sourceware.org" Subject: Possible bug in __sfp() libc routine Date: Fri, 07 Apr 2017 21:58: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/msg00286.txt.bz2 Hi All, In the __sfp() function in "libc/findfp.c" file, I see that if no free FILE= object is found, one is allocated and put on a list in the global re-entra= ncy structure (_GLOBAL_REENT). This seems like a bug to me. I believe the F= ILE object should be put on a list in the thread specific reentrancy struct= ure. If I create a thread, do a fopen, do a fwrite (invokes __sfp which in = turn allocates the FILE object), do a fclose and then delete the thread, th= e FILE object allocated by __sfp() is not freed. If a do this sequence repe= atedly, 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 structure, it does not get freed = when I delete the thread and run _reclaim_reent() on the local reentrancy s= tructure. Any thoughts ? Best, Ashish