Issue 13250: ctypes: reference leak in POINTER code (original) (raw)

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 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 for fixing the ctypes regrtest caching problem.
History
Date User Action Args
2022-04-11 14:57:23 admin set github: 57459
2011-11-10 05:23:46 meador.inge set messages: +
2011-10-23 22:51:08 meador.inge set messages: +
2011-10-23 21:58:49 loewis set status: open -> closednosy: + loewismessages: + resolution: not a bug
2011-10-23 18:46:53 benjamin.peterson set nosy: + benjamin.petersonmessages: +
2011-10-23 18:45:08 meador.inge create