Re: Fix memleaks and error handling in jsonb_plpython

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nikita Glukhov <n(dot)gluhov(at)postgrespro(dot)ru>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix memleaks and error handling in jsonb_plpython
Date: 2019-03-08 05:59:11
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Mar 06, 2019 at 11:04:23AM +0900, Michael Paquier wrote:
> Another thing is that you cannot just return within a try block with
> what is added in PLyObject_FromJsonbContainer, or the error stack is
> not reset properly. So they should be replaced by breaks.

So, I have been poking at this stuff, and I am finishing with the
attached. The origin of the issue comes from PLyObject_ToJsonbValue()
and PLyObject_FromJsonbValue() which could result in problems when
working on PyObject which it may allocate. So this has resulted in
more refactoring of the code than I expected first. I also decided to
not keep the additional errors which have been added in the previous
version of the patch. From my understanding of the code, these cannot
actually happen, so replacing them by assertions is enough in my

While on it, I also noticed that hstore_plpython does not actually
need a volatile pointer for plpython_to_hstore(). Also, as all those
problems are really unlikely going to happen in real-life cases,
improving this code only on HEAD looks enough to me.

Attachment Content-Type Size
plpython-leaks.patch text/x-diff 5.4 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-03-08 06:13:00 Re: Small doc fix for pageinspect
Previous Message Masahiko Sawada 2019-03-08 05:10:27 Re: New vacuum option to do only freezing