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 534083 - pygtk_main_watch_new() - wrong sizeof()
pygtk_main_watch_new() - wrong sizeof()
Status: RESOLVED FIXED
Product: pygtk
Classification: Bindings
Component: gtk
1.99.x/2.0.x
Other Linux
: Normal critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 531255 536517 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-05-20 17:59 UTC by Owen Taylor
Modified: 2008-06-03 22:13 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Owen Taylor 2008-05-20 17:59:18 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).
Comment 1 Johan (not receiving bugmail) Dahlin 2008-05-20 18:02:10 UTC
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.
Comment 2 Owen Taylor 2008-05-20 18:43:07 UTC
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.
Comment 3 Rémi Cardona 2008-05-28 12:49:10 UTC
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
Comment 4 Johan (not receiving bugmail) Dahlin 2008-05-28 13:01:11 UTC
*** Bug 531255 has been marked as a duplicate of this bug. ***
Comment 5 Josselin Mouette 2008-06-03 22:13:59 UTC
*** Bug 536517 has been marked as a duplicate of this bug. ***