pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: plperl: don't save and re-use temp context in return_next(). 3+ messages / 1 participants [nested] [flat]
* pgsql: plperl: don't save and re-use temp context in return_next(). @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org plperl: don't save and re-use temp context in return_next(). Commit ebdefb93b arranged to run plperl_return_next_internal() in a temporary memory context that got reset at the end of each call, so as not to accumulate lots of leaked memory in a PL/Perl function that returns many rows. But this arrangement is unsafe because re-entrant calls of return_next are possible, as shown by the new regression test. In that case the inner call's reset destroys data the outer call still needs, leading to crashes. Instead, just create and delete a temp context for each call. That works correctly in the nested case, and in the normal case it's not really much slower than the old way thanks to the context recycling logic in aset.c (which long postdates ebdefb93b, but is in every still-supported branch). Reported-by: Anthropic OSS program Author: Anthropic OSS program Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116319 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/1388b0fbd4c8db3f37c4175e3c4e4437d863ff90 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/pl/plperl/expected/plperl_tied.out | 21 +++++++++++++++++++++ src/pl/plperl/plperl.c | 22 ++++++++++++---------- src/pl/plperl/sql/plperl_tied.sql | 17 +++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: plperl: don't save and re-use temp context in return_next(). @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org plperl: don't save and re-use temp context in return_next(). Commit ebdefb93b arranged to run plperl_return_next_internal() in a temporary memory context that got reset at the end of each call, so as not to accumulate lots of leaked memory in a PL/Perl function that returns many rows. But this arrangement is unsafe because re-entrant calls of return_next are possible, as shown by the new regression test. In that case the inner call's reset destroys data the outer call still needs, leading to crashes. Instead, just create and delete a temp context for each call. That works correctly in the nested case, and in the normal case it's not really much slower than the old way thanks to the context recycling logic in aset.c (which long postdates ebdefb93b, but is in every still-supported branch). Reported-by: Anthropic OSS program Author: Anthropic OSS program Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116319 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e51917d91d2eaa992b9f68823420d93b64723476 Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/pl/plperl/expected/plperl_tied.out | 21 +++++++++++++++++++++ src/pl/plperl/plperl.c | 22 ++++++++++++---------- src/pl/plperl/sql/plperl_tied.sql | 17 +++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: plperl: don't save and re-use temp context in return_next(). @ 2026-11-09 14:21 Noah Misch <noah@leadboat.com> 0 siblings, 0 replies; 3+ messages in thread From: Noah Misch @ 2026-11-09 14:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org plperl: don't save and re-use temp context in return_next(). Commit ebdefb93b arranged to run plperl_return_next_internal() in a temporary memory context that got reset at the end of each call, so as not to accumulate lots of leaked memory in a PL/Perl function that returns many rows. But this arrangement is unsafe because re-entrant calls of return_next are possible, as shown by the new regression test. In that case the inner call's reset destroys data the outer call still needs, leading to crashes. Instead, just create and delete a temp context for each call. That works correctly in the nested case, and in the normal case it's not really much slower than the old way thanks to the context recycling logic in aset.c (which long postdates ebdefb93b, but is in every still-supported branch). Reported-by: Anthropic OSS program Author: Anthropic OSS program Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Backpatch-through: 14 Security: CVE-2026-116319 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/343663966f830427033b51c8703e64e3a2446c4e Author: Tom Lane <tgl@sss.pgh.pa.us> Modified Files -------------- src/pl/plperl/expected/plperl_tied.out | 21 +++++++++++++++++++++ src/pl/plperl/plperl.c | 22 ++++++++++++---------- src/pl/plperl/sql/plperl_tied.sql | 17 +++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-09 14:21 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-09 14:21 pgsql: plperl: don't save and re-use temp context in return_next(). Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: plperl: don't save and re-use temp context in return_next(). Noah Misch <noah@leadboat.com> 2026-11-09 14:21 pgsql: plperl: don't save and re-use temp context in return_next(). Noah Misch <noah@leadboat.com>
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