Re: BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub-

From: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>
To: murasovb(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #19906: Backend crash (signal 11) creating a LANGUAGE sql function that returns a composite type from a sub-
Date: 2026-11-16 18:56:09
Message-ID: CAJTYsWUm1j=YQsHpt12=E_Xmx7GhtmVtRAZ2x+ySOo3bkJtWyQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

On Mon, 16 Nov 2026 at 20:47, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 19906
> Logged by: Boris
> Email address: murasovb(at)gmail(dot)com
> PostgreSQL version: 18.7
> Operating system: Debian 13 (trixie), x86_64, Docker image pgvector/
> Description:
>
> PostgreSQL version:
> PostgreSQL 18.7 (Debian 18.7-1.pgdg13+2) on x86_64-pc-linux-gnu, compiled by
> gcc (Debian 14.2.0-19) 14.2.0, 64-bit
> (official Debian package in the pgvector/pgvector:0.8.7-pg18-trixie Docker
> image; default configuration; empty database)
>
> Minimal reproduction:
>
> CREATE TABLE t (id int, v text);
> CREATE FUNCTION m1() RETURNS TABLE (x t) LANGUAGE sql
> AS $$ SELECT s FROM (SELECT t.* FROM t) s $$;
>
> Result: "server closed the connection unexpectedly". The server log shows:
> client backend (PID ...) was terminated by signal 11: Segmentation fault
> and the postmaster runs crash recovery.
>

Thanks for the report and repro.

The crash can be fixed by checking for pstate not being NULL in
coerce_record_to_complex(), which makes it error out with "cannot cast
type record to t". But I'm unsure if we should do just that, or rather
teach check_sql_fn_retval() to expand the whole-row Var so that this
works like s::t?

Regards,
Ayush

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-11-16 19:07:52 Re: PostgreSQL 18.6/17.11: standby PANIC on restart after VM truncation
Previous Message Daniel Gustafsson 2026-11-16 18:49:14 Re: BUG #19905: loread() with length near INT_MAX: "invalid memory alloc request size" (int32 overflow)