Title: posixmodule.c leaks crypto context on Windows
Type: Stage:
Components: Extension Modules Versions: Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: loewis, ygale
Priority: normal Keywords:

Created on 2007-01-03 10:47 by ygale, last changed 2007-09-04 09:52 by loewis. This issue is now closed.

Messages (7)
msg30889 - (view) Author: Yitz Gale (ygale) Date: 2007-01-03 10:47
The Win API docs for CryptAcquireContext require that
the context be released after use by calling
CryptReleaseContext, but posixmodule.c fails to do so
in win32_urandom().
msg30890 - (view) Author: Yitz Gale (ygale) Date: 2007-01-03 12:12
You might consider backporting this to 2.5 and 2.4.
msg30891 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-01-04 21:13
I fail to see the problem. Only a single crypto context is allocated, and it is used all the time, i.e. until the Python interpreter finishes, at which time it is automatically released by the operating system.
msg30892 - (view) Author: Yitz Gale (ygale) Date: 2007-01-04 21:46
How do you know that "it is automatically released
by the operating system?"

The documentation for CryptAcquireContext states:
"When you have finished using the CSP, release the
handle by calling the CryptReleaseContext function."

In the example code provided, the wording in the comments
is even stronger:
"When the handle is no longer needed, it must be released."
The example code then explicitly calls CryptReleaseContext.

Do you know absolutely for certain that we are not
leaking resourses if we violate this clear API

msg30893 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-01-05 00:46
Yes, I'm absolutely certain that terminating a process releases all handles, on Windows NT+.
msg30894 - (view) Author: Yitz Gale (ygale) Date: 2007-01-05 10:01
OK, then, fine. You might want to just add a comment
there so that people like me won't keep filing bugs
against this. :)
msg55637 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-09-04 09:52
Ok, I added a comment in r57958
Date User Action Args
2007-09-04 09:52:17loewissetstatus: open -> closed
resolution: fixed
messages: + msg55637
2007-01-03 10:47:10ygalecreate