pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: tillmann73@yahoo.de, pgsql-bugs@lists.postgresql.org, PG Bug reporting form <noreply@postgresql.org>
Cc: andrew.dunstan@2ndquadrant.com
Subject: Re: BUG #15448: server process (PID 22656) was terminated by exception 0xC0000005
Date: Tue, 23 Oct 2018 11:00:56 +0900
Message-ID: <9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp> (raw)
In-Reply-To: <15448-068ca37e168742d6@postgresql.org>
References: <15448-068ca37e168742d6@postgresql.org>

Hi,

On 2018/10/22 21:34, PG Bug reporting form wrote:
> The following bug has been logged on the website:
> 
> Bug reference:      15448
> Logged by:          Tillmann Schulz
> Email address:      tillmann73@yahoo.de
> PostgreSQL version: 11.0
> Operating system:   Windows
> Description:        
> 
> I have a reproducable error when running two junit test cases in sequence
> from Java with Postgres 11.0.1. With postgres 10 everything worked fine. 
> 
> 
> The error occurs at
> 
> 2018-10-22 14:06:59.651 CEST [22696] LOG:  server process (PID 22656) was
> terminated by exception 0xC0000005
> 2018-10-22 14:06:59.651 CEST [22696] DETAIL:  Failed process was running:
> delete from c5_member

Thanks for the report and the log.

(Today I learned that exception 0xC0000005 is the Windows equivalent of
"segmentation fault".)

> Aft that, postgres is in recovery mode. Shortly after that the database is
> availiably again.
> 
> The complete log of both testcases is:

After observing the test case in the provided log, I managed to reproduce
it with the following:

create table foo (a int primary key, b int);
create table bar (a int references foo on delete cascade, b int);
insert into foo values (1, 1);
insert into foo values (2, 2);
alter table foo add c int;
alter table foo drop c;
delete from foo;
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

Analyzing this crash, I located the bug down to GetTupleForTrigger(), but
perhaps it's really in heap_expand_tuple() / expand_tuple(), where the
value of trigger tuple's t_self is being switched from a valid one to an
invalid value.

In heaptuple.c: expand_tuple()


        ItemPointerSetInvalid(&((*targetHeapTuple)->t_self));


FWIW, attached patch fixes this for me.  Adding Andrew whose recent commit
7636e5c60f [1] seems to have introduced the heap_expan_tuple call in
GetTupleForTrigger.  Maybe, he can better judge a fix for this.

Thanks,
Amit

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=7636e5c60f

Attachments:

GetTupleForTrigger-fix.patch (text/plain, 456B) download diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 240e85e391..3c9ce9be0c 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -3399,7 +3399,10 @@ ltrmark:; } if (HeapTupleHeaderGetNatts(tuple.t_data) < relation->rd_att->natts) + { result = heap_expand_tuple(&tuple, relation->rd_att); + result->t_self = *tid; + } else result = heap_copytuple(&tuple); ReleaseBuffer(buffer);

view thread (10+ messages)  latest in thread

Message-ID: <9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp>
Permalink:  ../9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp/
Also on:    postgresql.org/message-id/9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Langote_Amit_f8@lab.ntt.co.jp, noreply@postgresql.org, andrew.dunstan@2ndquadrant.com
  Subject: Re: BUG #15448: server process (PID 22656) was terminated by exception 0xC0000005
  In-Reply-To: <9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp>
  References: <15448-068ca37e168742d6@postgresql.org> <9cb4aa1c-12ba-59c3-fd75-545fa90fb92f@lab.ntt.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox