Re: BUG #19438: segfault with temp_file_limit inside cursor
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: kuzmin.db4@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2026-03-29T15:32:54Z
Lists: pgsql-bugs
Attachments
- v2-detect-double-free-with-requested_size.patch (text/x-diff) patch v2
David Rowley <dgrowleyml@gmail.com> writes: > For the switching MemoryContextMethodID patch, I applied the memory > context benchmarking patch I used when writing that code to test out > the overhead in a tight palloc/pfree loop (attached). I can see an > overhead of a little over 6.5%. Hm. I got an overhead of about 2% on an Apple M4, which might be argued to be acceptable, but 12% on an aging x86_64 platform. Realistically, given that we failed to notice this omission at all for more than three years, it's hard to argue that testing for it in non-debug builds is worth any overhead. Here's a fleshed-out version of the requested_size method. I noted that AllocSetRealloc needs a defense too, and then extended the patch to generation.c and slab.c. bump.c doesn't have an issue, and I don't think alignedalloc.c needs its own defense either: it can rely on the underlying context type. regards, tom lane
Commits
-
Be more careful to preserve consistency of a tuplestore.
- 739477345036 19 (unreleased) landed
- adb7873bb933 18.4 landed
- 811f3263a48d 15.18 landed
- 7cd23aad2a7a 14.23 landed
- 59c139d53be3 16.14 landed
- 1f5b6a5e5d74 17.10 landed
-
Detect pfree or repalloc of a previously-freed memory chunk.
- a26ac902f662 16.14 landed
- 3f3eefc28892 18.4 landed
- 0c8b4e9cfc45 17.10 landed
- 095555daf124 19 (unreleased) landed
-
Improve performance of and reduce overheads of memory management
- c6e0fe1f2a08 16.0 cited