Ubuntu

Segmentation fault when asking help() for the list of modules

Reported by onesandzeroes on 2011-11-27
614
This bug affects 74 people
Affects Status Importance Assigned to Milestone
PyGTK
New
Undecided
Unassigned
Python
New
Undecided
Unassigned
pygtk (Ubuntu)
Medium
Unassigned
python2.7 (Ubuntu)
Medium
Unassigned

Bug Description

Using Python 2.7.2 on Oneiric (package version is 2.7.2-7ubuntu2), I'm getting a consistent segmentation fault when I open the interactive help in a Python shell (i.e. typing "help()" in the shell) and then ask for the list of modules (by typing "modules").

The error code returned is as follows:
Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:5116): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault

Hans Joachim Desserud (hjd) wrote :

I get the same error on Ubuntu 11.10. Listing "topics" or "keywords" works without problems though.

Changed in python2.7 (Ubuntu):
status: New → Confirmed
Alain Kalker (miki4242) wrote :

From Googling around, this looks to me quite similar to the problem described here: http://blog.rabbitvcs.org/archives/312

The author points to the cause of a mixture of modules with both static and dynamic gtk bindings being active at the same time.

Because `help()` (and pydoc for that matter) iterate over all modules, actually importing them to get at the documentation, I believe that this causes a similar incompatible mixture of 'active' modules to occur.

Can anyone confirm that this is actually the case?

-ack

Robert Jamison (rwjamiso) wrote :

After installing matplotlib from the default oneiric repos, I was also getting the exact error in Bug Description above while executing help() modules. Also I was unable to 'import gtk'. Installing gtk2-engines-pixbuf changed the above error to this:

python2.7.2
import gtk
help()
modules
>
/usr/lib/python2.7/dist-packages/Onboard/__init__.py:2: Warning: cannot register existing type `GdkDisplayManager'
  import osk
/usr/lib/python2.7/dist-packages/Onboard/__init__.py:2: Warning: g_once_init_leave: assertion `initialization_value != 0' failed
  import osk
/usr/lib/python2.7/dist-packages/Onboard/__init__.py:2: Warning: g_type_register_static: assertion `parent_type > 0' failed
  import osk
/usr/lib/python2.7/dist-packages/Onboard/__init__.py:2: Warning: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
  import osk

....hung process

FWIW

Nancy Jones (lumpybird) wrote :

I get exactly the same segmentation fault described above on Ubuntu 11.10 using python 2.7. Does anyone have a solution?

Piet Delport (pjdelport) wrote :

There's an apport report and stack trace in LP #921383

To repeat my comment from there: according to the trace, the crash seems to be happening under this debug print:

#0 __find_specmb (format=0x7f39f1f40732 "%s: assertion `%s' failed") at printf-parse.h:99

which is triggering unbounded recursion involving the following loop:

...
#10 pygobject_lookup_class (gtype=0) at /build/buildd/pygobject-2-2.28.6/gobject/pygobject.c:894
#11 0x00007f39e88b9032 in pyg_type_get_bases (gtype=0) at /build/buildd/pygobject-2-2.28.6/gobject/pygobject.c:659
#12 0x00007f39e88b90e2 in pygobject_new_with_interfaces (gtype=0) at /build/buildd/pygobject-2-2.28.6/gobject/pygobject.c:702
#13 0x00007f39e88b8fe5 in pygobject_lookup_class (gtype=0) at /build/buildd/pygobject-2-2.28.6/gobject/pygobject.c:913
#14 pygobject_lookup_class (gtype=0) at /build/buildd/pygobject-2-2.28.6/gobject/pygobject.c:894
...

Govind Tatachari (osstacker) wrote :

This is regarding bug #896836: "Using Python 2.7.2 on Oneiric (package version is 2.7.2-7ubuntu2), I'm getting a consistent segmentation fault when I open the interactive help in a Python shell (i.e. typing "help()" in the shell) and then ask for the list of modules (by typing "modules")."

