pgsql: Fix WaitEventSet resource leak in WaitLatchOrSocket().

From: Etsuro Fujita <efujita(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix WaitEventSet resource leak in WaitLatchOrSocket().
Date: 2024-04-11 10:13:21
Message-ID: E1rurQm-001a8d-RY@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix WaitEventSet resource leak in WaitLatchOrSocket().

This function would have the same issue we solved in commit 501cfd07d:
If an error is thrown after calling CreateWaitEventSet(), the file
descriptor (on epoll- or kqueue-based systems) or handles (on Windows)
that the WaitEventSet contains are leaked.

Like that commit, use PG_TRY-PG_FINALLY (PG_TRY-PG_CATCH in v12) to make
sure the WaitEventSet is freed properly.

Back-patch to all supported versions, but as we do not have this issue
in HEAD (cf. commit 50c67c201), no need to apply this patch to it.

Discussion: https://postgr.es/m/CAPmGK16MqdDoD8oatp8SQWaEa4vS3nfQqDN_Sj9YRuu5J3Lj9g%40mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e79ceafe93a85820188e835adb392d38331ceed2

Modified Files
--------------
src/backend/storage/ipc/latch.c | 70 ++++++++++++++++++++++-------------------
1 file changed, 38 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Etsuro Fujita 2024-04-11 10:33:29 pgsql: postgres_fdw: Improve comment about handling of asynchronous req
Previous Message Michael Paquier 2024-04-11 08:19:56 pgsql: Use correct datatype for xmin variables in slot.c