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.96) (envelope-from ) id 1vdsTJ-00648V-2W for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 16:02:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vdsTI-002sSp-2L for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jan 2026 16:02:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vdsTI-002sSg-13 for pgsql-hackers@lists.postgresql.org; Thu, 08 Jan 2026 16:02:49 +0000 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vdsTG-005Isq-2w for pgsql-hackers@postgresql.org; Thu, 08 Jan 2026 16:02:48 +0000 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-3ec46e3c65bso2560375fac.0 for ; Thu, 08 Jan 2026 08:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767888165; x=1768492965; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TGVMeFX/qZMogABvc08tFZ1mi0TsTR8Ui5oOXXjjOyg=; b=Urk+pDYHcL+FCgooUjoBe7TBUvV0Jyx7L8wz4Pz9VmMaaKcY6SPTdxJUJItdwLA+Zm x/8iU5zbJ7txRjFnQTwXb6PLDdCOm0ng1rmhMaKwpIoT2QSIfykWeSWBAZBJuJK7H5wZ BcfN7JbS5BKhErm+K7icvOz/Bn9CgQbMRl6Nk+Cx83QdBoNUxhd3uN7xySodb/S6NKlF abQ6E3WAtv+sKlwRnwNP9g4mDg/y/5BunJsSbto0GI3B0Na0byJJpnLvYVGQGncucfZN 8kEorlGDAsYi3sg7MHC+NLZ5N/9KENXggGRt/1GhtVA035A350vmyIxeTFjsu0NGP54r 45Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767888165; x=1768492965; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TGVMeFX/qZMogABvc08tFZ1mi0TsTR8Ui5oOXXjjOyg=; b=EkL3eVZn4HijUaLY3meJHRpPc1aOtAqmpwUkpHYE8hfdwzlsm4zXtCGKS1ZDECazWJ w+FUqwC7AB4PfjkAkeDT51hSfnEQWvjoYW/RctLQXXmhxAJi3NqCpCSnTZ6YAG7wHrGm ptzDnOG67tE7jqitqVQZK+neM3e9uA8lmgbAj3N4VwnPdkNm9tL0j9T5prRsBkUyrkyD iwOmhI7CKV2stss2ZByqNqZ7eOPRd90sN5RY+nohg1C+m3bbg8MvPcD7oaDNMzX7ea7y AUeoSXF8ZGSucwx59pmbE2PeTBEPLyFyt9IGkc05sOzvUDavriaxdE6ULeMq3sO4mnCk CmeA== X-Forwarded-Encrypted: i=1; AJvYcCW6qNnjlDwdLWp61jrv9NcaBpwVoAsDm9Vwz/iFPSIT9V3cQ0IJf7isnUYnlwqDoOVe3KQfqH01o3Ffu6D1@postgresql.org X-Gm-Message-State: AOJu0Yy0hNN+jRxLZtjiy8ggIL4kCKOUCYtfzm6g1jeZ831B0irGv4yR 0J9PZ882fu7VUGSGrKBty6BSzJ9KlQlv7mQIySEOxnhNeT0kFFeahn7vu9Urb3zTAfpCT4y+TaP brWdhXcwO3JRDP6dKIg2iWPQ2AzjxPSBEq++egLnB5Q== X-Gm-Gg: AY/fxX444nUY0aVvMaQgcdMuupUAREAqPhYbtQnbwYfFair6HJB3Ldq0t0xIQcHPtUY aVoGHPgm31byw8FayXhFxangJuLGCkeDoz/TQKtvZ9ozbKYOcqruZ+uxVAAz39ymYi/yk8+IGFo 867oNQW5zLtXbFPDQEQM+Rq5AhZeFkuSmc7qvQT8ZBk7v8zJp4+nDahC1V7OP4sMvaGa1Q9pfb5 GVepSqNxHv2f56zSfokYI314yTNLXd5xZ+Xg4GUshPZcjmzPUkOXmv2yKtBTziSp0H/ggJ2iDlr los+wW491uQX0lR9GJmGFcFNqxXtqw== X-Google-Smtp-Source: AGHT+IEB/TQQLaEMqc8NEqBBnMudg9l6K4jnrZ0B81VqdDCC5vcG7BCqhnO4bVvyF+acllxjYd3SgsV5nFZM4msEPOk= X-Received: by 2002:a05:6820:1501:b0:65b:37cd:9dd4 with SMTP id 006d021491bc7-65f54eea304mr2603817eaf.8.1767888164533; Thu, 08 Jan 2026 08:02:44 -0800 (PST) MIME-Version: 1.0 References: <3007317.1765210195@sss.pgh.pa.us> In-Reply-To: From: Fujii Masao Date: Fri, 9 Jan 2026 01:02:31 +0900 X-Gm-Features: AQt7F2r8nD-9P0g33_D72hiQQvHxDVG2WRvfc48KUeIF_RzYREg5Ux8O06rxX-M Message-ID: Subject: Re: [BUG] CRASH: ECPGprepared_statement() and ECPGdeallocate_all() when connection is NULL To: Shruthi Gowda Cc: Tom Lane , PostgreSQL Development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 8, 2026 at 3:00=E2=80=AFAM Shruthi Gowda = wrote: > > > On Mon, Dec 8, 2025 at 9:39=E2=80=AFPM Tom Lane wrote= : >> >> Shruthi Gowda 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 chec= k 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=E2=80=99ve reviewed all occurrences of ecpg_get_connection() a= nd noted that, in most instances, it is followed by ecpg_init(), which vali= dates the connection and returns immediately if the connection is NULL. Why did you add this check instead of calling ecpg_init()? Wouldn't it be better and sufficient to use ecpg_init() to validate the connection? + con =3D ecpg_get_connection(connection_name); + if (!con) + { + ecpg_raise(lineno, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST, + connection_name ? connection_name : ecpg_gettext("NULL")); Regards, --=20 Fujii Masao