Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL
Shruthi Gowda <gowdashru@gmail.com>
From: Shruthi Gowda <gowdashru@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Date: 2026-01-07T18:00:27Z
Lists: pgsql-hackers
Attachments
- v2-0001-Add-missing-connection-validation-in-ECPG.patch (application/octet-stream) patch v2-0001
On Mon, Dec 8, 2025 at 9:39 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Shruthi Gowda <gowdashru@gmail.com> writes: > > The ECPG application crashes with a segmentation fault when calling > > specific deallocation or prepared statement functions without an > > established database connection. This is caused by a missing NULL check > on > > the connection handle before attempting to access it. > > Hmm ... poking around, I see several other places that aren't checking > the result of ecpg_get_connection. Shouldn't we tighten them all? > > regards, tom lane > I agree. I’ve reviewed all occurrences of ecpg_get_connection() and noted that, in most instances, it is followed by ecpg_init(), which validates the connection and returns immediately if the connection is NULL. In a few cases, the caller had already validated the connection. However, I identified an additional case that lacked this check, so I have revised the patch to include the missing validation. Thanks & Regards, Shruthi K C EnterpriseDB: http://www.enterprisedb.com
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add missing connection validation in ECPG
- f0e3f9732d41 14.23 landed
- 6916f4410051 15.18 landed
- 7e4c871f4181 16.14 landed
- 5d67549d9412 17.10 landed
- e2688ea5e411 18.4 landed
- c34a280c85b3 19 (unreleased) landed