Re: Segmentation fault - PostgreSQL 17.0

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Ľuboslav Špilák <lspilak(at)microstep-hdo(dot)sk>, Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: Segmentation fault - PostgreSQL 17.0
Date: 2024-11-11 13:48:38
Message-ID: ad5f0ecf-6edb-43d4-8965-60eac1b04775@vondra.me
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 11/11/24 10:30, Ľuboslav Špilák wrote:
> Hello.
>
> After creating new database cluster (5433) in Postgresql 17 there was no
> problem with calling function
>       select * from brin_page_items(
>                 get_raw_page(
>
>
> On the pg_upgraded cluster I got this backtrace on sigsegv. Is this
> helpful or do I need to include any more information?
>

Could you maybe try on a completely new 17.0 cluster, not one that went
through pg_upgrade? I don't think pg_upgrade should cause anything like
this, but it'd be good to conclusively rule that out by reproducing the
issue on a fresh cluster.

> (gdb) c
> Continuing.
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x00005627752205d5 in heap_compute_data_size
> (tupleDesc=tupleDesc(at)entry=0x5627a1df38c0,
> values=values(at)entry=0x7fff4744a450, isnull=isnull(at)entry=0x7fff4744a448)
>     at ./build/../src/backend/access/common/heaptuple.c:234
> 234     ./build/../src/backend/access/common/heaptuple.c: No such file
> or directory.
> (gdb) bt
> #0  0x00005627752205d5 in heap_compute_data_size
> (tupleDesc=tupleDesc(at)entry=0x5627a1df38c0,
> values=values(at)entry=0x7fff4744a450, isnull=isnull(at)entry=0x7fff4744a448)
>     at ./build/../src/backend/access/common/heaptuple.c:234

This is ... weird. heap_compute_data_size literally didn't change for
the last 9 years, so it's the same for 12 and 17. Line 234 is this:

Size
heap_compute_data_size(TupleDesc tupleDesc,
const Datum *values,
const bool *isnull)
{
Size data_length = 0;
int i;
int numberOfAttributes = tupleDesc->natts;

for (i = 0; i < numberOfAttributes; i++)
{
Datum val;
Form_pg_attribute atti;

if (isnull[i])
continue;

val = values[i];
atti = TupleDescAttr(tupleDesc, i);

if (ATT_IS_PACKABLE(atti) &&
VARATT_CAN_MAKE_SHORT(DatumGetPointer(val)))

I wonder which of the conditions triggers the segfault. Whether the one
accessing the attribute info (atti), or the one checking the pointer. It
has to be the first, because we're dealing with int8, and that's not a
varlena type, so it's not packable. So my guess would be atti is some
bogus pointer, with garbage.

Could you please print variables "i", "numberOfAttributes" and then also
the contents of tupleDesc and atti?

print i
print numberOfAttributes
print *tupleDesc
print *atti

regards

--
Tomas Vondra

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tomas Vondra 2024-11-11 13:59:06 Re: Segmentation fault - PostgreSQL 17.0
Previous Message PG Bug reporting form 2024-11-11 10:41:56 BUG #18699: Checksum verification failed for: edb_pgagent_pg17.app.zip