Re: [PATCH] Fix segmentation fault and infinite loop in jsonb_{plperl,plpython}

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCH] Fix segmentation fault and infinite loop in jsonb_{plperl,plpython}
Date: 2026-06-16 21:25:18
Message-ID: CAJ7c6TOOyK+Z_hge0Pz7ejM=t5Wp1xm39_rZ6HYvzyBu2z76BA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2026-06-16 21:37:58 Re: Require SSL connection to postgres for oauth
Previous Message Tom Lane 2026-06-16 21:10:16 Re: [PATCH] Fix segmentation fault and infinite loop in jsonb_{plperl,plpython}