Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 281971 - app-admin/eselect-python-20090814: Fix argv[0]
Summary: app-admin/eselect-python-20090814: Fix argv[0]
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 280959 281241 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-08-18 20:51 UTC by Victor Mataré
Modified: 2009-08-22 17:55 UTC (History)
3 users (show)

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


Attachments
"fix" for python-wrapper (python-wrapper.patch,521 bytes, patch)
2009-08-19 22:19 UTC, Victor Mataré
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Victor Mataré 2009-08-18 20:51:00 UTC
/usr/bin/python-wrapper from app-admin/eselect-python-20090814:
emerging avahi failed with a segfault on the following test:
# prog="
import sys
try:
        import gtk
except ImportError:
        sys.exit(1)
except:
        sys.exit(0)
sys.exit(0)
"

# /usr/bin/python -c "$prog"
Segmentation fault

/usr/bin/python is a symlink to /usr/bin/python-wrapper. Relinking /usr/bin/python to /usr/bin/python2.6 fixes the segfault, and avahi compiles again.

BTW, the segfault does not happen when I call python without an absolute path like this:
# python -c "$prog"

# emerge --info
Portage 2.1.6.13 (default/linux/amd64/2008.0/desktop, gcc-4.4.1, glibc-2.10.1-r0, 2.6.30-gentoo-r4_wald x86_64)                                                                               
=================================================================                              
System uname: Linux-2.6.30-gentoo-r4_wald-x86_64-Intel-R-_Core-TM-2_Duo_CPU_T9500_@_2.60GHz-with-gentoo-2.0.1                                                                                 
Timestamp of tree: Mon, 17 Aug 2009 08:15:01 +0000                                             
distcc 3.1 x86_64-pc-linux-gnu [disabled]                                                      
app-shells/bash:     4.0_p28                                                                   
dev-java/java-config: 2.1.8-r1                                                                 
dev-lang/python:     2.6.2-r1                                                                  
dev-python/pycrypto: 2.0.1-r8                                                                  
dev-util/cmake:      2.6.4-r2                                                                  
sys-apps/baselayout: 2.0.1                                                                     
sys-apps/openrc:     0.4.3-r3                                                                  
sys-apps/sandbox:    2.0                                                                       
sys-devel/autoconf:  2.13, 2.63-r1                                                             
sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2, 1.11                   
sys-devel/binutils:  2.19.1-r1                                                                 
sys-devel/gcc-config: 1.4.1                                                                    
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.30-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=core2 -msse4.1 -mssse3 -msse3 -msse2 -msse -mmmx"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /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 /etc/udev/rules.d"
CXXFLAGS="-O2 -pipe -march=core2 -msse4.1 -mssse3 -msse3 -msse2 -msse -mmmx"
DISTDIR="/usr/portage/distfiles"
FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror"
LANG="en_US.UTF8"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j2"
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/layman/sunrise /usr/local/portage/wald"
SYNC="rsync://rsync.phuk.ath.cx/gentoo-portage"
USE="X a52 aac aalib acl acpi aiglx akonadi alsa amd64 ao audiofile avahi bash-completion berkdb bluetooth bonjour branding bzip2 cairo caps cdaudio cddb cdparanoia cdr cli consolekit cracklib crypt css cups curl dbus dga dri dts dv dvd dvdr dvdread encode evo exif extensions fam ffmpeg fftw firefox flac fortran fuse gcj gd gdbm geoip gif git gnokii gnome gnome-keyring gnutls gpm gstreamer gtk hal hdaps http ical iconv id3 id3tag ipv6 jack jack-tmpfs java java5 java6 jingle jpeg jpeg2k kde kde4 kdeenablefinal kerberos kipi kvm ladspa lame laptop lash ldap libnotify libsamplerate logrotate mad matroska midi mikmod mjpeg mmap mmx mng mp3 mp4 mpeg mplayer msn mudflap multilib musicbrainz mysql ncurses networkmanager nodrm nptl nptlonly nsplugin nvidia obex offensive ogg opengl openmp oscar otr pam pcre pdf perl phonon plotutils png policykit ppds pppd pulseaudio python qt3 qt3support qt4 quicktime raw rdesktop readline reflection replaygain resolvconf rtsp samba sasl sdl session sms sndfile sox speex spell spl sql sse sse2 sse3 ssl ssse3 startup-notification subversion svg sysfs tcpd tetex theora threads tiff truetype unicode usb vamp vcd vim vim-syntax vnc vorbis wifi wmf wxwindows x264 xcomposite xine xinerama xinetd xml xorg xosd xulrunner xv xvid xvmc zeroconf 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 evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" USERLAND="GNU" VIDEO_CARDS="nvidia nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

Reproducible: Always

