From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) by sourceware.org (Postfix) with ESMTPS id 6E8563857830 for ; Sat, 5 Dec 2020 14:27:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6E8563857830 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ritter-vogt.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=fabian@ritter-vogt.de Received: from linux-e202.suse.de ([79.198.107.251]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mft3h-1kE7X73ZH7-00gHwY for ; Sat, 05 Dec 2020 15:27:52 +0100 From: Fabian Vogt To: newlib@sourceware.org Subject: impure_data never reclaimed Date: Sat, 05 Dec 2020 15:27:52 +0100 Message-ID: <3052588.mabWh2cJZc@linux-e202.suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:mvPCCFb4V5rskVy7fFSBLxkruZeekxU6JMgHipCQV5cxbgN9vVW 7bKXfJ3Fo7OX+rucLs6q52uBU++AXsxJK4htKm4n2H3qGPzByn8IXyk0KfxmjSVZ8q25TK1 VApda9vF/kgA/IdotLOeECKc+QiAxg2Bi+6Rz+NOcfpP2whlH95jVnie5h4rzCf3l07lYqh Yd0MSHeVwT02RfpkzZa1A== X-UI-Out-Filterresults: notjunk:1;V03:K0:opBHxXokeYQ=:nY3HWF774Jeg76+m3lK6z8 8K1kwADuWDF03Hobamq6pYYAbZ75tgWzzMWQ8NO+IzlwXLAY3/SyAzTzONOs7tb8xqwAwr93V LRKawgP1H75Uw3ijVKVfsMrZj2gopLxbv7RwEr6+LUdrruH5Eg8/RggV7uJ9yMXtZ/PMUpIlo W5lqnuaTKfbJ0CB8KunhXOYL3BhjVIzZxWOJAyAInM9aSjxqouCv4MRV3s3/E07I2ICiCLCJP eF2CdB0kWgygeonQd7MF931ZB0jrfeMxkxcbeEwcv2zOFLNZp7ryu+nrW7qIKY2KoLYuXwzCi AOHhtefoI1gSmBfgKjwLa1Nl/B/5oR9mXQNUkENqLuc/6qeaVpWIUajZ1cMjumQatVnwtS3ZH lYEjsjOuGJyo9yCLT46IBDZ3Kq4G7PM2g7iSBpCA67g95dTdcXtXG84BoaDKD7xCcYN6DP98v rzVol8igcQ== X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Dec 2020 14:27:56 -0000 Hi, I'm using newlib as libc on top of an OS which provides malloc and free. Threads aren't supported, but programs can be started and stopped. The used heap is shared between all programs, so leaked memory is lost forever. Thus it is important that after a clean exit, every allocation was properly freed. Currently this simple program leaks three allocations though: #include int main() { setbuf(stdout, NULL); // This would be properly freed, avoid distraction printf("This is 0.5 as a float: %f\n", 0.5f); } Those are from Balloc, which allocates a list also for later use. FWICT, _reclaim_reent takes care of freeing the list and its contents, but: - _reclaim_reent is never called for _impure_ptr (== &impure_data) - _reclaim_reent does nothing if impure_ptr is passed Is the OS glue code supposed to do something like this in _exit? struct _reent *global_reent = _impure_ptr; _impure_ptr = NULL; _reclaim_reent(global_reent); With that the leaks are gone, but it seems a bit odd to me. Thanks, Fabian