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 1wgmXm-006Obo-2e for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2026 16:51:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgmXl-001qsk-07 for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Jul 2026 16:51:41 +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 1wgji3-000xFW-1z for pgsql-bugs@lists.postgresql.org; Mon, 06 Jul 2026 13:50:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wgji1-0000000249k-3EIP for pgsql-bugs@lists.postgresql.org; Mon, 06 Jul 2026 13:50:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=3dC3z3yasgJKNQjKJ8BnG/4SBpiSvFmlkVUJ1+HPrkM=; b=HN/9hLfnL/gk/rwt5YvaCZqjGK vccNCWM+Ny6N2qvfJtZRK0Nzp/zBn7UIHU4kDDaboO2+tiRfSFRs7VR3f4BTP88bERwMKIwuoPHXt r7nnrD1v4oo+iUDKtQ3BwTETu5rB3bU8ay/kbnzltwdCnnEukhujUoW/IfYD1rbRYulomUKlMDs/J vxsyH6TKbxQ/+WgA4vrEIllyj3mVsKqP3eVD/dCC9tfzgqKi03+Ni0YNsfMGPvUNukAe/gmS9muNP NShN/EQLclM1/Cvn5kG9N9GCiifvTFagJ3RlzWPganWQbxPRwZlFLDmdT8dlIgcjxjG8GgpxvnEkQ vT4x4g3Q==; Received: from wrigleys.postgresql.org ([217.196.149.60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wgji0-00Bamh-1o for pgsql-bugs@lists.postgresql.org; Mon, 06 Jul 2026 13:50:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgjhy-00EFqv-2o for pgsql-bugs@lists.postgresql.org; Mon, 06 Jul 2026 13:50:02 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19544: PostgreSQL 18.3 backend crashes with SIGSEGV when a PL/pgSQL function To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: haogangmao@gmail.com Reply-To: haogangmao@gmail.com, pgsql-bugs@lists.postgresql.org Date: Mon, 06 Jul 2026 13:49:33 +0000 Message-ID: <19544-a63ef569459e4e1c@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19544 Logged by: HaoGang Mao Email address: haogangmao@gmail.com PostgreSQL version: 18.3 Operating system: Linux Description: =20 A PL/pgSQL function declares a local variable of composite type foo where attribute b is INT. Inside the function, the variable is initialized with ROW(123, power(2, 30)). The function then changes foo.b from INT to TEXT using ALTER TYPE and returns the previously initialized composite value. When the caller executes SELECT bar(), PostgreSQL attempts to output the returned record using the updated composite type metadata and the backend segfaults in the text output path. Reproduction steps: ```sql DROP FUNCTION IF EXISTS bar(); DROP TYPE IF EXISTS foo CASCADE; CREATE TYPE foo AS (a INT, b INT); CREATE FUNCTION bar() RETURNS RECORD AS $$ DECLARE r foo :=3D ROW(123, power(2, 30)); BEGIN ALTER TYPE foo ALTER ATTRIBUTE b TYPE TEXT; RETURN r; END; $$ LANGUAGE plpgsql; SELECT bar(); ``` Expected behavior: PostgreSQL should reject the operation or report an error indicating that the composite type changed while a value of the old layout is still being returned. Actual behavior: The client connection is closed unexpectedly and the PostgreSQL backend process terminates with SIGSEGV. Server log: ```text LOG: client backend (PID 90) was terminated by signal 11: Segmentation fault DETAIL: Failed process was running: SELECT bar(); LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing ``` GDB backtrace, trimmed: ```text Program received signal SIGSEGV, Segmentation fault. #0 0x0000762a0a47fc60 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #1 text_to_cstring(t=3D0x5c9ae669d6bc) at varlena.c:234 len =3D 268435452 #2 textout(fcinfo=3D0x7fff0aabda20) at varlena.c:603 #3 FunctionCall1Coll(flinfo=3D0x5c9ae668c148, collation=3D0, arg1=3D101820360414908) at fmgr.c:1139 #4 OutputFunctionCall(flinfo=3D0x5c9ae668c148, val=3D101820360414908) at fmgr.c:1685 #5 record_out(fcinfo=3D0x7fff0aabdbc0) at rowtypes.c:435 column_type =3D 25 attr =3D 101820360414908 tupdesc =3D 0x762a00b61fd8 ncolumns =3D 2 i =3D 1 #8 printtup(slot=3D0x5c9ae668bb88, self=3D0x5c9ae6699e18) at printtup.c:360 #9 ExecutePlan(queryDesc=3D0x5c9ae65c3ed0, operation=3DCMD_SELECT, sendTuples=3Dtrue, numberTuples=3D0, direction=3DForwardScanDirection, dest=3D0x5c9ae6699e18) at execMain.c:1742 #12 PortalRunSelect(portal=3D0x5c9ae6619740, forward=3Dtrue, count=3D0, dest=3D0x5c9ae6699e18) at pquery.c:921 #13 PortalRun(portal=3D0x5c9ae6619740, count=3D9223372036854775807, isTopLevel=3Dtrue, dest=3D0x5c9ae6699e18, altdest=3D0x5c9ae6699e18, qc=3D0x7fff0aabdfe0) at pquery.c:765 #14 exec_simple_query(query_string=3D0x5c9ae6599b80 "SELECT bar();") at postgres.c:1273 #15 PostgresMain(dbname=3D0x5c9ae65d2f38 "postgres", username=3D0x5c9ae65d2f20 "pguser") at postgres.c:4766 ```