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)

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>, Ranier Vilela <ranier.vf@gmail.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2021-07-14T06:05:54Z
Lists: pgsql-bugs, pgsql-hackers
On 13.07.21 20:26, Tom Lane wrote:
> Did you see my followup?  The vast majority of live systems do not do
> that, so we are accomplishing nothing of value by insisting it's a
> crash-worthy bug.

But there are no guarantees that that will be maintained in the future. 
In the past, it has often come back to bite us when we relied on 
implementation-dependent behavior in the C library or the compiler, 
because no optimization might invalidate old assumptions.

In this particular case, I would for example be quite curious how those 
alternative minimal C libraries such as musl-libc handle this.




Commits

  1. Make printf("%s", NULL) print "(null)" instead of crashing.

  2. Lock the extension during ALTER EXTENSION ADD/DROP.

  3. Add an assertion that we don't pass NULL to snprintf("%s").

  4. Fix broken logic for reporting PL/Python function names in errcontext.