[pygtk] Crash: gobject.IOChannel and threads enabled

Ole André Vadla Ravnås oleavr at gmail.com
Sun Oct 9 22:20:23 WST 2005


Hi,

gobject.IOChannel, introduced in 2.7.x/2.8.x seems to have a bug related to
threading. I've verified this with pygtk 2.8.0 (as the IOChannel code didn't
change from 2.8.0 -> 2.8.1 I didn't test 2.8.1).

The following testcase triggers the bug and results in SIGSEGV on my system:
--- 8< ---
import gobject
import gtk
import socket

def io_callback(chan, cond):
print "io_callback: exiting main loop"
gtk.main_quit()
return False

# threading enabled results in a crash,
# comment the following line to verify
gobject.threads_init()

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(False)
ch = gobject.IOChannel(s.fileno())
try:
s.connect(("www.pygtk.org <http://www.pygtk.org>", 80))
except socket.error, e:
pass
ch.add_watch(gobject.IO_OUT, io_callback)

print "running main loop"
gtk.main()
--- >8 ---

However, the following testcase, using gobject.io_add_watch (which uses an
IOChannel internally) doesn't result in a crash:
--- 8< ---
import gobject
import gtk
import socket

def io_callback(chan, cond):
print "io_callback: exiting main loop"
gtk.main_quit()
return False

gobject.threads_init()

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setblocking(False)
try:
s.connect(("www.pygtk.org <http://www.pygtk.org>", 80))
except socket.error, e:
pass
gobject.io_add_watch(s, gobject.IO_OUT, io_callback)

print "running main loop"
gtk.main()
--- >8 ---

Would be nice if someone could verify this. I'm working on debugging the
problem, but as I'm not familiar with the pygtk codebase it will probably
take some time. (I'll file a bug-report as soon as I get a verification that
this crash isn't related to something being broken on my system).

Ole André
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20051009/37fc8538/attachment.htm


More information about the pygtk mailing list