model-writtenrun 2998 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Alexander Lakhin reported an AddressSanitizer use-after-free during a large JSON_OBJECTAGG query with unique-key checking in #1, and Tomas Vondra reproduced it with Valgrind while initially suspecting a memory-context lifetime problem in #2.
- Junwang Zhao identified buffer reallocation as the cause and proposed copying hash-table keys into the aggregate context in #3; Tomas confirmed the fix with Valgrind, suggested MemoryContextStrdup, and requested investigation of another uniqueness-checking caller in #4.
- Junwang's attached fix in #6 covered both the aggregate and json_build_object_worker(), supplied a reproducer for the latter, and explained why the parsing callback already handled key lifetime correctly.
- Tomas verified the second reproducer and expanded the patch with regression tests large enough to force buffer reallocation in #8, while raising questions about allocation lifetime and identifying PostgreSQL 16 as the backpatch boundary.
- Tomas committed 842265631d from the latest attachment #9, retaining its tests while adding comments and switching the non-aggregate key copy to pstrdup(); the commit credits both authors and specifies backpatching through PostgreSQL 16.
- In #10, Tomas explained that his lifetime investigation found no new leak and that CurrentMemoryContext was appropriate for ordinary keys because unique_check.mcxt was intended for skipped keys; Junwang acknowledged the completed work in #11, leaving no outstanding work stated in the thread.