import gtk:- undefined symbol: Py_InitModule4

Bug #282320 reported by nszabolcs
6
Affects Status Importance Assigned to Milestone
PyGTK
Fix Released
Medium
pygtk (Ubuntu)
Fix Released
Undecided
Loïc Minier

Bug Description

Binary package hint: python-gtk2

'import gtk', 'import pango',.. results in 'Segmentation fault'

with python2.5-dbg the result is:

$ python-dbg
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:16)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py", line 48, in <module>
    from gtk import _gtk
ImportError: /var/lib/python-support/python2.5/gtk-2.0/gtk/_gtk_d.so: undefined symbol: Py_InitModule4
[23400 refs]

it's ubuntu hardy on a 32bit machine:
$ lsb_release -rd
Description: Ubuntu 8.04.1
Release: 8.04

with most recent python, python-gtk2, libgtk2.0-0 packages:
$ dpkg-query -W python python-gtk2 libgtk2.0-0
libgtk2.0-0 2.12.9-3ubuntu4
python 2.5.2-0ubuntu1
python-gtk2 2.12.1-0ubuntu1

Tags: gtk python

Related branches

Revision history for this message
James Westby (james-w) wrote :

Hi,

bug 86685 looks kind of similar, but they are certainly different
issues.

Thanks,

James

Revision history for this message
nszabolcs (nszabolcs) wrote :

meanwhile i realized the same problem happens with every module that has a c extension (ie. a .so module) eg. Tkinter or sqlite

>>> import Tkinter
>>> Tkinter.Tk()
Segmentation fault

with python-dbg:

>>> import Tkinter
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 41, in <module>
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: /usr/lib/python2.5/lib-dynload/_tkinter.so: undefined symbol: Py_InitModule4, please install the python-tk package
[32869 refs]

the same happens when i use python2.4

(notice that the segfault does not happen immediately when i use non-debug python, with certain libs i could not produce segfaults while i still got the importerror in debug mode)

1 or 2 weeks ago everything worked fine and unfortunately i'm not sure what has been changed since then

so the bug is not pygtk related and i have no idea what could have caused it

Revision history for this message
Matthias Klose (doko) wrote :

install python-gtk2-dbg

Revision history for this message
Matthias Klose (doko) wrote :

> with python-dbg:
> >>> import Tkinter

is python-tk-dbg installed?

Revision history for this message
nszabolcs (nszabolcs) wrote :

python-gtk2-dbg was installed, but python-tk-dbg was not

i can't test tkinter right now (with running X), but i can confirm over ssh that it does not segfaults after import with installed python-tk-dbg
(same is true for sqlite: python-sqlite-dbg fixed the problem)

gtk however still has the problem:

$ dpkg-query -W python-gtk2-dbg
python-gtk2-dbg 2.12.1-0ubuntu1

$ python-dbg
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:16)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py", line 48, in <module>
    from gtk import _gtk
ImportError: /var/lib/python-support/python2.5/gtk-2.0/gtk/_gtk_d.so: undefined symbol: Py_InitModule4
[23397 refs]
>>>

i looked into the gtk,atk,pango,pangocairo modules with nm (these segfault after import) and compared the result to the builtin modules which work fine (/usr/lib/python2.5/lib-dynload/_*_d.so) and found the following:
those modules which work has the symbol
         U Py_InitModule4TraceRefs
while the gtk mudules has
         U Py_InitModule4
instead

hope this helps

Loïc Minier (lool)
Changed in pygtk:
assignee: nobody → lool
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pygtk - 2.13.0-0ubuntu6

---------------
pygtk (2.13.0-0ubuntu6) intrepid; urgency=low

  * Fix broken -I flags during build causing python*-dbg shared libs to be
    unusable; LP: #282320.
    - New patch, 65_bogus-python-includes, don't override PYTHON_INCLUDES,
      it's already set by AM_CHECK_PYTHON_HEADERS; GNOME #556130.
    - New patch, 90_autoconf, update configure by running autoconf && rm -rf
      autom4te.cache.

 -- Loic Minier <email address hidden> Mon, 13 Oct 2008 15:11:32 +0200

Changed in pygtk:
status: New → Fix Released
Changed in pygtk:
status: Unknown → New
Revision history for this message
nszabolcs (nszabolcs) wrote :
Download full text (3.7 KiB)

python*-dbg might be fixed but that's not the point
(who cares about dbg anyway..:)

the point is:

$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Segmentation fault

and it's _not_ the dbg version (dbg version might be broken as well), so the bug is _not_ fixed.

i'm not sure if it helps, but here is a backtrace:

