pgsql: Fix refcounting bug in PLy_modify_tuple().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix refcounting bug in PLy_modify_tuple().
Дата
Msg-id E1WSueM-0000sZ-Fr@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix refcounting bug in PLy_modify_tuple().

We must increment the refcount on "plntup" as soon as we have the
reference, not sometime later.  Otherwise, if an error is thrown in
between, the Py_XDECREF(plntup) call in the PG_CATCH block removes a
refcount we didn't add, allowing the object to be freed even though
it's still part of the plpython function's parsetree.

This appears to be the cause of crashes seen on buildfarm member
prairiedog.  It's a bit surprising that we've not seen it fail repeatably
before, considering that the regression tests have been exercising the
faulty code path since 2009.

The real-world impact is probably minimal, since it's unlikely anyone would
be provoking the "TD["new"] is not a dictionary" error in production, and
that's the only case that is actually wrong.  Still, it's a bug affecting
the regression tests, so patch all supported branches.

In passing, remove dead variable "plstr", and demote "platt" to a local
variable inside the PG_TRY block, since we don't need to clean it up
in the PG_CATCH path.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/742cc408f1ad8ef8d104663938f9910064607253

Modified Files
--------------
src/pl/plpython/plpy_exec.c |    8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix refcounting bug in PLy_modify_tuple().
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix refcounting bug in PLy_modify_tuple().