New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_lzma: test_refleaks_in_decompressor___init__() leaks 100 handles on Windows #78097
Comments
Using my PR 7827, I saw that test_refleaks_in_decompressor___init__() of test_lzma leaks 100 handles on Windows. Extract of the code: @support.refcount_test
def test_refleaks_in_decompressor___init__(self):
gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
lzd = LZMADecompressor()
refs_before = gettotalrefcount()
for i in range(100):
lzd.__init__()
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) |
In _lzmamodule.c
This seems leak some resource. But I'm not sure this lock contains refcnt on Windows. |
PR 7827 checks for leaks of Windows handles, this issue is about Windows handles, not Python reference leaks. But a Windows lock may use a Windows handle internally, I don't know :-) |
It seems like test_bz2 has the same issue, but I'm not sure: |
I four times tried to update this issue, and only the forth one was successful. Other attempts was failed because "Edit Error: someone else has edited this issue (nosy, components, versions)." This is an extreme case of race condition in real life. |
It seems like Python 2.7 is inaffected by the bug: static int
BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
{
...
#ifdef WITH_THREAD
if (!self->lock) {
self->lock = PyThread_allocate_lock();
}
if (!self->lock) {
PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
goto error;
}
#endif
...
} I fixed the leak in Python 3.6, 3.7 and master. I close the issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: