GNOME Bugzilla – Bug 534083
pygtk_main_watch_new() - wrong sizeof()
Last modified: 2008-06-03 22:13:59 UTC
This was found debugging a crash with Johannes Jensen In gtk.override: static GSource * pygtk_main_watch_new(void) { return g_source_new(&pygtk_main_watch_funcs, sizeof(GSource)); } But the returned source is used as a PySignalWatchSource ... e.g.: static gboolean pygtk_main_watch_prepare(GSource *source, int *timeout) { PySignalWatchSource *real_source = (PySignalWatchSource *)source; So memory is corrupted. (This was observed on x86_64, might conceivably coincidentally work in x86, though I wouldn't expect it since there are a lot of extra fields in PySignalWatchSource) The fix is to change the above sizeof(GSource) to sizeof(PySignalWatchSource).
Owen: Feel free to check in a patch which solves this, I cannot personally test this as I do not have access to a 64-bit machine.
This change was tested by Johannes earlier to fix his problem. I haven't seen the crash myself even on my x86_64 system, but the valgrind output and bug in the code are clear. 2008-05-20 Owen Taylor <otaylor@redhat.com> * gtk/gtk.override: Allocate the right amount of memory for PySignalWatchSource, fixing memory corruption. (bug #534083) I haven't checked if this needs backporting to older branches.
Could this patch be applied to the 1.12.x branch? Applying this patch directly on top of 1.12.1 fixes Gentoo Bug #209531 http://bugs.gentoo.org/209531 Thanks
*** Bug 531255 has been marked as a duplicate of this bug. ***
*** Bug 536517 has been marked as a duplicate of this bug. ***