From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | Eric Thinnes <e(dot)thinnes(at)gmx(dot)de> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Segmentation fault when calling BlessTupleDesc in a C function in parallel on PostgreSQL-(12.6, 12.7, 13.2, 13.3) |
Date: | 2021-05-15 00:20:47 |
Message-ID: | CA+hUKGK8ib9c5h-+uQudQ0+CGAx23h6XAAns9pL+pVgHfV2REQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Sat, May 15, 2021 at 5:42 AM Eric Thinnes <e(dot)thinnes(at)gmx(dot)de> wrote:
> Because of the parallelism it is difficult to debug the error.
> I have less experience with that.
I was able to reproduce the problem using your test.c/test.sql. It's
a bug in PostgreSQL. BlessTupleDesc() is supposed to work correctly
in any process in a parallel query since the typmods are shared (since
PG 11, before that there was a different arrangement involving
translation), but there is a low probability edge case that your test
manages to hit fairly reliably, where two backends try to bless a
tuple with matching attributes at exactly the same time, and then the
one that loses the race switches to using the TupleDesc blessed by the
other, but it dereferences the wrong pointer (or rather, a non-pointer
with a similar name...) here:
/* Return the one we found. */
Assert(record_table_entry->key.shared);
result = (TupleDesc)
dsa_get_address(CurrentSession->area,
-
record_table_entry->key.shared);
+
record_table_entry->key.u.shared_tupdesc);
Assert(result->tdrefcount == -1);
With that change I can see it still hits this path often but works
correctly. Will fix next week.
From | Date | Subject | |
---|---|---|---|
Next Message | varun kamal | 2021-05-15 07:39:11 | Re: BUG #17007: server process (PID XXXX) was terminated by signal 11: Segmentation fault |
Previous Message | Peter Geoghegan | 2021-05-14 22:10:01 | Re: BUG #16833: postgresql 13.1 process crash every hour |