Crashes when C calls Python callback with Python3 due to local ctypes module build configuration
Bug #909292 reported by
Iven Hsu
This bug affects 5 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pygobject |
Unknown
|
Critical
|
|||
python3.2 (Debian) |
Fix Released
|
Unknown
|
|||
python3.2 (Ubuntu) |
Fix Released
|
High
|
Unassigned | ||
Precise |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
The sample code is attached, both happens in new installed Ubuntu 11.10 and Ubuntu 12.04.
Changed in pygobject (Ubuntu): | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in pygobject: | |
importance: | Unknown → Medium |
status: | Unknown → Confirmed |
Changed in pygobject: | |
importance: | Medium → Critical |
summary: |
- Segment fault when using set_cell_data_func in python3 + Crashes when C calls Python callback with Python3 |
Changed in pygobject (Ubuntu): | |
assignee: | nobody → Martin Pitt (pitti) |
status: | Triaged → In Progress |
Changed in pygobject (Debian): | |
status: | Unknown → Confirmed |
affects: | pygobject (Ubuntu) → python3.2 (Ubuntu) |
Changed in python3.2 (Ubuntu): | |
assignee: | Martin Pitt (pitti) → nobody |
status: | In Progress → Triaged |
affects: | pygobject (Debian) → python3.2 (Debian) |
Changed in python3.2 (Ubuntu Precise): | |
status: | New → In Progress |
Changed in pygobject: | |
status: | Confirmed → Unknown |
Changed in python3.2 (Debian): | |
status: | Confirmed → Fix Released |
To post a comment you must log in.
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}' PVER-minimal. README. Debian. in)XX)" \
Modules/ Setup.dist \ -Bdynamic/ /;s/-Wl, -Bstatic/ /' \ Setup.local
debian/
| sed -e 's/^#//' -e 's/-Wl,
>> $(1)/Modules/
When I disable this part, the local build works.
That code results in this Modules/ Setup.local:
----------------- 8< ------- ------- ------- shutdown malloc_ closure. c -lffi prefix) /lib -lz ------- -------
# 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
interpreter-
_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/
zlib zlibmodule.c -I$(prefix)/include -L$(exec_
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/ 2_3.2.3. orig.tar. gz malloc_ closure. c -lffi' >>
$ tar xf python3.
$ 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/
Modules/Setup.local
$ make -j4
Then in the pygobject built tree, run
$ (cd tests; TEST_NAMES= test_everything .TestCallbacks PYTHONPATH=..:. PATH=./ .libs GI_TYPELIB_PATH=. /tmp/python3. 2-3.2.3/ python
LD_LIBRARY_
./runtests.py)
which reproduces the failure.
Conversely, if I change the ctypes line in debian/ PVER-minimal. README. Debian. in from
_ctypes extension
to
_ctypes ...