Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 537042 - dev-python/graph-tool - segmentation fault in PyInit_libgraph_tool_generation () at graph_generation.cc:99
Summary: dev-python/graph-tool - segmentation fault in PyInit_libgraph_tool_generation...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: PATCH
Depends on: 536734
Blocks:
  Show dependency tree
 
Reported: 2015-01-19 12:36 UTC by Justin Keogh
Modified: 2015-05-12 20:19 UTC (History)
0 users

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


Attachments
backtrace.log (backtrace.log,106.45 KB, text/plain)
2015-01-20 04:12 UTC, Justin Keogh
Details
backtrace.full.log (backtrace.full.log,386.18 KB, text/plain)
2015-01-20 04:13 UTC, Justin Keogh
Details
emerge.info (emerge.info,18.80 KB, text/plain)
2015-01-20 04:14 UTC, Justin Keogh
Details
graph_tool_segfault_gdb_log.txt (graph_tool_segfault_gdb_log.txt,15.12 KB, text/plain)
2015-01-27 22:08 UTC, Justin Keogh
Details
graph_tool_segfault_gdb_log_new.txt (graph_tool_segfault_gdb_log_new.txt,17.25 KB, text/plain)
2015-01-29 10:12 UTC, Justin Keogh
Details
remove_all_tr1hash.patch (remove_all_tr1hash.patch,10.60 KB, patch)
2015-02-11 02:59 UTC, Justin Keogh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Keogh 2015-01-19 12:36:58 UTC
dev-python/graph-tool-9999 and dev-python/graph-tool-2.2.36 both segfault on the standard import:

$/usr/bin/python3.3 -c 'import graph_tool.all as gt' ; tail -n 1 /var/log/messages 
Segmentation fault
Jan 19 04:42:12 localhost kernel: [196711.282646] python3.3[18903]: segfault at 16ae16 ip 000000000016ae16 sp 00007ffff2286a18 error 14 in libgmp.so.10.1.3[7f05c5edb000+78000]


$/usr/bin/python2.7 -c 'import graph_tool.all as gt' ; tail -n 1 /var/log/messages 
Segmentation fault
Jan 19 04:45:00 localhost kernel: [196878.961090] python2.7[18950]: segfault at 165526 ip 0000000000165526 sp 00007fffd26a6918 error 14 in libgmp.so.10.1.3[7fe6b5045000+78000]


Reproducible: Always

Steps to Reproduce:
1. install graph-tool (note bug 536734 and bug 537034 block this)
2. python -c 'import graph_tool.all as gt'

Actual Results:  
$python -c 'import graph_tool.all as gt'
Segmentation fault

Expected Results:  
successful import

I have both PAX and GRSEC disabled in the kernel for testing.


