model-writtenrun 4904 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Sergey Shinderuk reported a Valgrind-detected use-after-free in row_number() optimization on 32-bit builds and supplied a reproducer that exposed wrong results on 64-bit builds by forcing pass-by-reference values and zeroing freed memory #1.
- Richard Guo confirmed the memory-lifetime diagnosis, tested evaluation in query-lifetime memory, and then proposed copying only the last results when entering pass-through mode; Sergey cautioned that the solution must support arbitrary pass-by-reference return types #2 #3 #4.
- David Rowley proposed nullifying unused window results instead of preserving them, supplying the first executor fix; Richard verified it and explained that upper WindowAgg filters still reference those results, so strict filtering is essential #5 #6 #8.
- David identified that nullification could happen once when entering pass-through mode, while Sergey demonstrated incorrect results with a custom non-strict operator; Tom Lane observed that index access methods generally assume strict operators #7 #9 #10.
- David revised the fix to clear results once per partition and explicitly require strict operators in the planner, rejecting query-lifetime copies because many partitions could accumulate memory and a separate partition context would add complexity #11.
- Sergey caught the reversed return value in the new strictness check and questioned dangling pointers in strict pass-through mode; Richard agreed with the return-value correction, while Sergey clarified his concern about tuples already spooled to disk #12 #13 #14.
- David explained the distinction between spooled input tuples and projected window results, and retained the explicit strictness check because the demonstrated custom operator could otherwise produce wrong results #15 #16.
- David posted the corrected final patch and announced his intention to commit after roughly a day without objections; the thread's last message therefore left the fix awaiting that final window for feedback #17.
- The fix subsequently landed as a858327221 from #17, with only explanatory comments rewritten, crediting Richard and Sergey as reviewers and backpatching through PostgreSQL 15.