Opened 9 years ago

Last modified 7 years ago

#4481 defect new

reference cycle involving glib2reactor causes gobject to leak file descriptors

Reported by: Jean-Paul Calderone Owned by: Itamar Turner-Trauring
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch: branches/glib2reactor-fd-leak-4481
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun


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.

Change History (4)

comment:1 Changed 9 years ago by Jean-Paul Calderone

Author: exarkun
Branch: branches/glib2reactor-fd-leak-4481

(In [29171]) Branching to 'glib2reactor-fd-leak-4481'

comment:2 Changed 9 years ago by Jean-Paul Calderone

(In [29246]) This might fix it on Lucid

refs #4481

comment:3 Changed 8 years ago by <automation>

Owner: Glyph deleted

comment:4 Changed 7 years ago by Itamar Turner-Trauring

Owner: set to Itamar Turner-Trauring

In trunk (r33906) the suggested test run does fail after 1021 runs. However, /proc/<pid>/fd shows no fd leak, nor any file descriptors with numbers higher than 12. The error coming out of gobject is:

twisted/internet/ Warning: poll(2) failed due to: Invalid argument.

Note: See TracTickets for help on using tickets.