[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

Eryk Sun report at bugs.python.org
Mon Jul 1 09:49:36 EDT 2019


Eryk Sun <eryksun at gmail.com> added the comment:

> Without accessing private attributes, I don't see how someone can 
> discover the private handle. So for me, it's more a serious bug in an 
> application, no? Blindly closing random handles doesn't sound like a 
> good idea to me.

Say a library calls CreateEventW and gets handle 32. It passes this handle to some other library, which uses the event and closes the handle when it no longer needs it. But due to a miscommunication in the documentation, the first library thinks the handle remains open. Now handle 32 is free for reuse, but the library doesn't know this. subprocess.Popen subsequently calls CreateProcessW and gets handle 32. Later on, the library closes handle 32, making it invalid, at least until it gets assigned to some other kernel object.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37380>
_______________________________________


More information about the Python-bugs-list mailing list