Re: PostgreSQL crashes with SIGSEGV

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Aleksandr Parfenov <a(dot)parfenov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL crashes with SIGSEGV
Date: 2018-02-23 00:22:47
Message-ID: CAH2-Wz=QW6FNpLEfQpFKmKiu_WkfxCpmPDmp6ZUf=7SrARsNpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Mon, Feb 12, 2018 at 6:15 PM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> * For 9.5 and 9.6, the approach taken in bugfix commit d8589946d
> should be taken even further -- we should always copy. Moreover, we
> should always copy within tuplesort_getdatum(), for the same reasons.
>
> * For 9.5, 9.6, 10, and master, we should make sure that
> tuplesort_getdatum() uses the caller's memory context. The fact that
> it doesn't already do so seems like a simple oversight. We should do
> this to be consistent with tuplesort_gettupleslot(). (This isn't
> critical, but seems like a good idea.)
>
> * For 9.5, 9.6, 10, and master, we should adjust some comments from
> tuplesort_getdatum() callers, so that they no longer say that
> tuplesort datum tuple memory lives in tuplesort context. That won't be
> true anymore.

Attached patches do it that way. I'm happy with what I came up with,
which is a lot simpler than my first approach. The extra copying seems
likely to be well worth it, since it is fairly isolated in practice,
especially on 9.6. There is no extra copying from v10+, since they
don't need the first fix at all.

--
Peter Geoghegan

Attachment Content-Type Size
REL9_6_STABLE-fix-double-free-tuplesort.patch text/x-patch 9.8 KB
REL_10_STABLE-fix-double-free-tuplesort.patch text/x-patch 6.5 KB
REL9_5_STABLE-fix-double-free-tuplesort.patch text/x-patch 9.4 KB
master-fix-double-free-tuplesort.patch text/x-patch 5.3 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 趙明春 2018-02-23 02:16:36 Re: BUG #15076: postmaster crashes unexpectedly when using up arrow key in psql command
Previous Message David G. Johnston 2018-02-22 21:24:47 Re: BUG #15079: [54000] ERROR: total size of jsonb array elements exceeds the maximum of 268435455 bytes

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2018-02-23 00:42:03 Re: Translations contributions urgently needed
Previous Message Tatsuo Ishii 2018-02-23 00:15:05 Re: Translations contributions urgently needed