public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "R. Diez" <rdiezmail-newlib@yahoo.de>
To: Jeff Johnston <jjohnstn@redhat.com>
Cc: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: _REENT_CHECK_VERIFY calls __assert_func even if NDEBUG is defined
Date: Tue, 28 Apr 2020 12:06:24 +0000 (UTC)	[thread overview]
Message-ID: <1949956947.2883373.1588075584956@mail.yahoo.com> (raw)
In-Reply-To: <CAOox84vYRMU2K2UE6OasV_PMrkvjBcCD5s7Wxj0eLFSA1gT4Hw@mail.gmail.com>

> An alternative change would require modifications to all the
> existing conversion routines using eBalloc() and their callers
> to do checking of return values and bubble up to the user,
> setting errno to ENOMEM.

I am not sure what conversion routines you are referring to. I found this issue with rand(), because lwIP needs a source of random numbers. It is normally not expected that rand() calls malloc(). rand() returns no error indication, according to the POSIX standard:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/rand.html

So using errno here is difficult.

rand() ends up calling _REENT_CHECK, which does a malloc(). What do you mean with eBalloc()?

  
> The memory in question is being allocated by Balloc()
> which is part of the mprec.c solution used in newlib.
> The allocated _REENT_MP_FREELIST has an array
> of storage to reuse for different k values so newlib will reuse
> [...]

Does that apply in my scenario? I am building Newlib without thread support. There is no reent creation or destruction, as far as I can tell.

I have been digging further, and I believe (the code is not easy to follow) that these unexpected allocations come from using the "small reent". What does --enable-newlib-reent-small actually do? The README file at this location:

  https://sourceware.org/newlib/README

has this description:

  `--enable-newlib-reent-small'
    Enable small reentrant struct support.
    Disabled by default.

But it does not really say what the difference between the normal and "small" versions is.

Thanks in advance,
  rdiez

  reply	other threads:[~2020-04-28 12:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <989180140.2023825.1588003097077.ref@mail.yahoo.com>
2020-04-27 15:58 ` R. Diez
2020-04-27 17:39   ` Jeff Johnston
2020-04-27 20:29     ` R. Diez
2020-04-27 23:57       ` Jeff Johnston
2020-04-28 12:06         ` R. Diez [this message]
2020-04-29 19:51           ` Jeff Johnston
2020-04-30  8:08             ` R. Diez
2020-04-28 19:36         ` FAQ link to crossgcc broken R. Diez
2020-04-28 19:57         ` _REENT_CHECK_VERIFY calls __assert_func even if NDEBUG is defined R. Diez
2020-04-28 22:00           ` Keith Packard
2020-04-29 13:05             ` R. Diez

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=1949956947.2883373.1588075584956@mail.yahoo.com \
    --to=rdiezmail-newlib@yahoo.de \
    --cc=jjohnstn@redhat.com \
    --cc=newlib@sourceware.org \
    /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).