public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Jeff Johnston <jjohnstn@redhat.com>
To: "R. Diez" <rdiezmail-newlib@yahoo.de>
Cc: "newlib@sourceware.org" <newlib@sourceware.org>
Subject: Re: _REENT_CHECK_VERIFY calls __assert_func even if NDEBUG is defined
Date: Mon, 27 Apr 2020 13:39:40 -0400	[thread overview]
Message-ID: <CAOox84s-9GH0TQi6OxDDaqJ=b4EOcHrNbEw1pqghFYMo42DFaw@mail.gmail.com> (raw)
In-Reply-To: <989180140.2023825.1588003097077@mail.yahoo.com>

The code does not disable via NDEBUG because it is a fix for a CVE.  It is
not (and should not be) tied to user control over usage of the assert macro.

If you do not want the verification check, you can use
--disable-newlib-reent-check-verify when you configure.

-- Jeff J.

On Mon, Apr 27, 2020 at 11:58 AM R. Diez via Newlib <newlib@sourceware.org>
wrote:

> Hallo all:
>
> I have used Newlib 3.1.0 (and older versions) for quite some time. I am
> trying to upgrade to the latest release/snapshot 3.3.0, but I hit a
> compilation error in release builds (with NDEBUG defined):
>
> newlib-3.3.0/newlib/libc/stdlib/rand.c:78: undefined reference to
> `__assert_func'
>
> I tracked it down to this definition:
>
> /* Specify how to handle reent_check malloc failures. */
> #ifdef _REENT_CHECK_VERIFY
> #include <assert.h>
> #define __reent_assert(x) ((x) ? (void)0 : __assert_func(__FILE__,
> __LINE__, (char *)0, "REENT malloc succeeded"))
> #else
> #define __reent_assert(x) ((void)0)
> #endif
>
> This is unfortunate. First of all, I wonder what happens if malloc fails
> and there is no assert. Will there be a crash?
>
> Then, I would like to assert() in debug builds, and not in release builds.
> My code does not define __assert_func in release builds, because assertions
> are only supposed to work if NDEBUG is not defined. That has been working
> fine for years, until this Newlib version.
>
> I am configuring Newlib with --disable-newlib-multithread , because my
> embedded firmware has no threads. But I guess I still have to deal with
> "struct _reent", don't I? I would have hoped that, in this single-thread
> situation, any reentrancy structure could be allocated statically. Or is
> there any way to avoid this malloc()?
>
> Thanks in advance,
>   rdiez
>
>

  reply	other threads:[~2020-04-27 17:39 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 [this message]
2020-04-27 20:29     ` R. Diez
2020-04-27 23:57       ` Jeff Johnston
2020-04-28 12:06         ` R. Diez
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='CAOox84s-9GH0TQi6OxDDaqJ=b4EOcHrNbEw1pqghFYMo42DFaw@mail.gmail.com' \
    --to=jjohnstn@redhat.com \
    --cc=newlib@sourceware.org \
    --cc=rdiezmail-newlib@yahoo.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).