Ticket #4481 defect new
reference cycle involving glib2reactor causes gobject to leak file descriptors
| Reported by: | exarkun | Owned by: | itamar |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | |
| Cc: | Branch: | branches/glib2reactor-fd-leak-4481 | |
| Author: | exarkun | Launchpad Bug: |
Description
Recent versions of pygobject use a pipe to ensure that threading is properly supported (or something like that). The pipe is closed when the MainLoop instance is freed. However, pygobject doesn't seem to handle reference cycles. glib2reactor creates a reference cycle from itself to a MainLoop instance back to the reactor (probably via its doIterationTimer and/or simulate method).
The problem thus created can be observed by using trial -u to run a unit test which creates and destroys a glib2reactor instance. Eventually enough pipes will leak such that no more can be created and the test run will fail. For example:
trial -u twisted.internet.test.test_tcp.TCPClientTestsBuilder_Glib2Reactor.test_addresses
fails after about 1021 iterations (using the versions of things packaged in Ubuntu 10.04).
This appears to be fixable by manually breaking the cycle.
