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
BZ2File leaking fd and memory #37709
Comments
The attached patch fixes BZ2File() leaking the fd and I'm not sure the patch fixes these problems in the best Make sure the file: 'empty' exists and do: from bz2 import * A simple test which demonstrates the problem is: for i in range(100000): o = BZ2File('empty') ; del o Without the patch, you quickly get: IOError: [Errno 24] Too many open files: 'empty' You can modify this to: for i in range(100000): o = BZ2File('empty') ;
o.close() ; del o Now you can see the memory leaks. |
Logged In: YES Assigning to the author of the module for review. Gustavo, |
Logged In: YES I've found a better solution: change the last line of to
PyFile_Type.tp_dealloc((PyObject *)self);
Updated patch attached. |
Logged In: YES Um, I don't understand why the BZ2File class inherits from |
Logged In: YES Sorry about the delay. I was on a not-so-short vacation. nnorwitz: Thanks for the patch. I'll check the problem (for my own gvanrossum: BZ2File used to share a lot of code with FileObject. |
Logged In: YES FileObject sharing: I see. But I still think it's a bad |
Logged In: YES Ok. Do you want me to work on this for 2.3? |
Logged In: YES If you could, that would be great. |
Logged In: YES Ok, I've started to "unparent" the bz2 code. OTOH, I've just file_new(), file_init(), open_the_file(), and the following arrays file_memberlist[], file_getsetlist[] My question is, do you think it's better to maintain all I'll do the job, if you still think this is great. |
Logged In: YES I don't understand. Why would you want to copy all the |
Logged In: YES zlib module doesn't emulate a file at C level. It also does The strange thing is, I thought it was a good thing to |
Logged In: YES IMO, being a subclass of a concrete class typically only You may also confuse other parts of the Python runtime that |
Logged In: YES Ok.. I can't find a good way to workaround the presented |
Logged In: YES Thanks! I expect you'll be surprised at the gained clarity |
Logged In: YES Fixed in the following revisions: Modules/bz2module.c: 1.15 Thanks to everybody. |
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: