Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: gcc15: drop -fno-delete-null-pointer-checks local change
To:
ports@openbsd.org
Date:
Tue, 18 Nov 2025 10:50:54 +0100

Download raw body.

Thread
On Tue, Nov 18, 2025 at 10:38:58AM +0100, Theo Buehler wrote:
> On Mon, Nov 17, 2025 at 02:14:03PM +0100, Claudio Jeker wrote:
> > In gcc -fdelete-null-pointer-checks is a nightmare.
> > 
> > It is a stupid optimisation which has some bad security track record since
> > it tends to remove 'if (p == NULL) error out' checks. Now on OpenBSD you can
> > not map the page at address 0 so it is less of a concern since in that
> > case the code should crash before the check (at least that is the theory).
> > 
> > The problem with skipping this optimisation is that a lot of c++ code
> > breaks because of static asserts against nullptr.
> > Many of those expressions are actually not using proper const expressions
> > and so gcc errors out. With -fdelete-null-pointer-checks these checks
> > get optimised away (because the compiler decided that somewhen before the
> > static assert the pointer was already dereferenced and so impossible to be
> > NULL).
> > 
> > I got tired to figure out how to pass -fdelete-null-pointer-checks to all
> > those c++ monsters. The common linux distros all ship with a gcc that has
> > -fdelete-null-pointer-checks set by default and so we just inflict a lot
> > of pain on us for being a special snowflake.
> 
> I'm not going to object, but as I said elsewhere I would prefer to know
> what ports are really affected by this. With the exception of ruby/3.3,
> I think all known cases are already broken on sparc64, so this should
> not be a blocker.
> 
> I think the option was disabled in ports because miod disabled it in
> base 20 years ago. This is pascal's sync commit:
> https://github.com/openbsd/ports/commit/e7f261aa1558eedd881e29bc5c69734f9e3f23bc
> and here's miod's original base commit:
> 
> commit 66149774b87757613e220f937ebb9c1d56485993
> Author: miod <miod@openbsd.org>
> Date:   Tue Nov 2 21:04:50 2004 +0000
> 
>     Do not enable -fdelete-null-pointer-checks at -O2 by default on OpenBSD.
> 
>     This optimizations is really cool, but it does not work for complex code;
>     we had to disable it for Perl 5.8 to run correctly, now it turns out it
>     broke Bind 9 on powerpc, so neuter it for good.
> 
>     ok deraadt@ henning@ millert@ others@
> 
> Now hopefully things have improved since then...
> 

Also, if we land this for 15, should it also be done for 8 and 11?