Segfault starting with 2.16.1-0ubuntu2 using Python 2.5

Bug #334784 reported by Severin H
2
Affects Status Importance Assigned to Milestone
LottaNZB
Invalid
Undecided
Unassigned
pygobject (Ubuntu)
Invalid
Medium
Unassigned

Bug Description

A few days ago, the development version of the PyGTK application LottaNZB 0.5 (https://code.edge.launchpad.net/~lottanzb/lottanzb/main) stopped working because of a segmentation fault during startup. I was able to track down the problem:

2.16.1-0ubuntu1: Works fine both using Python 2.5 and Python 2.6.
2.16.1-0ubuntu2 when launching the application using Python 2.5: Segmentation fault.
2.16.1-0ubuntu2 when launching the application using Python 2.6: Works fine.

I wasn't able to produce a simple demonstration of the Python 2.5 problem yet, but in our code the situation is as follows:

class GObjectSingletonMeta(GObjectMeta):
    """GObject singleton metaclass"""

    def __init__(mcs, name, bases, _dict):
        # THIS IS WHERE THE APPLICATION SEGFAULTS.
        GObjectMeta.__init__(mcs, name, bases, _dict)
        mcs.__instance = None

    def __call__(mcs, *args, **kwargs):
        """Creates an instance of mcs if it doesn't exist yet"""

        if mcs.__instance is None:
            mcs.__instance = GObjectMeta.__call__(mcs, *args, **kwargs)

        return mcs.__instance

class App(GObject, kiwi.environ.Application):
    __metaclass__ = GObjectSingletonMeta

    lock = property(type=object)

    [...]

It's possible to prevent the application from segfaulting in the singleton metaclass by *either* removing the Application parent class from the App class or by removing all GObject properties from the App class.

I'm using an up-to-date Jaunty amd64 machine. I only exchanged the python-gobject package for the tests.

I'll try to provide further information about the problem and I wonder if someone else can reproduce this. You can try to reproduce the problem by branching the project and running ./run-lottanzb.sh (which will run the application using Python 2.5 by default).

Revision history for this message
Severin H (severinh) wrote :

Changelog of python-gobject_2.16.1-0ubuntu2: https://edge.launchpad.net/ubuntu/jaunty/+source/pygobject/2.16.1-0ubuntu2

  * Remove explicit dependencies on python2.5.
  * Rename -dbg extensions for python2.6 as well. LP: #333557.

Revision history for this message
Severin H (severinh) wrote :

I seem to have found a solution. Right now, the GObjectSingletonMeta metaclass is part of the util module. Moving it to the core module where it is actually used by the App class solved the problem. This is totally weird.

I was able to create a simple script that demonstrates the problem. demo.py and demo_util.py. Install the python-kiwi package (!). Run demo.py using Python 2.5 and the latest python-gobject package (2.16.1-0ubuntu2). Make sure that the demo_util.py file is in the same directory.

Revision history for this message
Severin H (severinh) wrote :

Forgot to remove unnecessary stuff from the demo.py file. Download this one and not the one above.

Revision history for this message
Severin H (severinh) wrote :

...and the demo_util.py file.

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

2.16.1-0ubuntu1 and 2.16.1-0ubuntu2 don't have any code changes; are you sure that you didn't use 2.15.x before?

Revision history for this message
Severin H (severinh) wrote :

The most interesting thing about it is that the order of the three import statements in demo.py has an effect on what happens:

# Finally leads to the segfault described in this bug report.
from kiwi.environ import Application
from gobject import property, GObject
from demo_util import GObjectSingletonMeta

# Everything works fine
from gobject import property, GObject
from kiwi.environ import Application
from demo_util import GObjectSingletonMeta

# Raises
# Exception exceptions.TypeError: 'could not get typecode from object' in <module 'threading' from '/usr/lib/python2.5/threading.pyc'> ignored
from gobject import property, GObject
from demo_util import GObjectSingletonMeta
from kiwi.environ import Application

Can anyone confirm this behaviour?

Revision history for this message
Severin H (severinh) wrote :

@Matthias:

I've downloaded the required files from https://edge.launchpad.net/ubuntu/jaunty/+source/pygobject/2.16.1-0ubuntu1, built it using dpkg-source -x and installed the package using dpkg --install --force-all (which replaced the ubuntu2 version). Everything was fine after this. Upgrading back to ubuntu2 using apt-get upgrade reintroduced the bug.

Revision history for this message
Severin H (severinh) wrote :

lantash@gauss:~/Desktop$ python demo.py # Using 2.16.1-0ubuntu2.
Segmentation fault (core dumped)

lantash@gauss:~/Desktop$ sudo dpkg --install --force-all python-gobject_2.16.1-0ubuntu1_amd64.deb
[...]
Vorbereiten zum Ersetzen von python-gobject 2.16.1-0ubuntu2 (durch python-gobject_2.16.1-0ubuntu1_amd64.deb) ...
[...]

lantash@gauss:~/Desktop$ python demo.py

lantash@gauss:~/Desktop$ sudo apt-get upgrade
[...]
Vorbereiten zum Ersetzen von python-gobject 2.16.1-0ubuntu1 (durch .../python-gobject_2.16.1-0ubuntu2_amd64.deb) ...
[...]

lantash@gauss:~/Desktop$ python demo.py
Segmentation fault (core dumped)

Revision history for this message
Severin H (severinh) wrote :

Sorry for bothering you once more. I'm not quite sure what to think about it. In addition to the ubuntu1, I built the ubuntu2 pacakge by myself a few minutes ago, and now it looks as if the application segfaults if either the self-built ubuntu1 package (why did this work before?!) or the official ubuntu2 package is used. Running the application using my own ubuntu2 build works fine.

I just commited a "fix" described above for this problem to the LottaNZB development branch, so that at least this application can be started again on Jaunty.

If noone can reproduce this bug using the demo files one might consider marking this bug as invalid or incomplete for the moment.

Revision history for this message
Severin H (severinh) wrote :

According to a message by Matthias Klose in ubuntu-devel, the Python interpreter will be updated from 2.5.4 to 2.6 within the next days and numerous packages will be rebuilt for that purpose. Since the bug only affects Python 2.5 I assume that everything will be fine after the transition. I'll problably make a clean install a couple of days after Alpha 5.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Please try to obtain a backtrace following the instructions at http://wiki.ubuntu.com/DebuggingProgramCrash and upload the backtrace (as an attachment) to the bug report. This will greatly help us in tracking down your problem.

Changed in pygobject:
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
Severin H (severinh) wrote :

This bug has somehow been fixed. As I mentioned above, LottaNZB works just fine using Python 2.6.

Changed in lottanzb:
status: New → Invalid
Changed in pygobject (Ubuntu):
status: Incomplete → Invalid
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.