Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 303541 - dev-python/pygtk-2.14.1-r1 segfault in gtk.TreeModel.foreach() when compiled with gcc-3.4.6-r2
Summary: dev-python/pygtk-2.14.1-r1 segfault in gtk.TreeModel.foreach() when compiled ...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-05 07:21 UTC by Longpoke
Modified: 2010-11-15 22:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
workaround patch.. (pygtk-2.14.1-TreeModel.foreach.patch,719 bytes, patch)
2010-02-05 07:26 UTC, Longpoke
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Longpoke 2010-02-05 07:21:30 UTC
The following code will crash on both of my amd64 systems (one hardened, one not) when pygtk is compiled with gcc-3.4.6-r2, due to calling an invalid address:

#/usr/bin/python
import gtk
import gobject
ls = gtk.ListStore(gobject.TYPE_STRING)
ls.set(ls.append(), 0, "BOOM")
ls.foreach(lambda a, b, c : False)

Note that it will only crash when the list has at least one item in it, otherwise the wrapped gtk_tree_model_foreach() wont call through the invalid function pointer.

The "problem" is in pygtk in gtk/gtktreeview.override:

static PyObject *
_wrap_gtk_tree_model_foreach(PyGObject *self, PyObject *args)
{
    gboolean pygtk_tree_foreach_marshal(GtkTreeModel *model,
                                           GtkTreePath *path,
                                           GtkTreeIter *iter,
                                           gpointer data);
...
    gtk_tree_model_foreach(GTK_TREE_MODEL(self->obj),
                           pygtk_tree_foreach_marshal, &cunote);
...

Python code calls this C code, which calls gtk_tree_model_foreach in the C library gtk+, which will call pygtk_tree_foreach_marshal for each item in the list (this is why it only crashes when the list is non-empty).

However, for some reason, the address of pygtk_tree_foreach_marshal is not passed, and some strange number is passed instead (was 0x64894cd8246c8948 every time for me, on my hardened system. Also note that it should be changing because of image base randomization, and this address is too high for the x64 address space anyways).

Removing the forward declaration from this function's body magically fixes it... I have no clue why, I suspect gcc is bugged... but maybe codegen from pygobject contributes to the problem, haven't checked that yet.

Relevant packages I have on both systems:
x11-libs/gtk+-2.16.6
dev-python/pygtk-2.14.1-r1
dev-lang/python-2.6.4
dev-python/pygobject-2.18.0
sys-devel/gcc-3.4.6-r2
sys-devel/gcc-4.3.4

Workaround:
a) Remove local forward declaration (see patch attached)
b) Compile with gcc 4.3.4 (no SSP! not viable for me)
Comment 1 Longpoke 2010-02-05 07:22:22 UTC
On my hardened machine:

$ emerge --info
Portage 2.1.7.16 (hardened/linux/amd64/10.0, gcc-3.4.6, glibc-2.10.1-r1, 2.6.28-hardened-r9 x86_64)
=================================================================
System uname: Linux-2.6.28-hardened-r9-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T5750_@_2.00GHz-with-gentoo-1.12.13
Timestamp of tree: Fri, 05 Feb 2010 00:00:01 +0000
ccache version 2.4 [enabled]
app-shells/bash:     4.0_p35
dev-java/java-config: 2.1.9-r2
dev-lang/python:     2.6.4
dev-python/pycrypto: 2.1.0_beta1
dev-util/ccache:     2.4-r7
dev-util/cmake:      2.6.4-r3
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc:       3.4.6-r2, 4.3.4
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=nocona"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe -march=nocona"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests ccache distlocks fixpackages news parallel-fetch protect-owned sandbox severe sfperms strict suidctl unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg"
GENTOO_MIRRORS="ftp://gentoo.arcticnetwork.ca/pub/gentoo http://gentoo.arcticnetwork.ca/ http://gentoo.mirrors.tera-byte.com/ http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/"
LANG="en_US.utf8"
LDFLAGS="-nopie"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage/tree"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X X509 a52 aac acl acpi alsa amd64 bash-completion berkdb bzip2 cairo caps cjk cli cracklib crypt cups cxx dbus djvu dri dts flac gdbm gpm gtk hal hardened iconv jpeg json justify live mad midi mmx modules mp3 mudflap multilib ncurses nls nptl nptlonly ogg opengl openmp pam pcre perl pic png pppd python quicktime readline reflection session smp spl sse sse2 sse3 ssl ssse3 svg sysfs tcpd theora truetype unicode urandom vorbis wma x264 xorg xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev mouse keyboard synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" NETBEANS_MODULES="ide java mobility profile php cnd nb" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="radeonhd radeon" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Longpoke 2010-02-05 07:23:25 UTC
On my non-hardened machine:
# emerge --info
Portage 2.1.7.16 (default/linux/amd64/10.0, gcc-3.4.6, glibc-2.10.1-r1, 2.6.31-gentoo-r6 x86_64)
=================================================================
System uname: Linux-2.6.31-gentoo-r6-x86_64-Intel-R-_Core-TM-2_CPU_4400_@_2.00GHz-with-gentoo-1.12.13
Timestamp of tree: Fri, 05 Feb 2010 00:00:01 +0000
ccache version 2.4 [enabled]
app-shells/bash:     4.0_p35
dev-lang/python:     2.6.4
dev-util/ccache:     2.4-r7
dev-util/cmake:      2.6.4-r3
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.9.6-r2, 1.10.2
sys-devel/binutils:  2.18-r3
sys-devel/gcc:       3.4.6-r2, 4.3.4
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.27-r2
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=nocona"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe -march=nocona"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests ccache distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://ftp.lecl.net/pub/gentoo/ http://gentoo.in.th/ http://ftp.daum.net/gentoo/"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://10.0.0.1/gentoo-portage"
USE="X a52 aac acl alsa amd64 berkdb bzip2 cairo cli cracklib crypt cups cxx djvu dri dts flac fortran gdbm gpm gtk iconv ipv6 jpeg live mad mmx modules mp3 mudflap multilib ncurses nls nptl nptlonly opengl openmp pam pcre perl png pppd python quicktime readline reflection session spl sse sse2 sse3 ssl ssse3 svg sysfs tcpd unicode vorbis wma x264 xorg xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 3 Longpoke 2010-02-05 07:26:00 UTC
Created attachment 218495 [details, diff]
workaround patch..
Comment 4 Gilles Dartiguelongue (RETIRED) gentoo-dev 2010-02-10 09:04:04 UTC
Is it happening in pygtk-2.16 too ?
Comment 5 Longpoke 2010-02-10 18:19:04 UTC
(In reply to comment #4)
> Is it happening in pygtk-2.16 too ?
> 

Yep, just tried with pygtk-2.16.0-r1.
Got a segmentation fault when compiled with gcc 3 but runs fine when compiled with gcc 4.
Comment 6 Pacho Ramos gentoo-dev 2010-09-03 18:17:17 UTC
Can you try with pygtk-2.17? It includes a lot of fixes, but I am unsure about upstream supporting gcc-3 :-/
Comment 7 Magnus Granberg gentoo-dev 2010-10-28 15:47:50 UTC
On hardened we don't longer support gcc-3.X so update to gcc-4.4.4-r2
Comment 8 Pacho Ramos gentoo-dev 2010-10-28 16:46:53 UTC
I am also tempted to close this as wontfix, but will wait a bit for other team members opinions :-/
Comment 9 Gilles Dartiguelongue (RETIRED) gentoo-dev 2010-11-15 22:17:01 UTC
Fill free to reopen with a modern gcc slot (per your arch/profile recommendations). Thanks for reporting.