Re: Schema variables - new implementation for Postgres 15

From: Sergey Shinderuk <s(dot)shinderuk(at)postgrespro(dot)ru>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, dean(dot)a(dot)rasheed(at)gmail(dot)com, er(at)xs4all(dot)nl, joel(at)compiler(dot)org, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Schema variables - new implementation for Postgres 15
Date: 2022-11-14 07:00:38
Message-ID: 7c253688-7ced-a413-2719-394492bed5bb@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 13.11.2022 20:59, Pavel Stehule wrote:
> fresh rebase

Hello,

Sorry, I haven't been following this thread, but I'd like to report a
memory management bug. I couldn't apply the latest patches, so I tested
with v20221104-1-* patches applied atop of commit b0284bfb1db.

postgres=# create variable s text default 'abc';

create function f() returns text as $$
begin
return g(s);
end;
$$ language plpgsql;

create function g(t text) returns text as $$
begin
let s = 'BOOM!';
return t;
end;
$$ language plpgsql;

select f();
CREATE VARIABLE
CREATE FUNCTION
CREATE FUNCTION
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

LOG: server process (PID 55307) was terminated by signal 11:
Segmentation fault
DETAIL: Failed process was running: select f();

I believe it's a use-after-free error, triggered by assigning a new
value to s in g(), thus making t a dangling pointer.

After reconnecting I get a scary error:

postgres=# select f();
ERROR: compressed pglz data is corrupt

Best regards,

--
Sergey Shinderuk https://postgrespro.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-11-14 07:03:58 Re: Time delayed LR (WAS Re: logical replication restrictions)
Previous Message Amit Kapila 2022-11-14 06:44:44 Time delayed LR (WAS Re: logical replication restrictions)