Re: function lca('{}'::ltree[]) caused DB Instance crash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pierre Ducroquet <p(dot)psql(at)pinaraf(dot)info>
Cc: pgsql-hackers(at)postgresql(dot)org, Oleg Bartunov <obartunov(at)gmail(dot)com>, Teodor Sigaev <teodor(at)sigaev(dot)ru>
Subject: Re: function lca('{}'::ltree[]) caused DB Instance crash
Date: 2018-07-13 14:26:56
Message-ID: 993.1531492016@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Pierre Ducroquet <p(dot)psql(at)pinaraf(dot)info> writes:
> On Friday, July 13, 2018 12:09:20 PM CEST 李海龙 wrote:
>> contrib_regression=# select lca('{}'::ltree[]);
>> server closed the connection unexpectedly

> There is indeed a bug. The _lca function in _ltree_op.c tries to allocate 0
> bytes of memory, doesn't initialize it and dereference it in lca_inner.
> The attached basic patch fixes it.

I think the defense ought to be in lca_inner not there.

However, I don't understand why this code is returning NULL, rather than
a zero-length ltree, in the case that there's no common prefix. That
doesn't seem consistent to me.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Łukasz Jarych 2018-07-13 14:48:02 Fwd: SQL
Previous Message Ashutosh Bapat 2018-07-13 13:50:36 Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2018-07-13 14:37:24 Re: [PATCH] Include application_name in "connection authorized" log message
Previous Message Heikki Linnakangas 2018-07-13 14:25:47 Re: GiST VACUUM