public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: "R. Diez" <rdiezmail-2005@yahoo.de>
Cc: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>, newlib@sourceware.org
Subject: Re: [PATCH v2] newlib: fix build with <gcc-5 versions
Date: Wed, 16 Mar 2022 04:30:11 -0400	[thread overview]
Message-ID: <YjGgE0WFwVPT2oh1@vapier> (raw)
In-Reply-To: <e8076dd4-5977-4cfd-a968-2ce5f85ca905@yahoo.de>

[-- Attachment #1: Type: text/plain, Size: 1378 bytes --]

On 16 Mar 2022 08:12, R. Diez wrote:
> > __builtin_mul_overflow showed up with gcc-5, so stub it out for older
> > versions.
> > [...]
> > +#if !__GNUC_PREREQ__(5, 0)
> > +#define __builtin_mul_overflow(a, b, size) ({ *(size) = (a) * (b); 0; })
> 
> I do not understand why Newlib needs to "stub it out" like this.

because the builtin doesn't exist, and attempting to use it leads to
undefined functions, and the resulting libc.a can't link anything.

> According to the GCC documentation, this kind of built-in routines allow the caller to check whether the operations overflowes. But the code above performs no overflow checking at all.
> 
> Therefore, compiling your code with GCC < 5 will silently break your application. After all, the only reason to use __builtin_mul_overflow() is that you need to check for overflow, is it?

practically speaking, i don't think this is a big deal.  newlib gained these
checks only "recently" (<2 years ago).  newlib has been around for much much
longer, and the world didn't notice.  yes, if an app starts trying to allocate
huge amounts of memory such that it triggers 32-bit overflows when calculating,
the new size, it will probably internally allocate fewer bytes than requested,
and things will get corrupted.  but like, don't do that :p.  such applications
probably will have other problems already.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-03-16  8:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14  3:25 [PATCH] " Mike Frysinger
2022-03-14  7:36 ` Sebastian Huber
2022-03-14 16:58   ` Mike Frysinger
2022-03-15  3:25 ` [PATCH v2] " Mike Frysinger
2022-03-15 12:41   ` Richard Earnshaw
2022-03-15 23:54     ` Mike Frysinger
2022-03-16  7:12       ` R. Diez
2022-03-16  8:30         ` Mike Frysinger [this message]
2022-03-16  9:17           ` R. Diez
2022-03-17  2:41             ` Mike Frysinger
2022-03-17  9:49               ` Corinna Vinschen
2022-03-17 11:26                 ` Richard Earnshaw
2022-03-18  7:24                   ` Corinna Vinschen
2022-03-18  8:30                     ` R. Diez
2022-03-18  9:26                       ` Corinna Vinschen
2022-03-18  9:45                         ` R. Diez
2022-03-20  1:22                           ` Mike Frysinger
2022-03-20  1:21                 ` Mike Frysinger
2022-03-20 13:57                   ` Jordi Sanfeliu
2022-03-20 12:52       ` Eric Bresie
2022-03-20 14:16         ` Mike Frysinger
2022-03-15 23:53 ` [PATCH v3] " Mike Frysinger
     [not found] <1647792834.2524.0.ref@smtp.mail.att.net>
2022-03-20 16:13 ` [PATCH v2] " Steven J Abner
     [not found] <1647807849.2524.1.ref@smtp.mail.att.net>
2022-03-20 20:24 ` Steven J Abner

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=YjGgE0WFwVPT2oh1@vapier \
    --to=vapier@gentoo.org \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=newlib@sourceware.org \
    --cc=rdiezmail-2005@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).