Re: Fix memleaks and error handling in jsonb_plpython - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Fix memleaks and error handling in jsonb_plpython
Date
Msg-id 20190308055911.GG4099@paquier.xyz
Whole thread Raw
In response to Re: Fix memleaks and error handling in jsonb_plpython  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Fix memleaks and error handling in jsonb_plpython
List 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
opinion.

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.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: New vacuum option to do only freezing
Next
From: Michael Paquier
Date:
Subject: Re: Small doc fix for pageinspect