(gdb) bt
#0 0x00000000 in ?? ()
#1 0xb75bbe98 in gdk_window_new () from /usr/lib/libgdk-x11-2.0.so.0
#2 0xb75981ad in gdk_display_open () from /usr/lib/libgdk-x11-2.0.so.0
#3 0xb7575a5d in gdk_display_open_default_libgtk_only () from /usr/lib/libgdk-x11-2.0.so.0
#4 0xb772c7df in gtk_init_check () from /usr/lib/libgtk-x11-2.0.so.0
#5 0xb7aad327 in ?? () from /var/lib/python-support/python2.5/gtk-2.0/gtk/_gtk.so
#6 0x080ca5c6 in PyEval_EvalFrameEx (f=0x83826d4, throwflag=0) at ../Python/ceval.c:3557
#7 0x080c96e5 in PyEval_EvalFrameEx (f=0x8217444, throwflag=0) at ../Python/ceval.c:3659
#8 0x080cb1f7 in PyEval_EvalCodeEx (co=0x81998d8, globals=0x81a09bc, locals=0x81a09bc, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at ../Python/ceval.c:2836
#9 0x080cb347 in PyEval_EvalCode (co=0x81998d8, globals=0x81a09bc, locals=0x81a09bc) at ../Python/ceval.c:494
#10 0x080dfdbc in PyImport_ExecCodeModuleEx (name=0xbffc4a67 "gtk", co=0x81998d8,
    pathname=0xbffc1967 "/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.pyc") at ../Python/import.c:675
#11 0x080e05bc in load_source_module (name=0xbffc4a67 "gtk", pathname=0xbffc1967 "/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.pyc",
    fp=0x8210ca8) at ../Python/import.c:959
#12 0x080e1bee in load_package (name=0xbffc4a67 "gtk", pathname=<value optimized out>) at ../Python/import.c:1015
#13 0x080e0b78 in import_submodule (mod=0x8147a18, subname=0xbffc4a67 "gtk", fullname=0xbffc4a67 "gtk") at ../Python/import.c:2400
#14 0x080e1037 in load_next (mod=0x8147a18, altmod=0x8147a18, p_name=<value optimized out>, buf=0xbffc4a67 "gtk", p_buflen=0xbffc4a60)
    at ../Python/import.c:2220
#15 0x080e1275 in import_module_level (name=0x0, globals=0xb7dac414, locals=<value optimized out>, fromlist=0x8147a18, level=-1)
    at ../Python/import.c:2001
#16 0x080e1717 in PyImport_ImportModuleLevel (name=0x81a8a34 "gtk", globals=0xb7da6acc, locals=0xb7da6acc, fromlist=0x8147a18, level=-1)
    at ../Python/import.c:2072
#17 0x080c2924 in builtin___import__ (self=0x0, args=0x81967d4, kwds=0x0) at ../Python/bltinmodule.c:47
#18 0x0805cb97 in PyObject_Call (func=0x1, arg=0x81967d4, kw=0x0) at ../Objects/abstract.c:1861
#19 0x080c2e9c in PyEval_CallObjectWithKeywords (func=0xb7d95e6c, arg=0x81967d4, kw=0x0) at ../Python/ceval.c:3442
#20 0x080c6757 in PyEval_EvalFrameEx (f=0x8210b5c, throwflag=0) at ../Python/ceval.c:2067
#21 0x080cb1f7 in PyEval_EvalCodeEx (co=0x81992a8, globals=0xb7da6acc, locals=0xb7da6acc, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
    defcount=0, closure=0x0) at ../Python/ceval.c:2836
#22 0x080cb347 in PyEval_EvalCode (co=0x81992a8, globals=0xb7da6acc, locals=0xb7da6acc) at ../Python/ceval....

Read more...

Revision history for this message
nszabolcs (nszabolcs) wrote :

python -c 'import gtk' still segfaults
(it turns out that python-dbg had an unrelated issue)

Changed in pygtk:
status: Fix Released → New
Revision history for this message
Loïc Minier (lool) wrote :

The original bug you reported was about a traceback in python-dbg; it was a real bug and has been fixed with python-dbg now.

It's quite confusing to deal with two issues in the same bug report, and "import gtk" works for me. Please file different bugs for different issues. :-/

Could you please attach a strace as well as the output of ldd /usr/lib/python-support/python-gtk2/python2.5/gtk-2.0/gtk/_gtk.so to the bug?

Thanks!

Revision history for this message
nszabolcs (nszabolcs) wrote :
Revision history for this message
nszabolcs (nszabolcs) wrote :
Revision history for this message
Loïc Minier (lool) wrote :

You seem to have a "win2pid.so" preloaded. Could you please try without?

Revision history for this message
nszabolcs (nszabolcs) wrote :

sorry, the preloaded .so was the problem
thank you for your help

Changed in pygtk:
status: New → Fix Released
Changed in pygtk:
status: New → Confirmed
Changed in pygtk:
status: Confirmed → Fix Released
Changed in pygtk:
importance: Unknown → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.