This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ctypes: reference leak in POINTER code
Type: resource usage Stage: needs patch
Components: ctypes Versions: Python 3.3
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, benjamin.peterson, loewis, meador.inge
Priority: normal Keywords: patch

Created on 2011-10-23 18:45 by meador.inge, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ctypes-refleak-repro.patch meador.inge, 2011-10-23 18:45 Reproduction case patch. review
Messages (5)
msg146242 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-10-23 18:45
While implementing a patch for issue13096 I found a reference leak in 'ctypes'.  I couldn't find the cause immediately, but it can be 
reproduced by applying the attached patch and running:

[meadori@motherbrain cpython]$ ./python -m test -R : test_ctypes
[1/1] test_ctypes
beginning 9 repetitions
123456789
.........
test_ctypes leaked [51, 51, 51, 51] references, sum=204
1 test failed:
    test_ctypes
[174347 refs]
msg146243 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-10-23 18:46
The cause is ctypes caches POINTER types. You have to make sure to clear the cache.
msg146261 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-10-23 21:58
So it's not a bug at all, right?
msg146266 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-10-23 22:51
Ah, I see now.  Thanks Benjamin.

> So it's not a bug at all, right?

A bug in regrtest.py maybe.  'dash_R_cleanup' clears various other caches in
between test runs to avoid false positives like this.  Perhaps
'ctypes._pointer_type_cache'
should be cleared there as well.
msg147395 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-11-10 05:23
I opened issue13380 for fixing the ctypes regrtest caching problem.
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57459
2011-11-10 05:23:46meador.ingesetmessages: + msg147395
2011-10-23 22:51:08meador.ingesetmessages: + msg146266
2011-10-23 21:58:49loewissetstatus: open -> closed

nosy: + loewis
messages: + msg146261

resolution: not a bug
2011-10-23 18:46:53benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg146243
2011-10-23 18:45:08meador.ingecreate