Re: [PATCH] Free memory allocated by waitonlock_error_callback()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Quan Zongliang <quanzongliang(at)yeah(dot)net>
Cc: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [PATCH] Free memory allocated by waitonlock_error_callback()
Date: 2025-10-23 04:08:22
Message-ID: aPmqNqlAGa_ivIpG@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 23, 2025 at 11:18:09AM +0800, Quan Zongliang wrote:
> On 9/19/25 7:16 PM, Aleksander Alekseev wrote:
>> Currently waitonlock_error_callback() allocates memory in ErrorContext
>> and doesn't explicitly free it. Valgrind is not happy about it and
>> generates multiple reports like this:
>
> Improve the completeness of the code.

errfinish() calls MemoryContextReset() on ErrorContext so as any leaks
like the one you are cleaning up are taken care of. Still, what you
are suggesting is simple enough and silences a bit valgrind, so agreed
about the addition of this pfree().

Let's see if somebody objects to that.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-10-23 04:21:34 Re: [PATCH] pg_get_domain_ddl: DDL reconstruction function for CREATE DOMAIN statement
Previous Message Amit Kapila 2025-10-23 04:06:07 Re: issue with synchronized_standby_slots