A somewhat verbose trace seems to indicate that the culprit is "atk.so" i.e.:
===========
import gtk # directory /usr/lib/python2.7/dist-packages/gtk-2.0/gtk
# /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.pyc matches /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py
import gtk # precompiled from /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.pyc
dlopen("/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/_gtk.so", 2);
dlopen("/usr/lib/python2.7/dist-packages/gtk-2.0/pango.so", 2);
import pango # dynamically loaded from /usr/lib/python2.7/dist-packages/gtk-2.0/pango.so
dlopen("/usr/lib/python2.7/dist-packages/gtk-2.0/atk.so", 2);
import atk # dynamically loaded from /usr/lib/python2.7/dist-packages/gtk-2.0/atk.so
Segmentation fault
============
Not sure where to look for a fix for this bug #896836 filed by onesandzeroes way back on 2011-11-27.

Jared Buckley (buckjrdley) wrote :

I have encountered this same bug in precise as well. Same error message ending with segmentation fault.

Alexandr Novel (normalex) wrote :

The following blog post clearly describes the problem

http://blog.rabbitvcs.org/archives/312

To verify that you can simply logout, alt+f1 to drop to text console, login and repeat the pydoc command.

This time it will work with the following warning message.

(python2.7:13084): Gdk-WARNING **: cannot open display:
pydoc - Generate Python documentation in HTML or text for interactive use.
pydoc_data
pydoc_data.topics

Hobson Lane (hobs) wrote :

It seems like ack's comment points the finger at the help() function within ipython. Has anyone tried to modify it so it doesn't simultaneously load modules with static and dynamic links to _gtk? Or is the problem in _gtk that it can't handle the simultaneous static and dynamic linking? Anyone working this?

tags: added: oneiric precise
Curtis Hovey (sinzui) on 2012-08-07
affects: python → obsolete-junk
no longer affects: obsolete-junk

The simplest combination of modules I can find that causes the segfault (presumably due to the mixture of static and dynamic bindings for the gtk module described above) is:

python -c 'import Onboard; import gtk '

/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:42: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:7386): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:42: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:42: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
zsh: segmentation fault python -c 'import Onboard; import gtk '

After removing the 'onboard' package, "pydoc -k" will get much further through the list of packages when searching, but now eventually hangs for me. strace shows it seems to be a race condition on a futex in atk:

stat("libgdk-3.so.0.la", 0x7fffe38aff70) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/girepository-1.0", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
getdents(5, /* 98 entries */, 32768) = 4152
open("/usr/lib/girepository-1.0/Atk-1.0.typelib", O_RDONLY) = 14
fstat(14, {st_mode=S_IFREG|0644, st_size=63688, ...}) = 0
mmap(NULL, 63688, PROT_READ, MAP_PRIVATE, 14, 0) = 0x7f23dabdf000
close(14) = 0
getdents(5, /* 0 entries */, 32768) = 0
close(5) = 0
munmap(0x7f23dabdf000, 63688) = 0
stat("/usr/lib/python2.7/dist-packages/gi/overrides/Atk", 0x7fffe38a9120) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/dist-packages/gi/overrides/Atk.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/dist-packages/gi/overrides/Atkmodule.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/dist-packages/gi/overrides/Atk.py", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/python2.7/dist-packages/gi/overrides/Atk.pyc", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("libatk-1.0.so.0", 0x7fffe38aded0) = -1 ENOENT (No such file or directory)
stat("libatk-1.0.so.0.so", 0x7fffe38aded0) = -1 ENOENT (No such file or directory)
stat("libatk-1.0.so.0.la", 0x7fffe38aded0) = -1 ENOENT (No such file or directory)
futex(0x171de84, FUTEX_WAIT_PRIVATE, 1, NULL

Vistaus (djmusic121) wrote :

I can confirm this bug on 12.10

As someone in a prior bug-report discovered that uncommenting line 27 in dist-packages/gobject/constants.py cures the crash.
Actually that line makes no sense as a python statement, but just listing the variable name TYPE_INVALID, without assigning any value in constants.py (which the comment there states is defined in gobjectmodule.c) eliminates the crash.

This would seem to discredit the theory that simultaneous loading of static and dynamic bindings is to blame.

Does the variable NEED to be declared in the python even if it's value is assinge in a .c file in order to work ?
I'm not knowledgable about the inner workings of the python language.
Is this a valid fix?

Joshua Tasker (jtasker) wrote :

@12, that's not a valid fix, it breaks other things (in my case, causes systemd.py to crash with a SyntaxError)

Alec Warner (antarus) wrote :

On precise we hit this with gtk and osk (part of Onboard.)

Manually importing gtk causes the segfault to go away, but nothing happens.

The segfault can also be reproduced by:

$ python
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Onboard import osk
>>> import gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 from gtk import _gtk

** (python:24631): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
 from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
 from gtk import _gtk
Segmentation fault (core dumped)

So, importing gtk after osk from Onboard causes a segfault.

mdyn (tamerlaha-gmail) wrote :

12.04.01 the same problem
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:23511): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