Steps to Reproduce:
Comment 1 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-18 21:02:13 UTC
(In reply to comment #0)
> /usr/bin/python-wrapper from app-admin/eselect-python-20090814:
> emerging avahi failed with a segfault on the following test:
> # prog="
> import sys
> try:
>         import gtk
> except ImportError:
>         sys.exit(1)
> except:
>         sys.exit(0)
> sys.exit(0)
> "
> 
> # /usr/bin/python -c "$prog"
> Segmentation fault

I tried it and I can't reproduce any segmentation fault.
Please provide exact output from GDB.
http://www.gentoo.org/proj/en/qa/backtraces.xml
Comment 2 Victor Mataré 2009-08-18 23:59:01 UTC
hmm... any idea how I can make gdb pass that multi-line python program as an argument?
Comment 3 Victor Mataré 2009-08-19 00:33:50 UTC
(In reply to comment #2)
> hmm... any idea how I can make gdb pass that multi-line python program as an
> argument?
> 
ok got it, it passes the arguments to bash. sorry.
Comment 4 Victor Mataré 2009-08-19 00:58:03 UTC
Wow, it looks like it's actually python receiving SIGSEGV. Fancy. python-wrapper does an execvp("/usr/bin/python2.6", argv), which looks fine. However running /usr/bin/python2.6 -c "$prog" from the shell works. Will have to do some more testing tomorrow to narrow in on this...
Comment 5 Victor Mataré 2009-08-19 01:40:56 UTC
ok, that's what gdb says:
Starting program: /usr/bin/python-wrapper -c "$(cat /root/prog)"
main (argc=3, argv=0x7fffd42b9758) at python-wrapper.c:165
165     python-wrapper.c: No such file or directory.
        in python-wrapper.c
Continuing.
Executing new program: /usr/bin/python2.6
[Thread debugging using libthread_db enabled]
[New Thread 0x7f51607186f0 (LWP 12020)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f51607186f0 (LWP 12020)]
0x0000000000400805 in _start ()

I'm not very familiar with gdb and debugging in general, but maybe this could be bad usage of execv()?
Comment 6 Victor Mataré 2009-08-19 01:56:37 UTC
I find singlestepping more interesting than the one-frame backtrace:

(gdb) set args -c "$(cat /root/prog)"
(gdb) break main
Breakpoint 1 at 0x40110b: file python-wrapper.c, line 165.
(gdb) start
Breakpoint 2 at 0x40110b: file python-wrapper.c, line 165.
Starting program: /usr/bin/python-wrapper -c "$(cat /root/prog)"

Breakpoint 1, main (argc=3, argv=0x7fff097036c8) at python-wrapper.c:165
165             const char* EPYTHON = getenv("EPYTHON");
(gdb) n
166             if (! valid_interpreter(EPYTHON))
... bla...
(gdb)
197             if (*path)
(gdb)
199                     execv(dir_cat(path, EPYTHON), argv);
(gdb) print *argv
$2 = 0x7fff09705228 "/usr/bin/python-wrapper"

Quote from EXEC(3): The  first  argument,  by  convention, should point to the filename associated with the file being executed.

Now this is definitely broken, but it's not what's causing the segfault. I'll have to recompile glibc to see what valgrind says.
Comment 7 Victor Mataré 2009-08-19 21:00:17 UTC
(In reply to comment #6)

> Now this is definitely broken, but it's not what's causing the segfault. I'll
> have to recompile glibc to see what valgrind says.

I'll have to correct myself -- This is actually exactly what's causing the python interpreter to segfault. Dunno what it does, but it sure goes nuts. Once I fix argv[0] to point to the correct path upon execv(), all goes fine. Patch is coming up...

Comment 8 Victor Mataré 2009-08-19 22:19:39 UTC
Created attachment 201746 [details, diff]
"fix" for python-wrapper

This patch kind of "fixes" python-wrapper into passing argv[0] correctly upon exec(). I'm not sure what this program is supposed to achieve anyway, so... where do I find the discussion about the future of eselect?
Comment 9 Jonathan Callen (RETIRED) gentoo-dev 2009-08-20 20:12:01 UTC
(In reply to comment #8)
> Created an attachment (id=201746) [edit]
> "fix" for python-wrapper
> 
> This patch kind of "fixes" python-wrapper into passing argv[0] correctly upon
> exec(). I'm not sure what this program is supposed to achieve anyway, so...
> where do I find the discussion about the future of eselect?

This patch looks correct.  I forgot that argv[0] had to be changed for execvp(3)/execv(3) to work properly... :)
Comment 10 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-22 02:26:23 UTC
*** Bug 280959 has been marked as a duplicate of this bug. ***
Comment 11 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-22 02:35:04 UTC
Fixed in r209.
Comment 12 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-22 17:55:35 UTC
*** Bug 281241 has been marked as a duplicate of this bug. ***