Re: BUG #17912: Invalid memory access when converting plpython' array containing empty array
Alexander Law <exclusion@gmail.com>
From: Alexander Lakhin <exclusion@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2023-05-01T12:00:00Z
Lists: pgsql-bugs
30.04.2023 19:24, Tom Lane wrote:
> Here's a version that adopts plperl's logic, causing it to treat
> empty sub-lists as being zero-length dimensions. Most of the new
> test cases are borrowed from plperl, too, and most of them act
> differently before and after the code change. So I'm pretty
> hesitant to put this into stable branches. OTOH, maybe it's not
> too late for v16?
Thanks for the patch!
I've tested the new implementation and found no issues with it — only
rectangular structures are accepted now. The code is straightforward and
very similar to plperl's, so I would not expect that it might bring new
anomalies, which couldn't be seen before.
Thus I don't think that adding it to current master (and possible follow-up
fixing) can take a significant amount of time out of v16+ schedule only.
> I noticed one inarguable bug here, too: PLySequence_ToArray_recurse
> leaks Python object refcounts after errors, because it has no
> PG_TRY to ensure that Py_XDECREF() gets done. I'm not sure if
> it's worth doing something about that in the back branches, given
> the lack of complaints.
I continue watching the array handling bugs dancing Sirtaki too. Now it's
another asymmetry:
select '{{1},{{2}}}'::int[];
{{{1}},{{2}}}
but:
select '{{{1}},{2}}'::int[];
{}
Reproduced on REL_11_STABLE..master.
Best regards,
Alexander
Commits
-
Tighten array dimensionality checks in Python -> SQL array conversion.
- b7fcf3824b42 12.15 landed
- b7001c6b6a77 15.3 landed
- aa7e5e404324 11.20 landed
- 9d517339e991 14.8 landed
- 0e6354ed9783 13.11 landed
- 0553528e7c2b 16.0 landed
-
Tighten array dimensionality checks in Perl -> SQL array conversion.
- f47004add160 16.0 landed
- ee24b5e792e0 13.11 landed
- ea96fbe772a7 11.20 landed
- ce9a1a3ea8fe 15.3 landed
- 900a8d526ff5 12.15 landed
- 1e868bb6c67a 14.8 landed
-
Handle zero-length sublist correctly in Python -> SQL array conversion.
- ff9203f46069 12.15 landed
- b7c6af375da6 11.20 landed
- a1d9aacc4128 14.8 landed
- 81eaaf65e393 16.0 landed
- 7dcd9998c19d 13.11 landed
- 512c555221c3 15.3 landed