pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: PL/Python: Fix crash in functions returning SETOF and using SPI
Date: 2012-05-02 18:04:42
Message-ID: E1SPdus-0005vg-0R@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

PL/Python: Fix crash in functions returning SETOF and using SPI

Allocate PLyResultObject.tupdesc in TopMemoryContext, because its
lifetime is the lifetime of the Python object and it shouldn't be
freed by some other memory context, such as one controlled by SPI. We
trust that the Python object will clean up its own memory.

Before, this would crash the included regression test case by trying
to use memory that was already freed.

reported by Asif Naeem, analysis by Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/52aa334fcd5a9d230be7e8fb964d94c6c4e63dc7

Modified Files
--------------
src/pl/plpython/expected/plpython_setof.out | 16 ++++++++++++++++
src/pl/plpython/plpy_spi.c | 11 +++++++++++
src/pl/plpython/sql/plpython_setof.sql | 12 ++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2012-05-02 18:12:35 pgsql: PL/Python: Improve test coverage
Previous Message Peter Eisentraut 2012-05-02 17:56:24 pgsql: Even more duplicate word removal, in the spirit of the season