Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my self-built PyGObject segfault on importing Gtk or Gdk?

Tags:

python

gtk

Edit: I have tried importing almost every library represented in /usr/lib/girepository-1.0 through gi.repository and they all work except Gtk and Gdk. I have updated the title to reflect this.


I need a self-built PyGObject library to go with my self-built Python 3.3.3. I installed all the dependencies for PyGObject using sudo apt-get build-dep python3-gi. I found that the working system PyGObject version was 3.2.2, so I checked out version 3.2.2 of the source from the Git repo. I ran:

autoreconf --force --install
./configure --prefix=/home/tomas/.pyenv/versions/3.3.3
make
make install

Everything compiled and installed beautifully. I opened a fresh CMD and set the working directory to ~, then:

~$ python
Python 3.3.3 (default, Dec 21 2013, 23:12:28) 
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gtk
Segmentation fault (core dumped)
~$ 

I have set LD_LIBRARY_PATH to /home/tomas/.pyenv/versions/3.3.3/lib and checked that the correct library is being loaded:

~$ ldd .pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/_gi.so
    linux-vdso.so.1 =>  (0x00007fffcdf51000)
    libgirepository-1.0.so.1 => /usr/lib/libgirepository-1.0.so.1 (0x00007f45d8304000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f45d80b5000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f45d7dbf000)
    libpyglib-gi-2.0-python.so.0 => /home/tomas/.pyenv/versions/3.3.3/lib/libpyglib-gi-2.0-python.so.0 (0x00007f45d7bba000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f45d799d000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f45d75dc000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f45d72e0000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f45d70dc000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f45d6d8c000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f45d6b84000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f45d6947000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f45d673e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f45d877b000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f45d653a000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f45d6323000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f45d6103000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f45d5ee7000)

I also imported the module with python -vv: Pastebin

The last few lines reveals that the core dump happens right after importing gi.repository.Atk:

# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.cpython-33m.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.abi3.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.py
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/repository/Atk.pyc
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.cpython-33m.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.abi3.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.so
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.py
# trying /home/tomas/.pyenv/versions/3.3.3/lib/python3.3/site-packages/gi/overrides/Atk.pyc
import 'gi.repository.Atk' # 
Segmentation fault (core dumped)

Importing just gi.repository.Atk doesn't segfault.

I have also tried removing the system version of the library (sudo dpkg -P python3-gi) in case it was interfering in some way.


I don't know what else to do. Does anybody know or have any idea what the problem might be? Please leave a comment if you have an idea of something I could try or if I can provide more information.

like image 233
Hubro Avatar asked Jan 07 '14 15:01

Hubro


1 Answers

PyGObject has strong prerequisites about Glib and Python.

For what it worth, I batch-build various combination sets in order to find the working ones.

Please note that, as Simon Feltman explained in a comment below, pycairo is not a strict dependency and might be disabled using the --enable-cairo=no configure option. It appears only here as I've performed those tests using the default build options.

Here are the results on my Debian Wheezy/Wheezy-backports system (GLib 2.33):

python      pygobject   pycairo     compile           ... import Gtk    

