Bug#665359: python3-gi: Segfault when computing size of subclasses

Martin Pitt mpitt at debian.org
Thu May 3 10:15:48 UTC 2012

reassign 665359 python3.2 3.2.3~rc2-1

After a multiple-days debugging orgy I finally found what's triggering this.
Please see https://bugzilla.gnome.org/show_bug.cgi?id=669157 for the whole
story, but copying the last comment here for convenience:

The Debian package runs this snippet between configure and make, to configure
static (builtin) vs. dynamic (extensions) modules:

        egrep \
          "^#($$(awk -v ORS='|' '$$2 ~ /^extension$$/ {print $$1}'
debian/PVER-minimal.README.Debian.in)XX)" \
          Modules/Setup.dist \
            | sed -e 's/^#//' -e 's/-Wl,-Bdynamic//;s/-Wl,-Bstatic//' \
            >> $(1)/Modules/Setup.local

When I disable this part, the local build works.

That code results in this Modules/Setup.local:

----------------- 8< ---------------------
# Edit this file for local setup changes
array arraymodule.c # array objects
math mathmodule.c _math.c # -lm # math library functions, e.g. sin()
_struct _struct.c # binary structure packing/unpacking
time timemodule.c _time.c # -lm # time operations and variables
_random _randommodule.c # Random number generator
atexit atexitmodule.c # Register functions to be run at
_elementtree -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
_pickle _pickle.c # pickle accelerator
_datetime _datetimemodule.c # datetime accelerator
_bisect _bisectmodule.c # Bisection algorithms
_heapq _heapqmodule.c # Heap queue algorithm
unicodedata unicodedata.c # static Unicode character database
fcntl fcntlmodule.c # fcntl(2) and ioctl(2)
spwd spwdmodule.c # spwd(3)
grp grpmodule.c # grp(3)
select selectmodule.c # select(2); not on ancient System V
_socket socketmodule.c
_ssl _ssl.c -lssl -lcrypto
_posixsubprocess _posixsubprocess.c # POSIX subprocess module helper
_hashlib _hashopenssl.c -lssl -lcrypto
syslog syslogmodule.c # syslog daemon interface
binascii binascii.c
_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c
_ctypes/stgdict.c _ctypes/cfield.c _ctypes/malloc_closure.c -lffi
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz
pyexpat pyexpat.c -lexpat
----------------- 8< ---------------------

Bisecting this quickly leads to the _ctypes module configuration.

So a small reproducer based on the upstream Python 3.2 build is:

 * Configure and build pygobject with PYTHON=python3.2 (or specify the full
path for a local python build)

 * Build python 3.2 with the broken _ctypes module configuration:

$ cd /tmp/
$ tar xf python3.2_3.2.3.orig.tar.gz
$ cd python3.2-3.2.3
$ ./configure --with-wide-unicode # to be compatible with the Debian/Ubuntu
python 3.2
$ echo '_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c
_ctypes/stgdict.c _ctypes/cfield.c _ctypes/malloc_closure.c -lffi' >>
$ make -j4

Then in the pygobject built tree, run

$ (cd tests; TEST_NAMES=test_everything.TestCallbacks PYTHONPATH=..:.
LD_LIBRARY_PATH=./.libs GI_TYPELIB_PATH=. /tmp/python3.2-3.2.3/python

which reproduces the failure.

Conversely, if I change the ctypes line in debian/PVER-minimal.README.Debian.in from

  _ctypes extension


  _ctypes builtin

and build/install the packages, everything works.

For a more convenient reproducer on the Debian side, you can just run
"python3 python3-gi-segfault.py", i. e. the attached sample code here.

So there is something wrong with how this configures the _ctypes module to be
linked into python itself, instead of being a separate module
(/usr/lib/python3.2/lib-dynload/_ctypes.cpython-32mu.so) that you get with
"builtin" (that is indeed pretty confusing, given that I switched it _from_
"extension" _to_ "builtin". Or there is a Python 3.2/libffi bug which causes

Note that this is also tracked in https://launchpad.net/bugs/909292


Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-gnome-maintainers/attachments/20120503/c1085902/attachment.pgp>

More information about the pkg-gnome-maintainers mailing list