From: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Yasir <yasir(dot)hussain(dot)shah(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Valgrind - showing memory leaks |
Date: | 2025-05-11 13:36:46 |
Message-ID: | 202505111336.2e4t564msogq@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2025-May-08, Tom Lane wrote:
> Uh ... yeah it is, down at the bottom of the function:
>
> /* Install array only after it's fully valid */
> relation->rd_att->constr->check = check;
> relation->rd_att->constr->num_check = found;
>
> So it seems like valgrind is wrong here, or else we're leaking the
> whole rd_att structure later on somehow.
Well, the problem is that if num_check is zero, FreeTupleDesc() doesn't
free ->check.
> In any case, you're right that asking for a zero-size chunk is pretty
> pointless. I'd support doing
>
> + if (ncheck > 0)
> + check = (ConstrCheck *)
> + MemoryContextAllocZero(CacheMemoryContext,
> + ncheck * sizeof(ConstrCheck));
> + else
> + check = NULL;
>
> but I think we have to make sure it's null if we don't palloc it.
Done that way, thanks.
> > On the other hand, the bug I was thinking about, is that if the table
> > has an invalid not-null constraint, we leak during detoasting in
> > extractNotNullColumn(). [...] But it's no longer so obvious that
> > extractNotNullColumn is okay to leak those few bytes.
>
> Given your description it still sounds fine to me.
Cool, I left it alone.
--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
“Cuando no hay humildad las personas se degradan” (A. Christie)
From | Date | Subject | |
---|---|---|---|
Next Message | Marcos Pegoraro | 2025-05-11 13:38:27 | Re: Request for Implementation of Custom Error Messages for CHECK Constraints |
Previous Message | Matthias van de Meent | 2025-05-11 12:06:49 | Re: Suggestion to add --continue-client-on-abort option to pgbench |