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-29T23:51:12Z
Lists: pgsql-bugs
David Rowley <dgrowleyml@gmail.com> writes: > I looked at the code and tested. The only thing that I noted was > GenerationFree(), where we do: > /* Test for previously-freed chunk */ > if (unlikely(chunk->requested_size == InvalidAllocSize)) > elog(WARNING, "detected double pfree in %s %p", > ((MemoryContext) block->context)->name, chunk); > /* Test for someone scribbling on unused space in chunk */ > Assert(chunk->requested_size < chunksize); > I expect you've likely thought of this, but if we do spit out the > warning there, then the Assert is definitely going to fail, as > InvalidAllocSize is defined as SIZE_MAX. Yeah, I saw that after sending the patch. Not only would that Assert fail, but without it, code below would go nuts too. > I don't know if that means > it's worth deviating from the similar WARNINGs you've added and making > that one an ERROR. There's certainly no guarantee with the other > context that we'll not crash sometime very soon after issuing the > warning anyway, so maybe it's fine. Seems like a reasonable answer. What do you think of making the double-free cases ERRORs across the board? If we don't error out, there will likely be cascading problems in all the mcxt types not just this one. 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