mrainb0w (annamalai-gurusami) wrote :

I am also affected by this same problem. My Ubuntu One has stopped working when I upgraded from 11.10 to 12.04. Let me know if there are any work arounds.

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
$

Grzegorz (rentorechovo) wrote :

Ubuntu 12.04.2 LTS

python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: specified class size for type `PyGtkGenericCellRenderer' is smaller than the parent type's `GtkCellRenderer' class size
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

Joao Paredes (paredesjoao) wrote :

Ubuntu 12.04.3 LTS

python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7! This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics". Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> modules

Please wait a moment while I gather a list of all available modules...

/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:12949): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

Leonard De Baets (lnrddbts376) wrote :
Download full text (10.4 KiB)

In case nobody has noticed it, in ubuntu 12.04.3 LTS, when I first import gtk and then list the modules using help, the segmentation fault does not occur. I suspect it has to do with the static/dynamic nature of the module being visible. See the terminal capture below as evidence:

$ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

ANSI _codecs_jp formencode profile
ArgImagePlugin _codecs_kr fpectl pstats
BaseHTTPServer _codecs_tw fpformat pty
Bastion _collections fractions pwd
BdfFontFile _csv ftplib pxssh
BmpImagePlugin _ctypes functools py_compile
BufrStubImagePlugin _ctypes_test future_builtins pyclbr
CDROM _curses gc pycurl
CGIHTTPServer _curses_panel gconf pydoc
Canvas _dbus_bindings gdbm pydoc_data
CommandNotFound _dbus_glib_bindings gencat pyexpat
ConfigParser _elementtree genericpath pyflakes
ContainerIO _functools genevents pygst
Cookie _hashlib genfind pygtk
Crypto _heapq gengrep pyinotify
CurImagePlugin _hotshot genlog pynotify
DLFCN _imaging genmessages query404
DcxImagePlugin _imagingcms genmulti quopri
Dialog _imagingft genopen random
DistUpgrade _imagingmath genpickle re
DocXMLRPCServer _io genqueue readline
EpsImagePlugin _json genreceive realtime404
ExifTags _locale genshutdown receivefrom
FSM _lsprof gentrace recvcount
FileDialog _multibytecodec getopt redict
FitsStubImagePlugin _multiprocessing getpass repr
FixTk _pyio gettext resource
FliImagePlugin _random gi retuple
FontFile _snack gio rexec
Formtools _socket glib rfc822
FpxImagePlugin _sqlite3 glob rlcompleter
GMenuSimpleEditor _sre gmenu robotparser
GbrImagePlugin _ssl gnomekeyring robots
GdImageFile _strptime gobject runpy
GifImagePlugin _struct google runservers
GifImagePluginH _symtable grp sched
GimpGradientFile _testcapi gst screen
GimpPaletteFile...

information type: Public → Public Security
Daniel Hahler (blueyed) on 2014-02-17
Changed in python2.7 (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Medium
Daniel Hahler (blueyed) wrote :

I can confirm that first importing gtk in "/usr/bin/pydoc" works around `pydoc -k .` crashing.

Changed in pygtk (Ubuntu):
status: New → Triaged
importance: Undecided → Medium

Ubuntu 12.10

 am facing following traceback while using command for displaying list of modules of python.

~$ python
Python 2.7.3 (default, Sep 26 2013, 20:08:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help('modules')

Please wait a moment while I gather a list of all available modules...

matplotlib must be installed in order to use SimplePlot!
An error occured setting up the themes: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
An error occured setting up the themes: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  import gobject._gobject
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
  from gtk import _gtk

** (python:5733): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice'
  from gtk import _gtk
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed
  from gtk import _gtk
Segmentation fault (core dumped)

To post a comment you must log in.
This report contains Public Security information  Edit
Everyone can see this security related information.

Other bug subscribers