Re: BUG #14722: Segfault in tuplesort_heap_siftup, 32 bit overflow
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Andres Freund <andres@anarazel.de>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Sergey Koposov <skoposov@cmu.edu>, "pgsql-bugs@postgresql.org" <pgsql-bugs@postgresql.org>
Date: 2017-07-05T22:35:30Z
Lists: pgsql-bugs
On Wed, Jul 5, 2017 at 3:19 PM, Peter Geoghegan <pg@bowt.ie> wrote: > I doubt that myself. Especially prior to Postgres 10, where merging > will have tuplesort_heap_insert() as the bottleneck. BTW, I do of course understand that the reporter isn't talking about merging, but rather is talking about run generation using replacement selection. Replacement selection is more or less obsolete, and was more or less removed in Postgres 9.6. I don't think that its needs should be given much weight here; this is mostly about merging. I wanted to make merging use its own dedicated function within the patch that became 24598337c8d, and leave tuplesort_heap_insert() and tuplesort_heap_siftup() as things used only by replacement selection + Top-N heap sort, but Heikki overruled me on that. He might have been right about that. I'm not sure, and never took the time to follow up with it. tuplesort_heap_replace_top(), which is where this logic lives now that tuplesort_heap_siftup() was broken up, certainly is a red-hot code path where individual instructions could matter. I've looked at the disassembly of the function in the past, which is rare for me. -- Peter Geoghegan
Commits
-
Avoid integer overflow while sifting-up a heap in tuplesort.c.
- e439bbe9996f 9.4.13 landed
- e7213fe2bda8 9.5.8 landed
- 512f67c8d02c 10.0 landed
- 09c598898166 9.6.4 landed
-
Implement binary heap replace-top operation in a smarter way.
- 24598337c8d2 10.0 cited
-
Permit super-MaxAllocSize allocations with MemoryContextAllocHuge().
- 263865a48973 9.4.0 cited