public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Volodymyr Medvid <vmmedvid@gmail.com>
To: Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc: newlib@sourceware.org
Subject: Re: [PATCH] Fix stdio memory leaks with _REENT_SMALL + _LITE_EXIT
Date: Tue, 12 Apr 2022 23:57:01 +0300	[thread overview]
Message-ID: <CAJfDXEpCy0n-eJ4hZLAAZ529NyYbotphA22ViXDGpBvCQz8tow@mail.gmail.com> (raw)
In-Reply-To: <795ccb59-38d3-a9d8-f8d4-9314689d1c62@embedded-brains.de>

On Tue, 12 Apr 2022 18:10:38 +0200
Sebastian Huber <sebastian.huber@embedded-brains.de> 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

      reply	other threads:[~2022-04-12 20:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 13:23 Volodymyr Medvid
2022-04-12 16:10 ` Sebastian Huber
2022-04-12 20:57   ` Volodymyr Medvid [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJfDXEpCy0n-eJ4hZLAAZ529NyYbotphA22ViXDGpBvCQz8tow@mail.gmail.com \
    --to=vmmedvid@gmail.com \
    --cc=newlib@sourceware.org \
    --cc=sebastian.huber@embedded-brains.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).