$emerge --info graph-tool boost gmp
Portage 2.2.14 (python 3.3.5-final-0, hardened/linux/amd64, gcc-4.8.3, glibc-2.17, 3.17.7-hardened-r1 x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.17.7-hardened-r1-x86_64-Intel-R-_Xeon-R-_CPU_X5482_@_3.20GHz-with-gentoo-2.2
KiB Mem:    32958716 total,    374576 free
KiB Swap:   33554428 total,  32378936 free
Timestamp of tree: Mon, 19 Jan 2015 11:15:01 +0000
ld GNU ld (Gentoo 2.24 p1.4) 2.24
distcc 3.1 x86_64-pc-linux-gnu [disabled]
ccache version 3.1.9 [enabled]
app-shells/bash:          4.2_p53
dev-java/java-config:     2.2.0
dev-lang/perl:            5.16.3
dev-lang/python:          2.7.5-r3, 3.3.5-r1
dev-util/ccache:          3.1.9-r3
dev-util/cmake:           2.8.12.2
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.24-r3
sys-devel/gcc:            4.6.3, 4.7.3-r1, 4.8.3, 4.9.1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.17
Repositories: gentoo poly-c local_overlay
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /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"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs ccache config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://gentoo.mirrors.hoobly.com/ http://mirror.usu.edu/mirrors/gentoo/ ftp://gentoo.mirrors.tds.net/gentoo ftp://mirror.datapipe.net/gentoo"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j9"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/poly-c /usr/local/portage"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="X alisp alsa amd64 amr apng aspell berkdb bindist bzip2 cairo celt clang cli cpudetection cracklib crypt cryptsetup cups cxx device-mapper dga dirac dri exif ffmpeg fftw fontconfig ftdi gcj gdbm geos gif glade glut gml gnuplot gps graphviz gstreamer gtk3 gudev hardened helpers hwdb iconv icu imagemagick introspection ipv6 ipython irqbalance jpeg jpeg2k justify keymap lapack latex lcms libkms lvm mad man mmx mmxext mng modules mp3 multilib ncat ncurses ndiff netcdf nls nping nptl ntfs numpy offensive ogg oog opengl openmp opus pam pax_kernel pcre pdf png postgres postscript pylint python qemu qt3support raw readline rtlsdr scipy sdl session smp smpeg spell spice sql sqlite sse sse2 ssl ssse3 svg tcpd threads tiff tinfo tools truetype unicode urandom usb v4l virt-network vorbis vpx wavelet webkit wmf x264 xa xattr xcb xetex xpm xtpax xvfb xvid zlib" ABI_X86="64" 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" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd 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 cgi cgid 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" DRACUT_MODULES="multipath crypt" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python3_3" PYTHON_TARGETS="python2_7 python3_3" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="nouveau intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7 3.3"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

dev-python/graph-tool-9999 was built with the following:
USE="cairo openmp" ABI_X86="64" PYTHON_TARGETS="python2_7 python3_3 -python3_4"


dev-libs/boost-1.56.0-r1 was built with the following:
USE="icu nls python threads tools -context -debug -doc -mpi -static-libs" ABI_X86="64 -32 -x32" PYTHON_TARGETS="python2_7 python3_3 -python3_4"
CXXFLAGS="-march=native -O2 -pipe -std=gnu++98"


dev-libs/gmp-5.1.3-r1 was built with the following:
USE="cxx -doc -pgo -static-libs" ABI_X86="64 -32 -x32"
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2015-01-19 19:58:40 UTC
Would you care to get a gdb backtrace of that segmentation fault?
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2015-01-19 22:28:36 UTC
Quoting memory addresses isn't very useful here.
Comment 3 Justin Keogh 2015-01-20 04:12:19 UTC
OK thanks. Learning. I enabled -ggdb and splitdebug, then recompiled python, gmp, boost, glibc, and graph-tool.

backtraces and updated emerge --info attached

line 99 of:
https://github.com/count0/graph-tool/blob/master/src/graph/generation/graph_generation.cc

seems to be the problem?
Comment 4 Justin Keogh 2015-01-20 04:12:57 UTC
Created attachment 394374 [details]
backtrace.log
Comment 5 Justin Keogh 2015-01-20 04:13:37 UTC
Created attachment 394376 [details]
backtrace.full.log
Comment 6 Justin Keogh 2015-01-20 04:14:30 UTC
Created attachment 394378 [details]
emerge.info
Comment 7 Tim Harder gentoo-dev 2015-01-21 16:48:46 UTC
Was this just caused by bug #536734?
Comment 8 Justin Keogh 2015-01-21 18:23:34 UTC
No, it was just dependent on it because you would get 'unknown symbol' instead of a segfault without first applying the fix for bug 536734. With the patch for 536734 applied, you can at least do some stuff, like:

$/usr/bin/python3.3 -c 'import graph_tool ; print(graph_tool.__version__)'
2.2.37dev (commit 201879ac, Fri Jan 9 15:46:17 2015 +0100)

which previously would give 'unknown symbol'
Comment 9 Justin Keogh 2015-01-22 23:02:18 UTC
I posted a request for help upstream:
http://thread.gmane.org/gmane.comp.science.graph.graph-tool.general/1807
Comment 10 Justin Keogh 2015-01-27 22:08:03 UTC
Upstream suggested this might be a py2.7 vs 3.3 issue.

I disabled python2.7:

PYTHON_TARGETS="python3_3"
PYTHON_SINGLE_TARGET="python3_3"
USE_PYTHON='3.3'

and recompiled boost, graph-tool, libgmp - and more.

Same problem.

LD_DEBUG="all" shows an unresolved symbol:

<snip>

 18820:     /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so: error: symbol lookup error: undefined symbol: _ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3_ (fatal)
     18820:     opening file=/usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so [0]; direct_opencount=1
     18820:
     18820:
     18820:     add /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so [0] to global scope
     18820:
     18820:     add /usr/lib64/libgmp.so.10 [0] to global scope
     18820:     symbol=PyInit_libgraph_tool_generation;  lookup in file=/usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so [0]
     18820:     binding file /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so [0] to /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so [0]: normal symbol `PyInit_libgraph_tool_generation'
Segmentation fault


$nm -D /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so | grep _ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3_
                 U _ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3_
$grep -r ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3 /var/tmp/portage/dev-python/graph-tool-9999/
Binary file /var/tmp/portage/dev-python/graph-tool-9999/work/graph-tool-9999-python3_3/src/graph/generation/.libs/graph_rewiring.o matches
Binary file /var/tmp/portage/dev-python/graph-tool-9999/work/graph-tool-9999-python3_3/src/graph/generation/.libs/libgraph_tool_generation.so matches

$nm -D /usr/lib64/python3.3/site-packages/graph_tool/generation/libgraph_tool_generation.so | grep _ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3_
                 U _ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3_

$grep -r ZNKSt3tr14hashISt6vectorISsSaISsEEEclES3 /var/tmp/portage/dev-python/graph-tool-9999/
Binary file /var/tmp/portage/dev-python/graph-tool-9999/work/graph-tool-9999-python3_3/src/graph/generation/.libs/graph_rewiring.o matches
Binary file /var/tmp/portage/dev-python/graph-tool-9999/work/graph-tool-9999-python3_3/src/graph/generation/.libs/libgraph_tool_generation.so matches


With help from #gdb, I was able to instruction step to the segfault source, log graph_tool_segfault_gdb_log.txt attached, unfortunately I don't yet know how to break before 0x7fffd80982b0 changes, right now it's got the bad value already when I break on graph_generation.cc:99
Comment 11 Justin Keogh 2015-01-27 22:08:28 UTC
Created attachment 395036 [details]
graph_tool_segfault_gdb_log.txt
Comment 12 Justin Keogh 2015-01-28 19:03:51 UTC
Per suggestion from upstream, I passed ./configure --disable-sparsehash, this resolved the segfault. Still working on understanding how to fix with sparsehash enabled.

$/usr/bin/python3.3 -c 'import graph_tool.all as gt ; print(gt.__version__)'
2.2.37dev (commit 201879ac, Fri Jan 9 15:46:17 2015 +0100)
Comment 13 Justin Keogh 2015-01-29 10:12:26 UTC
Created attachment 395102 [details]
graph_tool_segfault_gdb_log_new.txt

New log to assist upstream. This is with removetr1hash.patch applied and sparsehash enabled.
Comment 14 Justin Keogh 2015-02-11 02:57:59 UTC
This is fixed in git, for 2.2.36 and 2.2.36-r1 the attached pach is needed.

http://article.gmane.org/gmane.comp.science.graph.graph-tool.general/1826
Comment 15 Justin Keogh 2015-02-11 02:59:10 UTC
Created attachment 396156 [details, diff]
remove_all_tr1hash.patch

Patch for graph-tool-2.2.36-r1 and graph-tool-2.2.36
Comment 16 Tim Harder gentoo-dev 2015-03-23 16:45:47 UTC
I'm assuming this is fixed in 2.2.37 when it gets bumped.
Comment 17 Justin Keogh 2015-03-24 00:08:57 UTC
Yes, it's fixed in 9999 now.
Comment 18 Tim Harder gentoo-dev 2015-05-12 20:19:48 UTC
Closing since this should be fixed in more recent releases.