Re: BUG #16176: NULL value returned by category_sql argument to crosstab() causes segmentation fault

Joe Conway <[email protected]> Fri, 20 Dec 2019 13:04:37 -0500
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
On 12/20/19 1:00 PM, Tom Lane wrote:
> PG Bug reporting form <[email protected]> writes:
>>     -- this will crash pg12, but not version() < 12 - note NULL value in
>> categories query:
>>     select * from crosstab ('values (1, 2, 12), (1, 3, 13), (2, 2, 22), (2,
>> 3, 23), (3, 2, 32), (3, 3, 33) order by 1, 2, 3', 'values (2), (null)') as
>> rr (a int, "2" int, "3" int);
> 
> Yeah, duplicated here.  It seems tablefunc is passing a NULL string
> pointer to sprintf().  Previously, that would work on some platforms
> and crash on others --- as of v12, it crashes everywhere.
> 
> What we need here is to figure out what the hashtab string key ought
> to be for a NULL category.  I suspect what was happening before
> (on non-crashing platforms) was that you implicitly got "(nil)"
> or some spelling like that, which is not great because it could
> conflict with a valid user key.  Alternatively, we could refuse
> NULL category values ... not sure if that's desirable.
> 
> Anyway, this is *not* a new bug, it's just possible to hit it on
> more platforms now.

Thanks for the heads up -- I'll take a look as quick as I can, but
likely tomorrow.

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEg14x9eymXoJyHrH+N/L3QzX32GUFAl39DTUACgkQN/L3QzX3
2GVjTg/+PWXLR1E0kk193ptQKI70NjEd2P/HPU+f8155SnXF4Uu1Gd4trJDbHXqf
A6XDLO8QobNeU/JdGWWEXn0oZVttVQ86W2q7rKd3ka/pbee4ci9bIquMkscOEVqx
SsRN20pLQsEWxbsEhoTe0I4r7QKb/MuuHxoE4POTlufHSfJtQooQUJHG7XovHv7y
/FTkNE+V887IazZ4zSwT/pELgcJPkJFzjqApC/6yj7fTrHPCl6Nxc73DbUhYVksx
RT5T2VABvV50JS6zGeLjUwCP9Cfxot0oP337T5ZBYQLXap2RgHvTnwJzuSU3zSvl
Ik+sxNrr6IWlDH48SqV+tQQfIYNL1ICD6OdZOcsjIxhc6mKY2M2NF+/Qoci9S5S0
o9onHLk/92vT2pX5ncoim0YsXvOIQDsOMyLrW+0HJkjyukxRbtxaEtWSwx7+Rv/4
zom6ZyNB903PbOAZcgw8BnVRUBJKhliVBYavxFEt1BsUlQMxSHOdp/8Gp14v/fdZ
5XeK4zzfySu4fLWuwkFTkWtHZwNMRHYnPSXPxuLEVe/+cRACpb6dZ0HKkfyyOurc
buJ5rQoExlp6U8B9/ux4MfSeHTioGkv6neLQDEb6c9vB0lNQ5RpDiSDleOsR7m/w
USCJZoZCmBnzX3p6hjO45S1rLsb2PVIU1J+LrZmJycvtT6M3sE8=
=q1YV
-----END PGP SIGNATURE-----