Re: [PATCH] Fix segmentation fault and infinite loop in jsonb_{plperl,plpython}
Aleksander Alekseev <aleksander@tigerdata.com>
From: Aleksander Alekseev <aleksander@tigerdata.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2026-06-16T21:25:18Z
Lists: pgsql-hackers
Hi, > > Alternatively I could implement a check for the loops, if you feel > > like this is worth the effort. > > I thought about that, but I'm not sure how to build a bulletproof > check at reasonable (ie, near zero) cost. We could detect the example > case where an object refers directly to itself, by noticing that "in" > doesn't change in one iteration. But I'm pretty sure it's possible to > build reference loops involving two or more Perl objects, and those > would fool such a check. I was thinking about depth-first search where we store our current path in a set. If the visited node is already in the set then the graph has loops. This is not exactly cheap but the complexity is proportional to the cost of the serialization so I think we should be fine. The good thing is that the user will get a sensible error message instead of an infinite loop. -- Best regards, Aleksander Alekseev
Commits
-
hstore_plperl: Add CHECK_FOR_INTERRUPTS() in reference-unwinding loop.
- c0f17b04d906 19 (unreleased) landed
- d65cf6f800f0 18 (unreleased) landed
- 60a1d712a472 16 (unreleased) landed
- 4fbbabb0a729 15 (unreleased) landed
- 4efef9d18e63 17 (unreleased) landed
- 1f6b2295f952 14 (unreleased) landed
-
jsonb_plperl, jsonb_plpython: Fix unguarded recursion and loops.
- e3b7a43fa9b6 18 (unreleased) landed
- da82fbb8f9a3 19 (unreleased) landed
- b0f3465b6f6a 16 (unreleased) landed
- a6f23c3ade0e 15 (unreleased) landed
- 639fff5118a8 14 (unreleased) landed
- 3df0b77558d7 17 (unreleased) landed