Re: printf %s with NULL pointer (was Re: BUG #17098: Assert failed on composing an error message when adding a type to an extension being dropped)

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: printf %s with NULL pointer (was Re: BUG #17098: Assert failed on composing an error message when adding a type to an extension being dropped)
Date: 2021-07-13 05:52:20
Message-ID: dc29b1131b84bef879cf68d1d1edae07f51ca3d2.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, 2021-07-12 at 13:20 -0400, Tom Lane wrote:
> > However, that root issue is converted from a relatively minor bug into
> > a server crash because snprintf.c treats a NULL pointer passed to %s
> > as a crash-worthy error. I have advocated for that behavior in the
> > past, but I'm starting to wonder if it wouldn't be wiser to change
> > over to the glibc-ish behavior of printing "(null)" or the like.
>
> So my feeling about this is that switching snprintf.c's behavior
> would produce some net gain in robustness for v12 and up, while
> not making things any worse for the older branches. I still hold
> to the opinion that we've already flushed out all the cases of
> passing NULL that we're likely to find via ordinary testing.

New cases could be introduced in the future and might remain undetected.

What about adding an Assert that gags on NULLs, but still printing them
as "(null)"? That would help find such problems in a debug build.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2021-07-13 09:15:17 BUG #17103: WAL segments are not removed after exceeding max_slot_wal_keep_size
Previous Message Ing Sergio Basurto J. 2021-07-12 21:13:09 Re: BUG #17102: Running "create or replace language plperl" gives error

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2021-07-13 06:10:04 Quick tip on building pg with Visual Studio Build Tools 2019 + small patches
Previous Message vignesh C 2021-07-13 05:50:13 Re: Failed transaction statistics to measure the logical replication progress