Small bugs regarding resowner handling in aio.c, catcache.c

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Small bugs regarding resowner handling in aio.c, catcache.c
Date: 2025-12-09 23:33:23
Message-ID: CAEze2Whnfv8VuRZaohE-Af+GxBA1SNfD_rXfm84Jv-958UCcJA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Heikki, Andres,

Whilst looking through catcache.c's code I noticed this piece of code:

ReleaseCatCacheListWithOwner(CatCList *list, ResourceOwner resowner)
{
[...]
if (resowner)
ResourceOwnerForgetCatCacheRef(CurrentResourceOwner, &ct->tuple);

Note how the resowner argument is ignored in favour of
CurrentResourceOwner; and that probably wasn't what the author
intended.

So I looked around a bit, and found 2 more similar instances: one more
in catcache.c, and one in aio.c. I can't guarantee that there are no
other comparable issues, but at least I could not immediately find any
functions that ignore their ResourceOwner argument in favour of
CurrentResourceOwner.

The issue in aio.c is externally visible, so it might trigger issues.
However, every caller in the tree uses CurrentResourceOwner, so only
extensions could trigger this bug.
The two issues in catcache.c are benign: No external code can trigger
it with a different resource owner; and while no internal code would
trigger it either, it's better to use the provided resowner, so that
future callers won't activate the bug.

Attached a fix for all 3 cases.

Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)

Attachment Content-Type Size
v1-0001-Fix-some-near-bugs-related-to-ResOwner-function-a.patch application/octet-stream 2.9 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-12-09 23:36:19 Re: Solaris versus our NLS files
Previous Message Euler Taveira 2025-12-09 23:31:56 Re: Add support for specifying tables in pg_createsubscriber.