pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: marcos.castedo@anachronics.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19899: PL/Python backend crashes (SIGSEGV) when converting a column value to a Python object fails
Date: Mon, 16 Nov 2026 12:53:35 -0500
Message-ID: <121695.1794851615@sss.pgh.pa.us> (raw)
In-Reply-To: <19899-3e21845d988f0c0f@postgresql.org>
References: <19899-3e21845d988f0c0f@postgresql.org>

PG Bug reporting form <noreply@postgresql.org> writes:
> When the conversion of a column value to a Python object fails inside
> Python, the backend
> terminates with signal 11 and the postmaster restarts all sessions. The
> expected result is an ERROR
> in the calling session.

The immediate cause in this example seems to be
(1) PyBytes_FromStringAndSize returns NULL after a malloc failure
(2) We blindly pass that NULL to PyDict_SetItemString
(3) PyDict_SetItemString doesn't cope with that and dumps core.

It looks to me like plpy_typeio.c is just full of bugs like this,
because it doesn't have any coherent strategy for detecting or
dealing with failures.  There are a few places that check for
NULL results and throw PLy_elog(ERROR), but not many.  I think
we'd first want to decide whether to check immediately after
each call to a Python function, or try to centralize it a bit.

I wonder now about the rest of plpython, too.

I don't care enough about PL/Python to work on this myself,
but perhaps someone else will pick it up.

			regards, tom lane






view thread (7+ messages)  latest in thread

Message-ID: <121695.1794851615@sss.pgh.pa.us>
Permalink:  ../121695.1794851615@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/121695.1794851615@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, marcos.castedo@anachronics.com
  Subject: Re: BUG #19899: PL/Python backend crashes (SIGSEGV) when converting a column value to a Python object fails
  In-Reply-To: <121695.1794851615@sss.pgh.pa.us>
  References: <19899-3e21845d988f0c0f@postgresql.org> <121695.1794851615@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox