Re: Segfault in MemoryContextAlloc

From: Andres Freund <andres(at)anarazel(dot)de>
To: Dmitriy Sarafannikov <dimon99901(at)mail(dot)ru>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Segfault in MemoryContextAlloc
Date: 2016-01-27 10:35:33
Message-ID: 20160127103533.GA17919@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Dmitriy Sarafannikov 2016-01-27 10:47:18 Re[2]: [BUGS] Segfault in MemoryContextAlloc
Previous Message Dmitriy Sarafannikov 2016-01-27 10:24:35 Segfault in MemoryContextAlloc