From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-hackers@lists.postgresql.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: Tue, 13 Jul 2021 11:52:06 -0400
Message-ID: <3233754.1626191526@sss.pgh.pa.us> (raw)
In-Reply-To: <3227956.1626186568@sss.pgh.pa.us>
References: <17098-b960f3616c861f83@postgresql.org>
<2468663.1626017338@sss.pgh.pa.us>
<2984422.1626110456@sss.pgh.pa.us>
<dc29b1131b84bef879cf68d1d1edae07f51ca3d2.camel@cybertec.at>
<3227956.1626186568@sss.pgh.pa.us>
I wrote:
> Now, what we don't have control of is what will happen in pre-v12
> branches on platforms where we use the system's *printf. However,
> note what I wrote in the log for 0c62356cc:
> Per commit e748e902d, we appear to have little or no coverage in the
> buildfarm of machines that will dump core when asked to printf a
> null string pointer.
> Thus it appears that a large fraction of the world is already either
> using glibc or following glibc's lead on this point.
Further to that point: I just ran around and verified that the system
printf prints "(null)" rather than crashing on FreeBSD 12.2, NetBSD 8.99,
OpenBSD 6.8, macOS 11.4, and Solaris 11.3. AIX 7.2 and HPUX 10.20 print
"", but still don't crash. If we change snprintf.c then we will also be
okay on Windows, because we've always used our own snprintf on that
platform. In short, the only place I can find where there is actually
any hazard is Solaris 10 [1]. I do not think we should let the risk of
obscure bugs in pre-v12 versions on one obsolete OS drive our
decision-making about this.
regards, tom lane
[1] Per experimentation locally and on the GCC compile farm, using
the attached.
Attachments:pnull.c (text/x-c, 117B) download
#include <stdio.h>
int
main(int argc, char **argv)
{
printf("NULL prints as \"%s\"\n", (char *) NULL);
return 0;
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, pgsql-hackers@lists.postgresql.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)
In-Reply-To: <3233754.1626191526@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox