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 623965 - pygtk-2.16.0 causes python-2.7 to segfault if warning settings are changed from default to "error"
pygtk-2.16.0 causes python-2.7 to segfault if warning settings are changed fr...
Status: RESOLVED WONTFIX
Product: pygtk
Classification: Bindings
Component: gtk
2.16.x
Other Linux
: Normal major
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2010-07-09 17:02 UTC by Mike Auty
Modified: 2018-08-17 13:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to conditionally port to the PyCapsule API on 2.7 and later (1.50 KB, patch)
2010-08-12 17:43 UTC, Dave Malcolm
none Details | Review

Description Mike Auty 2010-07-09 17:02:40 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
  • #0 PyDict_SetItem
    at Objects/dictobject.c line 773
  • #1 PyDict_SetItemString
    at Objects/dictobject.c line 2406
  • #2 init_gtk
    at gtkmodule.c line 234
  • #3 _PyImport_LoadDynamicModule
    at ./Python/importdl.c line 53
  • #4 load_module
    at Python/import.c line 1834
  • #5 import_submodule
    at Python/import.c line 2596
  • #6 ensure_fromlist
    at Python/import.c line 2507
  • #7 import_module_level
    at Python/import.c line 2175
  • #8 PyImport_ImportModuleLevel
    at Python/import.c line 2189
  • #9 builtin___import__
    at Python/bltinmodule.c line 49
  • #10 PyCFunction_Call
    at Objects/methodobject.c line 85
  • #11 PyObject_Call
    at Objects/abstract.c line 2522
  • #12 PyEval_CallObjectWithKeywords
    at Python/ceval.c line 3881
  • #13 PyEval_EvalFrameEx
    at Python/ceval.c line 2332
  • #14 PyEval_EvalCodeEx
    at Python/ceval.c line 3252
  • #15 PyEval_EvalCode
    at Python/ceval.c line 666
  • #16 PyImport_ExecCodeModuleEx
    at Python/import.c line 681
  • #17 load_source_module
    at Python/import.c line 1021
  • #18 load_package
...
Comment 1 Dave Malcolm 2010-08-12 15:39:39 UTC
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").
Comment 2 Dave Malcolm 2010-08-12 15:41:45 UTC
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
Comment 3 Dave Malcolm 2010-08-12 17:39:29 UTC
pygobject seems to have a similar issue, alas:
http://git.gnome.org/browse/pygobject/tree/gobject/pygobject.h
Comment 4 Dave Malcolm 2010-08-12 17:43:29 UTC
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.
Comment 5 Dave Malcolm 2010-08-12 23:34:54 UTC
(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.
Comment 6 John Stowers 2010-09-27 05:23:31 UTC
Are you guys shipping this patch in Fedora?
Comment 7 Dave Malcolm 2010-09-27 14:25:05 UTC
(In reply to comment #6)
> Are you guys shipping this patch in Fedora?
IIRC we aren't yet.
Comment 8 Ionut Biru 2010-10-07 13:19:35 UTC
@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
Comment 9 Mark 2010-12-22 03:45:28 UTC
(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)
Comment 10 Mark 2010-12-24 16:58:40 UTC
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
Comment 11 André Klapper 2018-08-17 13:43:01 UTC
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!