Re: PostgreSQL crashes with SIGSEGV

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Andreas Seltenreich <andreas(dot)seltenreich(at)credativ(dot)de>, Bernd Helmle <mailings(at)oopsware(dot)de>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: PostgreSQL crashes with SIGSEGV
Date: 2017-12-17 10:46:17
Message-ID: CAB7nPqRnYyrqgZf3spjSw_E_ixGu75AFQLv=AdkG8z-cDJMFDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sun, Dec 17, 2017 at 10:40 AM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> On Thu, Dec 14, 2017 at 5:58 PM, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
>> The ambiguity about who owns the tuple memory when is the basic
>> problem, once again. One could argue that it's the caller's fault for
>> not knowing to not pfree() the tuple after tuplesort_end() is called,
>> but I don't buy that because it seems like an undue burden on callers
>> to do that. It seems okay to either provide a very weak, simple
>> guarantee about tuple memory lifetime, or very strong simple guarantee
>> about tuple memory lifetime. That's what routines like
>> tuplesort_gettupleslot() and tuplesort_getindextuple() should limit
>> their contracts to -- we've had enough problems in this area over the
>> years that that seems pretty clear to me.
>>
>> ISTM that an appropriate fix is one that results in having
>> tuplesort_gettupleslot() tuple memory that is *consistently* allocated
>> within caller's own memory context, at least on versions prior to
>> Postgres 10 (it's a bit more complicated in Postgres 10).
>
> This took longer than expected. Attached patch, which targets 9.6,
> shows what I have in mind. I'm going on vacation shortly, but wanted
> to post this patch before I leave. It could definitely use some more
> testing, since it was written under time pressure. I expect to be back
> early in the new year, so if someone feels like taking this off my
> hands, they're more than welcome to do so.

Could you add that to the next commit fest registered as a bug fix? We
don't want to lose track of that and this should be reviewed.
--
Michael

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message patsev.anton 2017-12-17 14:31:33 BUG #14981: Systemd unit used postmaster ( not postgres)
Previous Message Peter Geoghegan 2017-12-17 01:40:24 Re: PostgreSQL crashes with SIGSEGV

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Hernandez 2017-12-17 10:50:04 Re: GSoC 2018
Previous Message David Rowley 2017-12-17 10:29:10 Re: [HACKERS] Proposal: Local indexes for partitioned table