Attempting to use libuuid from within python after PyQt4 has been loaded leads to a segfault This seems to be because PyQt4/Qt leave their copy of libuuid in an inconsistent state. The uuid module in python uses ctypes to load libuuid. PyQt4 loads libuuid already and so ctypes returns the loaded copy. This is demonstrated by the following: Load a private copy of libuuid python2.6 -c "from PyQt4.Qt import *; import ctypes; lib=ctypes.CDLL('/t/util-linux-ng-2.17.2/shlibs/uuid/src/.libs/libuuid.so.1'); f = lib.uuid_generate_random; buf = ctypes.create_string_buffer(16); f(buf); from uuid import UUID; print UUID(bytes=buf.raw)" 074a355e-58a6-4d96-bdca-719a4b298c0d This works as expected. Use the previously loaded copy of libuuid python2.6 -c "from PyQt4.Qt import *; import ctypes; lib=ctypes.CDLL('/lib/libuuid.so.1'); f = lib.uuid_generate_random; buf = ctypes.create_string_buffer(16); f(buf); from uuid import UUID; print UUID(bytes=buf.raw)" Segmentation fault And finally to show that the problem is not with libuuid itself python2.6 -c "import ctypes; lib=ctypes.CDLL('/lib/libuuid.so.1'); f = lib.uuid_generate_random; buf = ctypes.create_string_buffer(16); f(buf); from uuid import UUID; print UUID(bytes=buf.raw)" 8b5b3f51-76a5-46b4-93de-e646d4375e50 Note that this segfault happens only my x64 system not my x86 system Reproducible: Always Steps to Reproduce: 1. python2.6 -c "from PyQt4.Qt import *; import uuid; print uuid.uuid4()" Actual Results: Segmentation fault Expected Results: A UUID being printed out Portage 2.2_rc67 (default/linux/amd64/10.0/desktop/kde, gcc-4.4.3, glibc-2.11.1-r0, 2.6.33-gentoo-r1 x86_64) ================================================================= System uname: Linux-2.6.33-gentoo-r1-x86_64-Intel-R-_Core-TM-_i7_CPU_940_@_2.93GHz-with-gentoo-2.0.1 Timestamp of tree: Tue, 27 Apr 2010 06:00:01 +0000 app-shells/bash: 4.1_p5 dev-java/java-config: 2.1.10 dev-lang/python: 2.4.6, 2.5.4-r4, 2.6.5-r1, 3.1.2-r2 dev-python/pycrypto: 2.1.0 dev-util/cmake: 2.8.1-r1 sys-apps/baselayout: 2.0.1 sys-apps/openrc: 0.6.1-r1 sys-apps/sandbox: 2.2 sys-devel/autoconf: 2.13, 2.65 sys-devel/automake: 1.7.9-r1, 1.9.6-r3, 1.10.3, 1.11.1 sys-devel/binutils: 2.20.1 sys-devel/gcc: 4.1.2, 4.3.4, 4.4.3-r2 sys-devel/gcc-config: 1.4.1 sys-devel/libtool: 2.2.6b virtual/os-headers: 2.6.33 ABI="amd64" ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="*" ACCEPT_PROPERTIES="*" 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" ARCH="amd64" ASFLAGS_x86="--32" AUTOCLEAN="yes" CBUILD="x86_64-pc-linux-gnu" CDEFINE_amd64="__x86_64__" CDEFINE_x86="__i386__" CFLAGS="-O2 -pipe -ggdb" CFLAGS_x86="-m32" CHOST="x86_64-pc-linux-gnu" CHOST_amd64="x86_64-pc-linux-gnu" CHOST_x86="i686-pc-linux-gnu" CLEAN_DELAY="5" COLLISION_IGNORE="/lib/modules" CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /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" CVS_RSH="ssh" CXXFLAGS="-O2 -pipe -ggdb" DEFAULT_ABI="amd64" DISPLAY=":0" DISTDIR="/usr/portage/distfiles" EDITOR="/usr/bin/vim" ELIBC="glibc" EMERGE_DEFAULT_OPTS="--verbose --deep" EMERGE_WARNING_DELAY="10" EPREFIX="" EROOT="/" FEATURES="assume-digests distlocks fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unmerge-logs unmerge-orphans userfetch userpriv usersandbox" FETCHCOMMAND="/usr/bin/wget -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}"" GCC_SPECS="" GDK_USE_XFT="1" GENTOO_MIRRORS="http://distfiles.gentoo.org" HG="/usr/bin/hg" HOME="/home/kovid" INFOPATH="/usr/share/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.20.1/info:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/info" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LANG="en_US.UTF-8" LANGUAGE="" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LC_CTYPE="en_US.UTF-8" LDFLAGS="-Wl,-O1" LDFLAGS_x86="-m elf_i386" LESS="-R -M --shift 5" LESSOPEN="|lesspipe.sh %s" LIBDIR_amd64="lib64" LIBDIR_amd64_fbsd="lib64" LIBDIR_ppc="lib32" LIBDIR_ppc64="lib64" LIBDIR_sparc32="lib32" LIBDIR_sparc64="lib64" LIBDIR_x86="lib32" LIBDIR_x86_fbsd="lib32" LINGUAS="en" LOGNAME="root" LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:" MAKEOPTS="-j9" MANPATH="/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.20.1/man:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.4.3/man:/etc/java-config/system-vm/man/:/usr/qt/3/doc/man:/opt/vmware/workstation/man" MULTILIB_ABIS="amd64 x86" MULTILIB_STRICT_DENY="64-bit.*shared object" MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib" MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage)" NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OPENGL_PROFILE="xorg-x11" PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/usr/kde/3.5/sbin:/usr/kde/3.5/bin:/usr/qt/3/bin:/opt/vmware/workstation/bin" PKGDIR="/usr/portage/packages" PORTAGE_ARCHLIST="ppc x86-openbsd ppc-openbsd ppc64 x86-winnt x86-fbsd ppc-aix alpha arm x86-freebsd s390 amd64 arm-linux x86-macos x64-openbsd ia64-hpux hppa x86-netbsd amd64-linux ia64-linux x86 sparc-solaris x64-freebsd sparc64-solaris x86-linux x64-macos sparc m68k-mint ia64 mips ppc-macos x86-interix hppa-hpux amd64-fbsd x64-solaris mips-irix m68k sh x86-solaris sparc-fbsd" PORTAGE_BINHOST_CHUNKSIZE="3000" PORTAGE_BIN_PATH="/usr/lib64/portage/bin" PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png" PORTAGE_CONFIGROOT="/" PORTAGE_DEBUG="0" PORTAGE_DEPCACHEDIR="/var/cache/edb/dep" PORTAGE_ELOG_CLASSES="warn error log" PORTAGE_ELOG_MAILFROM="portage@localhost" PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}" PORTAGE_ELOG_MAILURI="root" PORTAGE_ELOG_SYSTEM="save_summary echo" PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5" PORTAGE_FETCH_RESUME_MIN_SIZE="350K" PORTAGE_GID="250" PORTAGE_INST_GID="0" PORTAGE_INST_UID="0" PORTAGE_PYM_PATH="/usr/lib64/portage/pym" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_RSYNC_RETRIES="3" PORTAGE_SYNC_STALE="30" PORTAGE_TMPDIR="/var/tmp" PORTAGE_VERBOSE="1" PORTAGE_WORKDIR_MODE="0700" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND" PYTHONDONTWRITEBYTECODE="1" QMAKESPEC="linux-g++" QTDIR="/usr/qt/3" RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}"" ROOT="/" ROOTPATH="/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.3:/usr/qt/3/bin:/opt/vmware/workstation/bin" RPMDIR="/usr/portage/rpm" RUBY_TARGETS="ruby18" SANE_CONFIG_DIR="/etc/sane.d" SHELL="/bin/bash" STAGE1_USE="multilib nptl nptlonly unicode" SUDO_COMMAND="/usr/bin/emerge --info" SUDO_GID="1000" SUDO_UID="1000" SUDO_USER="kovid" SYMLINK_LIB="yes" SYNC="rsync://rsync.gentoo.org/gentoo-portage" TERM="xterm" USB_DEVFS_PATH="/dev/bus/usb" USE="X a52 aac acl acpi alsa amd64 avahi bash-completion berkdb bluetooth branding bzip2 cairo cdr cli consolekit cracklib crypt cups cxx dbus dirac djvu dri dts dvd dvdr emboss encode exif fam firefox flac fontconfig fortran gdbm gif gpm gtk hal iconv ipod ipv6 jpeg jpeg2k kde kdrive kvm lcms ldap libnotify live mad mikmod mmx mmxext mng modules mp3 mp4 mpeg mplayer mudflap multilib mysql ncurses nls nptl nptlonly ogg opengl openmp oxygen pam pango pcre pdf perl phonon png policykit ppds pppd pulseaudio pygments python qt3support qt4 readline reflection scanner schroedinger sdl secure-delete session spell spl sql sse sse2 ssl ssse3 startup-notification svg sysfs tcpd thumbnail tiff truetype unicode usb vim-syntax vorbis webkit wmf x264 xcb xml xorg xterm-color xulrunner xv 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="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="radeon radeonhd ati" USER="root" USERLAND="GNU" USERNAME="root" USE_EXPAND="ALSA_CARDS ALSA_PCM_PLUGINS APACHE2_MODULES APACHE2_MPMS CAMERAS CROSSCOMPILE_OPTS DVB_CARDS ELIBC FCDSL_CARDS FOO2ZJS_DEVICES FRITZCAPI_CARDS INPUT_DEVICES KERNEL LCD_DEVICES LINGUAS LIRC_DEVICES MISDN_CARDS NETBEANS_MODULES NGINX_MODULES_HTTP NGINX_MODULES_MAIL QEMU_SOFTMMU_TARGETS QEMU_USER_TARGETS RUBY_TARGETS SANE_BACKENDS USERLAND VIDEO_CARDS" USE_EXPAND_HIDDEN="CROSSCOMPILE_OPTS ELIBC KERNEL USERLAND" USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d" VIDEO_CARDS="radeon radeonhd ati" XDG_CONFIG_DIRS="/etc/xdg" XDG_DATA_DIRS="/usr/local/share:/usr/share"
util-linux - 2.17.2 PyQt4 - 4.7.3 qt - 4.6.2 And I have tried re-emerging Qt/PyQt4/util-linux
This is resolved by downgrading util-linux to 2.17-r1
The problem was discussed here: http://bugs.gentoo.org/show_bug.cgi?id=300307. Try: emerge util-linux linux-headers.
That does not work. I tried it twice in case build order made a difference. emerge -pv util-linux linux-headers [ebuild R ] sys-kernel/linux-headers-2.6.33 0 kB [ebuild R ] sys-apps/util-linux-2.17.2 USE="crypt nls perl unicode -loop-aes -old-linux (-selinux) -slang (-uclibc)" 0 kB
*** Bug 318473 has been marked as a duplicate of this bug. ***
Same here, with a slightly different scenario, see bug 318473
Turns out I had to downgrade all the way to util-linux-2.17-r1. I'm not sure why it started now, since I had a higher util-linux than that for calibre-0.6.50; however, the only other suspect, qt-gui-4.6.2-r1 turns out not to be the problem.
I found that I had to downgrade util-linux to 2.17-r1 to get calibre-0.6.54 (just copied the ebuild for 0.6.53). I wonder if this discussion is relevant: http://www.mobileread.mobi/forums/showthread.php?t=48761
Created attachment 248653 [details] Backtrace It looks like TLS in libuuid is not initialized correctly, as jrand_seed pointer is invalid, causing segmentation fault on access.
Added vapier to cc list as I saw his name in the util-linux-ng 2.17.2 release notes and if util-linux is the problem then we need to get some base-system guys in here. I just tried util-linux 2.19 and still have this problem. There is v. 2.19-r3 also but I do not see anything UUID relevant in the changelog. In the 2.17.2 changelog there is this mention of UUID: libblkid: - remove "0x" prefix from DRBD UUID [Karel Zak] Hopefully it won't be hard to bisect this regression. Thanks for taking a look if you can Mike. -Matt
python-2.7 and python-3.1 with util-linux-2.19 works fine for me
This also segfaults on my x86 (stable) system: python2.6 -c "from PyQt4.Qt import *; import uuid; print uuid.uuid4() util-linux 2.18-r1 PyQt4 4.8.1
No problems with PyQt4 4.8.4 and util-linux 2.19.1
[ebuild R ] dev-python/PyQt4-4.8.4 [ebuild R ] sys-apps/util-linux-2.19.1 $ python -c "from PyQt4.Qt import *; import uuid; print uuid.uuid1()" Segmentation fault It's still happening, even with davech's suggestions. So that's frustrating. My backtrace is different from the attachment, so it does appear to be a bit of a schroedingbug inside UUID. The suggestion that it's a bad thread management issue is gaining traction. (gdb) bt #0 0xb617722d in uuid_generate_time () from /lib/libuuid.so.1 #1 0xb32306ef in ffi_call_SYSV () from /usr/lib/libffi.so.5 #2 0xb323052e in ffi_call () from /usr/lib/libffi.so.5 #3 0xb3242b75 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.so #4 0xb323cc9e in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so #5 0xb7e74d4c in PyObject_Call () from /usr/lib/libpython2.7.so.1.0 #6 0xb7f12116 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0 #7 0xb7f14313 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0 #8 0xb7f124b8 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0 #9 0xb7f14313 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0 #10 0xb7f14463 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0 #11 0xb7f2e11b in ?? () from /usr/lib/libpython2.7.so.1.0 #12 0xb7f2e373 in PyRun_StringFlags () from /usr/lib/libpython2.7.so.1.0 #13 0xb7f2f6f3 in PyRun_SimpleStringFlags () from /usr/lib/libpython2.7.so.1.0 #14 0xb7f40e9c in Py_Main () from /usr/lib/libpython2.7.so.1.0 #15 0x08048833 in main ()
Just went through the qt upgrade from 4.6.3 to 4.7.2 and glibc from 2.11.3 to 2.12.2 and the test case works now, using the same util-linux-2.19.1, PyQt4-4.8.3 and Python-2.7 that failed for me before.
According to this thread: http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d26dfc60edc8 this is a bug in glibc that's been fixed but not released: http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=d26dfc60edc8 Perhaps glibc 2.12.2 ebuild should include this patch?
it's already been released in the glibc-2.13 ebuilds
Okay, so this should be fixed now.