Re: PostgreSQL crashes with SIGSEGV
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Aleksandr Parfenov <a.parfenov@postgrespro.ru>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-02-08T00:41:48Z
Lists: pgsql-bugs, pgsql-hackers
Peter Geoghegan <pg@bowt.ie> writes: > On Wed, Jan 17, 2018 at 2:23 PM, Peter Geoghegan <pg@bowt.ie> wrote: >> A complicating factor for this fix of mine is that mode_final() seems >> to have its own ideas about tuple memory lifetime, over and above what >> tuplesort_getdatum() explicitly promises, as can be seen here: >> /* >> * Note: we *cannot* clean up the tuplesort object here, because the value >> * to be returned is allocated inside its sortcontext. We could use >> * datumCopy to copy it out of there, but it doesn't seem worth the >> * trouble, since the cleanup callback will clear the tuplesort later. >> */ >> ISTM that either grouping sets or mode_final() must necessarily be >> wrong, because each oversteps, and infers a different contract from >> tuplesort tuple fetching routines (different assumptions about memory >> contexts are made in each case). Only one can be right, unless it's >> okay to have one rule for tuplesort_getdatum() and another for >> tuplesort_gettupleslot() (which seems questionable to me). I still >> think that grouping sets is right (and that mode_final() is wrong). Do >> you? > It would be nice to get an opinion on this mode_final() + tuplesort > memory lifetime business from you, Tom. I'm fairly sure that that bit in mode_final() was just a hack to make it work. If there's a better, more principled way, let's go for it. > Note that you removed the quoted comment within be0ebb65, back in October. There were multiple instances of basically that same comment before. AFAICS I just consolidated them into one place, in the header comment for ordered_set_shutdown. regards, tom lane
Commits
-
Fix actual and potential double-frees around tuplesort usage.
- c2d4eb1b1fa2 11.0 landed
- e4ff711582b1 9.5.13 landed
- c98f218fbf5a 10.4 landed
- 90decdba3786 9.6.9 landed
-
Allow the built-in ordered-set aggregates to share transition state.
- be0ebb65f512 11.0 cited
-
Avoid integer overflow while sifting-up a heap in tuplesort.c.
- 512f67c8d02c 10.0 cited
-
Allow avoiding tuple copy within tuplesort_gettupleslot().
- fa117ee40330 10.0 cited
-
Remove should_free arguments to tuplesort routines.
- 3856cf9607f4 10.0 cited
-
Fix use-after-free around DISTINCT transition function calls.
- a5f0bd77a2fa 9.6.1 cited
- d8589946ddd5 10.0 cited
-
Reuse abbreviated keys in ordered [set] aggregates.
- f1f5ec1efafe 9.6.0 cited