From: Joe Conway <mail@joeconway.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: ipluta@wp.pl
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16176: NULL value returned by category_sql argument to crosstab() causes segmentation fault
Date: Mon, 23 Dec 2019 13:40:34 -0500
Message-ID: <208f13a0-0433-6780-802d-fedcff3c8991@joeconway.com> (raw)
In-Reply-To: <12400.1576940917@sss.pgh.pa.us>
References: <16176-7489719b05e4303c@postgresql.org>
<8638.1576864859@sss.pgh.pa.us>
<8d8ef71e-a347-67be-696a-3bdd259ec9fb@joeconway.com>
<12400.1576940917@sss.pgh.pa.us>
On 12/21/19 10:08 AM, Tom Lane wrote:
> Joe Conway <mail@joeconway.com> writes:
>> It appears that in pg11 (and presumably prior) when snprintf() is called
>> it is resolved (here at least )to __GI___snprintf() which comes directly
>> from libc. On my desktop machine the system snprintf() deals with a null
>> pointer argument without crashing. I guess this is why the crash was
>> platform dependent.
>
> Right, glibc's version of snprintf has produced "(nil)" or "(null)"
> or something like that for many years. I'm not sure if that's true
> among the BSDen. One place where the platform snprintf does *not*
> survive this case is Windows.
>
>> In pg12 (and presumably master), it is resolved to our own port function
>> pg_snprintf(), which in turn works its way to dopr(), where strlen() is
>> called on a null pointer and "<boom>".
>
> Right. While it would only take a couple more lines of code to act like
> glibc does, we intentionally adopted the stricter definition because it
> seemed more likely to expose bugs. Looks like it just did.
>
>> From what I can see, even on pg11 and prior, having a null category
>> never did anything useful. And in the 16 years or so since this has been
>> around, no one in my memory ever asked for that functionality, so I am
>> inclined to refuse NULL category values unless someone wants to make a
>> good case otherwise.
>
> WFM, but I've never used crosstab() much so I don't have a good feeling
> for significant use-cases.
Pushed that way to all supported branches.
If someone arrives with a compelling use-case, the changes would likely
not be something we would want to back patch, so we can address it
if/when that happens.
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Attachments:
signature.asc (application/pgp-signature, 832B) download
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: mail@joeconway.com, tgl@sss.pgh.pa.us, ipluta@wp.pl, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16176: NULL value returned by category_sql argument to crosstab() causes segmentation fault
In-Reply-To: <208f13a0-0433-6780-802d-fedcff3c8991@joeconway.com>
* 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