Re: BUG #18598: AddressSanitizer detects use after free inside json_unique_hash_match()

2024-09-11 Thread Junwang Zhao
Hi Tomas, On Wed, Sep 11, 2024 at 8:08 PM Tomas Vondra wrote: > > On 9/10/24 21:47, Tomas Vondra wrote: > > ... > > > > The only question that bothers me a little bit is the possibility of a > > memory leak - could it happen that we keep the copied key much longer > > than needed? Or does aggcont

Re: BUG #18598: AddressSanitizer detects use after free inside json_unique_hash_match()

2024-09-11 Thread Tomas Vondra
On 9/10/24 21:47, Tomas Vondra wrote: > ... > > The only question that bothers me a little bit is the possibility of a > memory leak - could it happen that we keep the copied key much longer > than needed? Or does aggcontext have with the right life span? AFAICS > that's where we allocate the aggre

Re: BUG #18598: AddressSanitizer detects use after free inside json_unique_hash_match()

2024-09-10 Thread Tomas Vondra
On 9/5/24 06:06, Junwang Zhao wrote: > > ... > > I found two other places called json_unique_check_key. > > One is *json_build_object_worker*, and the usage is the same as > *json_object_agg_transfn_worker*, I fix that the same way, PSA > > The following sql should trigger the problem, I haven'

Re: BUG #18598: AddressSanitizer detects use after free inside json_unique_hash_match()

2024-09-06 Thread Junwang Zhao
CC'd hackers list. On Wed, Sep 4, 2024 at 7:54 PM Tomas Vondra wrote: > > On 9/4/24 11:55, Junwang Zhao wrote: > > ... > > > > ISTM that the JsonUniqueHashEntry.key point to an address later got > > invalidated by enlargeStringInfo, we can resolve this by explicitly > > pstrdup the key in the sam