GNOME Bugzilla – Bug 623965
pygtk-2.16.0 causes python-2.7 to segfault if warning settings are changed from default to "error"
Last modified: 2018-08-17 13:43:01 UTC
Hi there, I upgraded to python-2.7 to help test it out for my distribution, and most everything seems fine, except virt-manager. On closer investigation I've managed to isolate the following test case: Python 2.7 (r27:82500, Jul 6 2010, 15:43:32) [GCC 4.4.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import warnings >>> warnings.filterwarnings('error', module='gtk') >>> import gtk Segmentation fault Without the warnings filter, import gtk works just fine. I'm really not clear what's going on, but the backtrace (below) seems to suggest it occurs in gtk/gtkmodule.c, at the line: /* extension API */ PyDict_SetItemString(d, "_PyGtk_API", o=PyCObject_FromVoidPtr(&functions, NULL)); I'm afraid that's as far as I can get to, because I've no idea why it's going on. I think, however, that CObjects have been deprecated in 2.7, and that capsules are the recommended replacement (I found this out from D-bus, which gives the following warning on import - PendingDeprecationWarning: The CObject type is marked Pending Deprecation in Python 2.7. Please use capsule objects instead.) If there's any further information I can provide, please let me know. Software versions: python-2.7 pygtk-2.16.0 pygobject-2.21.1 gtk+-2.20.1 Backtrace: Program received signal SIGSEGV, Segmentation fault. PyDict_SetItem (op=0xb78043e4, key=0xb7c09580, value=0x0) at Objects/dictobject.c:773 773 Objects/dictobject.c: No such file or directory. in Objects/dictobject.c (gdb) bt
+ Trace 222772
...
We're seeing this downstream within Fedora. Downstream bug report: https://bugzilla.redhat.com/show_bug.cgi?id=621887 which links to a few other instances of this. (There's a workaround for virt-manager in https://bugzilla.redhat.com/show_bug.cgi?id=620216 , FWIW) Switching status from UNCONFIRMED to NEW; hope that's OK. I can try to create a patch, but unfortunately the affected code is in a macro: http://git.gnome.org/browse/pygtk/tree/gtk/pygtk.h rather than in a function (presumably so that it can write to the global "_PyGtk_API").
https://bugzilla.redhat.com/show_bug.cgi?id=620216 has more discussion on how the segfault happens. Documentation on the Python change can be seen at: http://docs.python.org/dev/whatsnew/2.7.html#capsules
pygobject seems to have a similar issue, alas: http://git.gnome.org/browse/pygobject/tree/gobject/pygobject.h
Created attachment 167753 [details] [review] Patch to conditionally port to the PyCapsule API on 2.7 and later (very) lightly tested; was able to step through the import of gtk.glade and it seemed to get the API pointers correctly.
(In reply to comment #3) > pygobject seems to have a similar issue, alas: > http://git.gnome.org/browse/pygobject/tree/gobject/pygobject.h I've filed bug 626785 against pygobject to cover this.
Are you guys shipping this patch in Fedora?
(In reply to comment #6) > Are you guys shipping this patch in Fedora? IIRC we aren't yet.
@Dave we are using that patch in archlinux and is fixing all related problems. Just a heads up, is breaking the api and some packages need to be rebuilt
(In reply to comment #1) > We're seeing this downstream within Fedora. > > Downstream bug report: > https://bugzilla.redhat.com/show_bug.cgi?id=621887 > which links to a few other instances of this. > > (There's a workaround for virt-manager in > https://bugzilla.redhat.com/show_bug.cgi?id=620216 , FWIW) > > Switching status from UNCONFIRMED to NEW; hope that's OK. > > I can try to create a patch, but unfortunately the affected code is in a macro: > http://git.gnome.org/browse/pygtk/tree/gtk/pygtk.h > rather than in a function (presumably so that it can write to the global > "_PyGtk_API"). I am seeing the same issue launching virt-manager. python: /builddir/build/BUILD/Python-2.7/Objects/dictobject.c:759: PyDict_SetItem: Assertion `value' failed. Aborted (core dumped)
python Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import warnings >>> warnings.filterwarnings('error', module='gtk') >>> import gtk python: /builddir/build/BUILD/Python-2.7/Objects/dictobject.c:759: PyDict_SetItem: Assertion `value' failed. Aborted (core dumped) [root@lotus src]# [root@lotus src]# [root@lotus src]# uname -a Linux lotus 2.6.35.9-64.fc14.i686 #1 SMP Fri Dec 3 12:35:42 UTC 2010 i686 i686 i386 GNU/Linux
pygtk is not under active development anymore and had its last code changes in 2013. Its codebase has been archived: https://gitlab.gnome.org/Archive/pygtk/commits/master PyGObject at https://gitlab.gnome.org/GNOME/pygobject is its successor. See https://pygobject.readthedocs.io/en/latest/guide/porting.html for porting info. Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Feel free to open a task in GNOME Gitlab if the issue described in this task still applies to a recent version of PyGObject. Thanks!