Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT0tg-000000002Ke-2SpN for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 17:53:41 +0000 Received: from localhost ([127.0.0.1]:38372 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xT0tg-00000000YNh-04W3 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Nov 2026 17:53:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:40938) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT0tf-00000000YNZ-3D8e for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 17:53:39 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xT0td-00000000194-02fb for pgsql-bugs@lists.postgresql.org; Mon, 16 Nov 2026 17:53:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 6AGHrZjx121696; Mon, 16 Nov 2026 12:53:36 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 sss.pgh.pa.us 6AGHrZjx121696 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sss.pgh.pa.us; s=default; t=1794851616; bh=rHOWdXn1VVje1tmT2emInncddiyVQzNOgNv9p8X08Us=; h=From:To:cc:Subject:In-reply-to:References:Date:From; b=IWbp+8OA2mQ9vrEzg9Ncy+HF1pTDWmrWcJniyMoZS0NBdYtGEXwbtJE34IqGRLLma cbZv4Lnu3aayAjfaWMhM1efFBcv9rdQIQ84HAMSIYSYGjxDi0egjuc03116FBMH/1A mWTNYp+PvpgnlZHJv+Br2dDDzNq69u/FF8dSrWvg= From: Tom Lane 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 In-reply-to: <19899-3e21845d988f0c0f@postgresql.org> References: <19899-3e21845d988f0c0f@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Thu, 12 Nov 2026 23:50:19 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <121694.1794851615.1@sss.pgh.pa.us> Date: Mon, 16 Nov 2026 12:53:35 -0500 Message-ID: <121695.1794851615@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form 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