After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 568427 - "gio.Error: Too many open files" without too many open files
"gio.Error: Too many open files" without too many open files
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gio
Git master
Other All
: Normal blocker
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks: 569774
 
 
Reported: 2009-01-20 13:47 UTC by David Versmisse
Modified: 2009-02-08 19:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
half-complete fix (9.76 KB, patch)
2009-01-29 21:19 UTC, Paul Pogonyshev
none Details | Review
more complete fix (26.10 KB, patch)
2009-02-08 17:32 UTC, Gian Mario Tagliaretti
committed Details | Review

Description David Versmisse 2009-01-20 13:47:08 UTC
Please describe the problem:
When we use the gio wrapper, it raises a "gio.Error: Too many open files" after a while. And we don't have too many open files.

Steps to reproduce:
This snippet of code raises the exception:

from gio import File, FILE_ATTRIBUTE_STANDARD_NAME
g_file = File('.')
while True:
    g_file.enumerate_children(FILE_ATTRIBUTE_STANDARD_NAME)


Actual results:
This code raises the exception.

Expected results:
I tried the same thing in C and i didn't have any problem (no g_error after a while). It's just with the python wrapper.

Does this happen every time?
yes

Other information:
Comment 1 Paul Pogonyshev 2009-01-25 23:15:00 UTC
This is because .defs file lacks '(caller-owns-return #t)'.  We need to revise all GIO files for that, I guess the problem is very widespread.

In PyGTK it is not a case (at least mostly) because of the floating reference.

Note that even after this bug is fixed, your test program is strictly speaking not correct.  It depends on implementation details of CPython, namely that when a last reference to an object is deleted, the object is instantly destroyed.  This is not the case on e.g. Jython.
Comment 2 Paul Pogonyshev 2009-01-29 20:51:30 UTC
This is horrible.  Seems like PyGIO leaks about everything.  To make it worse, GIO documentation doesn't properly specify when the returned object should and when shouldn't be unreffed...
Comment 3 Paul Pogonyshev 2009-01-29 21:19:18 UTC
Created attachment 127491 [details] [review]
half-complete fix

This patch adds a ton of 'caller-own-returns', plus makes constructor of gio.File not leak.  100% not complete.  Reviewing is a must.  By the way, the attached test program now works as expected.
Comment 4 Gian Mario Tagliaretti 2009-01-30 22:54:08 UTC
Paul, I've applied the patch and made some tests, plus I've been checking with GIO docs, it looks like a good job as usual.

I think you should commit
Comment 5 Paul Pogonyshev 2009-01-31 13:56:45 UTC
If you can, please scan over the patched .defs file and look for the methods that should have 'caller-owns-return' but which I missed.  There are almost certainly a few such.
Comment 6 Gian Mario Tagliaretti 2009-02-08 17:32:27 UTC
Created attachment 128237 [details] [review]
more complete fix

I've also added a pointer to the override file in the defs, so it's easier for everybody to see what has been overridden and where.
Comment 7 Paul Pogonyshev 2009-02-08 17:47:23 UTC
I think it reached that size (and mixes together different fixes) when it is easier to commit and sort it out later.  I briefly read through the patch and it looked fine to me.
Comment 8 Gian Mario Tagliaretti 2009-02-08 19:19:49 UTC
Sending        ChangeLog
Sending        gio/gfile.override
Sending        gio/gfileinfo.override
Sending        gio/gio.defs
Sending        gio/gio.override
Sending        gobject/gobjectmodule.c
Sending        gobject/pygobject.c
Sending        gobject/pygtype.c
Transmitting file data ........
Committed revision 1002.