3.1         3.0         1.0         NO (pycairo)                        
3.1         3.0         1.10        YES               OK                
3.1         3.0         1.2         NO (pycairo)                        
3.1         3.0         1.4         NO (pycairo)                        
3.1         3.0         1.6         NO (pycairo)                        
3.1         3.0         1.8         NO (pycairo)                        
3.1         3.2         1.0         NO (pycairo)                        
3.1         3.2         1.10        YES               OK                
3.1         3.2         1.2         NO (pycairo)                        
3.1         3.2         1.4         NO (pycairo)                        
3.1         3.2         1.6         NO (pycairo)                        
3.1         3.2         1.8         NO (pycairo)                        
3.1         3.4         1.0         NO (pycairo)                        
3.1         3.4         1.10        NO (pygobject)                      
3.1         3.4         1.2         NO (pycairo)                        
3.1         3.4         1.4         NO (pycairo)                        
3.1         3.4         1.6         NO (pycairo)                        
3.1         3.4         1.8         NO (pycairo)                        
3.1         3.6         1.0         NO (pycairo)                        
3.1         3.6         1.10        NO (pycairo)                        
3.1         3.6         1.2         NO (pycairo)                        
3.1         3.6         1.4         NO (pycairo)                        
3.1         3.6         1.6         NO (pycairo)                        
3.1         3.6         1.8         NO (pycairo)                        
3.1         3.8         1.0         NO (pycairo)                        
3.1         3.8         1.10        NO (pygobject)                      
3.1         3.8         1.2         NO (pycairo)                        
3.1         3.8         1.4         NO (pycairo)                        
3.1         3.8         1.6         NO (pycairo)                        
3.1         3.8         1.8         NO (pycairo)                        
3.2         3.0         1.0         NO (pycairo)                        
3.2         3.0         1.10        YES               OK                
3.2         3.0         1.2         NO (pycairo)                        
3.2         3.0         1.4         NO (pycairo)                        
3.2         3.0         1.6         NO (pycairo)                        
3.2         3.0         1.8         NO (pycairo)                        
3.2         3.2         1.0         NO (pycairo)                        
3.2         3.2         1.10        YES               OK                
3.2         3.2         1.2         NO (pycairo)                        
3.2         3.2         1.4         NO (pycairo)                        
3.2         3.2         1.6         NO (pycairo)                        
3.2         3.2         1.8         NO (pycairo)                        
3.2         3.4         1.0         NO (pycairo)                        
3.2         3.4         1.10        NO (pygobject)                      
3.2         3.4         1.2         NO (pycairo)                        
3.2         3.4         1.4         NO (pycairo)                        
3.2         3.4         1.6         NO (pycairo)                        
3.2         3.4         1.8         NO (pycairo)                        
3.2         3.6         1.0         NO (pycairo)                        
3.2         3.6         1.10        NO (pycairo)                        
3.2         3.6         1.2         NO (pycairo)                        
3.2         3.6         1.4         NO (pycairo)                        
3.2         3.6         1.6         NO (pycairo)                        
3.2         3.6         1.8         NO (pycairo)                        
3.2         3.8         1.0         NO (pycairo)                        
3.2         3.8         1.10        NO (pygobject)                      
3.2         3.8         1.2         NO (pycairo)                        
3.2         3.8         1.4         NO (pycairo)                        
3.2         3.8         1.6         NO (pycairo)                        
3.2         3.8         1.8         NO (pycairo)                        
3.3         3.0         1.0         NO (pycairo)                        
3.3         3.0         1.10        YES               SEGMENTATION FAULT
3.3         3.0         1.2         NO (pycairo)                        
3.3         3.0         1.4         NO (pycairo)                        
3.3         3.0         1.6         NO (pycairo)                        
3.3         3.0         1.8         NO (pycairo)                        
3.3         3.2         1.0         NO (pycairo)                        
3.3         3.2         1.10        YES               SEGMENTATION FAULT
3.3         3.2         1.2         NO (pycairo)                        
3.3         3.2         1.4         NO (pycairo)                        
3.3         3.2         1.6         NO (pycairo)                        
3.3         3.2         1.8         NO (pycairo)                        
3.3         3.4         1.0         NO (pycairo)                        
3.3         3.4         1.10        NO (pygobject)                      
3.3         3.4         1.2         NO (pycairo)                        
3.3         3.4         1.4         NO (pycairo)                        
3.3         3.4         1.6         NO (pycairo)                        
3.3         3.4         1.8         NO (pycairo)                        
3.3         3.6         1.0         NO (pycairo)                        
3.3         3.6         1.10        NO (pycairo)                        
3.3         3.6         1.2         NO (pycairo)                        
3.3         3.6         1.4         NO (pycairo)                        
3.3         3.6         1.6         NO (pycairo)                        
3.3         3.6         1.8         NO (pycairo)                        
3.3         3.8         1.0         NO (pycairo)                        
3.3         3.8         1.10        NO (pygobject)                      
3.3         3.8         1.2         NO (pycairo)                        
3.3         3.8         1.4         NO (pycairo)                        
3.3         3.8         1.6         NO (pycairo)                        
3.3         3.8         1.8         NO (pycairo)   

Many combinations just won't build because they require a more recent version of GLib than available on my system. In some cases, the setup.py script require python-2, hence the installation process failed on a python-3 only environment. I didn't take take time to understand why some combinations result in a segmentation fault at run-time.

As you can see, your best bet (at least today on Debian) is to build pycairo-1.10 + pygobject-3.2 + python 3.2. anything more up to date will require at least a more recent version of GLib...

like image 96
Sylvain Leroux Avatar answered Nov 17 '22 05:11

Sylvain Leroux