Re: Segfault in MemoryContextAlloc - Mailing list pgsql-bugs

From Andres Freund
Subject Re: Segfault in MemoryContextAlloc
Date
Msg-id 20160127103533.GA17919@awork2.anarazel.de
Whole thread Raw
In response to Segfault in MemoryContextAlloc  (Dmitriy Sarafannikov <dimon99901@mail.ru>)
Responses Re[2]: [BUGS] Segfault in MemoryContextAlloc
List pgsql-bugs
Hi,

On 2016-01-27 13:24:35 +0300, Dmitriy Sarafannikov wrote:
>  Hi, i caught segfault with a simple select query (column and table names in query were changed).
> select id_pk2 from table1 where id_pk1 = '9751302'
>
> primary key is (id_pk1, id_pk2)
> table1 is (id_pk1 bigint, id_pk2 bigint, date_add timestamp)

> (gdb) bt full
> #0 MemoryContextAlloc (context=0x0, size=120) at
/build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/utils/mmgr/mcxt.c:584
> No locals.
> #1 0x00007f6ecc5b8eec in AfterTriggerBeginXact () at
/build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/commands/trigger.c:3913
> No locals.
> #2 0x00007f6ecc4e8c21 in StartTransaction () at
/build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/access/transam/xact.c:1848
> s = 0x7f6eccbc4480 <TopTransactionStateData>
> #3 StartTransactionCommand () at
/build/postgresql-9.4-MZhK6O/postgresql-9.4-9.4.5/build/../src/backend/access/transam/xact.c:2534
> s = 0x7f6eccbc4480 <TopTransactionStateData>
> __func__ = "StartTransactionCommand"

That's, uh, weird. TopTransactionContext should never be NULL here. This
is with a stock 9.4.5, without any further extensions configured?

My best guess is that some cache invalidation callback did something
invalid. With
    AtStart_Inval();
    AtStart_Cache();
    AfterTriggerBeginXact();
in StartTransaction(), AtStart_Inval() still had a valid
TopTransactionContext, but AfterTriggerBeginXact() didn't anymore, that
seems like a good guess.

Greetings,

Andres Freund

pgsql-bugs by date:

Previous
From: Dmitriy Sarafannikov
Date:
Subject: Segfault in MemoryContextAlloc
Next
From: Dmitriy Sarafannikov
Date:
Subject: Re[2]: [BUGS] Segfault in MemoryContextAlloc