On Mon, Sep 16, 2024 at 6:00 PM Alexander Lakhin <exclus...@gmail.com> wrote: > So this leak looks like a recent and still existing defect.
>From my cartoon-like understanding of Windows, I would guess that if event handles created by a program are leaked after it has exited, it would normally imply that they've been duplicated somewhere else that is still running (for example see the way that PostgreSQL's dsm_impl_pin_segment() calls DuplicateHandle() to give a copy to the postmaster, so that the memory segment continues to exist after the backend exits), and if it's that, you'd be able to see the handle count going up in the process monitor for some longer running process somewhere (as seen in this report from the Chrome hackers[1]). And if it's not that, then I would guess it would have to be a kernel bug because something outside userspace must be holding onto/leaking handles. But I don't really understand Windows beyond trying to debug PostgreSQL at a distance, so my guesses may be way off. If we wanted to try to find a Windows expert to look at a standalone repro, does your PS script work with *any* source directory, or is there something about the initdb template, in which case could you post it in a .zip file so that a non-PostgreSQL person could see the failure mode? [1] https://randomascii.wordpress.com/2021/07/25/finding-windows-handle-leaks-in-chromium-and-others/