Re: [PATCH] Fix stdio memory leaks with _REENT_SMALL + _LITE_EXIT
Volodymyr Medvid <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <CAJfDXEpCy0n-eJ4hZLAAZ529NyYbotphA22ViXDGpBvCQz8tow@mail.gmail.com> |
On Tue, 12 Apr 2022 18:10:38 +0200 Sebastian Huber <[email protected]> wrote: > This is definitely not the right way to address this issue. > > Why don't you use the _REENT_GLOBAL_STDIO_STREAMS Newlib > configuration option? Thanks for the suggestion - I was able to verify the memory leak goes away once newlib-nano is reconfigured with "--enable-newlib-global-stdio-streams". I also see you originally submitted commit 668a4c8722090fffd10869dbb15b879651c1370d that was later extended to also apply to _REENT_SMALL (b7520b14d5fe175d9bc60266700fb7b988600a84). I filed a ticket https://bugs.linaro.org/show_bug.cgi?id=5841 to enable global stdio streams for standard newlib-nano provided with GNU Arm Embedded toolchain binary package. > This patch would break at least RTEMS. > Sorry, I have no way to validate this on any platform except Arm Cortex-M + FreeRTOS. Also, the current test suite is not capable of catching issues with stdio reentrancy. I understand there are lot of platform/OS-specific stdio implementations, some of them may rely on configure flags like "--enable-newlib-reent-small" or "--enable-lite-exit" to meet the memory and performance constraints. Unfortunately, it is not clear from the commit e7565f10886bac86410db6eb6fda47da1d04ac9b why _fclose_r was changed to _fflush_r when _LITE_EXIT is enabled - is this to reduce memory footprint? Thanks, Volodymyr