Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid handle leak (src/bin/pg_ctl/pg_ctl.c)
Date: 2025-10-24 11:15:55
Message-ID: CAEudQArgkD_enPn99aLjqQs3Z1MT8YAGoRtxZvfyWN6vz5o7Gw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sex., 24 de out. de 2025 às 02:57, Michael Paquier <michael(at)paquier(dot)xyz>
escreveu:

> On Thu, Oct 23, 2025 at 09:51:14PM -0300, Ranier Vilela wrote:
> > The function *CreateRestrictedProcess* is responsible to create a
> > restricted token
> > Coverity complains that the handle origToken can be leaked.
> >
> > In case of failure of the functions *AllocateAndInitializeSid* or
> > *GetPrivilegesToDelete*
> > the handle origToken must be released.
>
> pg_ctl exits quickly when a failure of CreateRestrictedProcess()
> happens, hence why does it matter to close these handles as an exit()
> should do the job as well?
>
Handles are a scarce Windows resource.
The work of freeing these resources is not done by exit(), but by Windows
itself, when possible.
If applications are not good citizens, these resources will eventually run
out.

best regards,
Ranier Vilela

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Verite 2025-10-24 11:23:53 Re: Unicode 17
Previous Message Ranier Vilela 2025-10-24 11:13:04 Re: Avoid resource leak (src/test/regress/pg_regress.c)