Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian
- X-seq: zsh-workers 27354
- From: Stefano Lattarini <stefano.lattarini@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian
- Date: Fri, 6 Nov 2009 19:49:31 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:mime-version:message-id:content-type; bh=KpnyR/4Mp1o2d7P0lkADmx5ssN02e+PmMEspjjyYh+M=; b=C8GiSq7vv4rhqeKheZvJanB4PCV70albPl3JS0BsYJGf1IIz03cv/4GnlSk6Xa+NAs avzJJSo/YfRmp4Amh/oyaf/PjowUltVxhDzWuNYANVNlqabYGgMUIBRf04MipvwhzzkX AFaFka2L2MuqxbPiyfEWPJ4nf08UxbkzLg2ZI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:mime-version:message-id :content-type; b=FI+Jwuya3v7DWiiLMiXlgaya6M4o0OsgVnjk17H7YZByy9Kl6bp9zpVrXhns1g2Xaj 6QSL6rZSB2KfBhdzKxu1lcjDnjBmzfcajxR+teDOPTHCeVfGFLpJaVVuEkNcMWA64vLa hQDTj9jqY0onaBRBo1ejbKm+5zfh7U7cMW0wA=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hi everybody.
I have recently found a problem in resetting `$0' inside a script "sourced"
with the `.' builtin.
Not sure if it's a bug or if it's just me doing something that should not
be done; hopefully you can tell.
Here are some minimal examples exposing the problem:
-*-*-*-
$ cat main1.zsh
0=x
v1=$0
v2=`echo "$0" | sed 's/x/y/g'`
echo 0="$0"
echo v1="$v1"
echo v2="$v2"
$ zsh main1.zsh; echo e=$? # this behaves OK
0=x
v1=x
v2=y
e=0
-*-*-*-
$ cat main2.zsh
. ./inc2.zsh
echo 0="$0"'
echo v="$v"
$ cat inc2.zsh
0=x
v=$0
$ zsh main2.zsh; echo e=$? # this causes zsh to crash
*** glibc detected *** zsh: double free or corruption (!prev): 0x08d91a18 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7dd98f4]
/lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7ddb896]
zsh[0x80804ba]
zsh(ingetc+0x1a2)[0x8080cc2]
... [CUT] (see the attachement)
b7f87000-b7f88000 rw-p 0001c000 03:47 3156250 /lib/ld-2.9.so
bff71000-bff87000 rw-p bffea000 00:00 0 [stack]
Abortito
e=134
-*-*-*-
$ cat main3.zsh
. ./inc3.zsh
echo 0="$0"'
echo v="$v"
$ cat inc3.zsh
0=x
v=`echo "$0"`
$ zsh main3.zsh; echo e=$? # I'd expect $v to be "x", but...
0=main3.zsh
v=
e=0
-*-*-*-
$ cat main4.zsh
. ./inc4.zsh
echo 0="$0"'
echo v="$v"
$ cat inc4.zsh
setopt no_function_argzero
0=x
v=`echo "$0"`
$ zsh main4.zsh; echo e=$? # this causes zsh to crash
*** glibc detected *** zsh: corrupted double-linked list: 0x0813aa20 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7dc836f]
/lib/i686/cmov/libc.so.6[0xb7dc9e6d]
/lib/i686/cmov/libc.so.6(__libc_malloc+0x95)[0xb7dcbcd5]
zsh(zalloc+0x24)[0x808de44]
zsh[0x809e347]
zsh(parse_event+0x2f)[0x80a3fff]
... [CUT] (see the attachement)
b7f75000-b7f76000 rw-p 0001c000 03:47 3156250 /lib/ld-2.9.so
bfb60000-bfb76000 rw-p bffea000 00:00 0 [stack]
-*-*-*-
System information:
$ uname -a
Linux bigio 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686 GNU/Linux
$ cat /etc/debian_version
squeeze/sid
$ zsh --version
zsh 4.3.10 (i686-pc-linux-gnu)
$ dpkg -l zsh
ii zsh 4.3.10-5 A shell with lots of features
$ dpkg -l libc6
ii libc6 2.9-25 GNU C Library: Shared libraries
Regards,
Stefano
*** glibc detected *** zsh: double free or corruption (!prev): 0x08d91a18 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7dd98f4]
/lib/i686/cmov/libc.so.6(cfree+0x96)[0xb7ddb896]
zsh[0x80804ba]
zsh(ingetc+0x1a2)[0x8080cc2]
zsh[0x8086bdb]
zsh[0x8087595]
zsh(zshlex+0x190)[0x8088340]
zsh[0x80a3229]
zsh[0x80a1d86]
zsh[0x80a2bde]
zsh[0x80a2df7]
zsh[0x80a2e74]
zsh[0x80a3eae]
zsh(parse_event+0x34)[0x80a4004]
zsh(loop+0x6c)[0x807f5bc]
zsh(zsh_main+0x1ce)[0x808036e]
zsh(main+0x22)[0x8054c92]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7d817a5]
zsh[0x8054bd1]
======= Memory map: ========
08048000-080ca000 r-xp 00000000 03:47 2940818 /bin/zsh4
080ca000-080ce000 rw-p 00081000 03:47 2940818 /bin/zsh4
080ce000-080e1000 rw-p 080ce000 00:00 0
08d83000-08da4000 rw-p 08d83000 00:00 0 [heap]
b7900000-b7921000 rw-p b7900000 00:00 0
b7921000-b7a00000 ---p b7921000 00:00 0
b7a9c000-b7ac6000 r-xp 00000000 03:47 3154466 /lib/libgcc_s.so.1
b7ac6000-b7ac7000 rw-p 00029000 03:47 3154466 /lib/libgcc_s.so.1
b7af1000-b7afb000 r-xp 00000000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7afb000-b7afc000 r--p 00009000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7afc000-b7afd000 rw-p 0000a000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7afd000-b7b06000 r-xp 00000000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7b06000-b7b07000 r--p 00008000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7b07000-b7b08000 rw-p 00009000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7b29000-b7b2e000 rw-p b7b29000 00:00 0
b7b2e000-b7b30000 r-xp 00000000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b30000-b7b31000 r--p 00001000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b31000-b7b32000 rw-p 00002000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b32000-b7b69000 r--p 001f5000 03:47 3367552 /usr/lib/locale/locale-archive
b7b69000-b7d69000 r--p 00000000 03:47 3367552 /usr/lib/locale/locale-archive
b7d69000-b7d6b000 rw-p b7d69000 00:00 0
b7d6b000-b7ec3000 r-xp 00000000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7ec3000-b7ec4000 ---p 00158000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7ec4000-b7ec6000 r--p 00158000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7ec6000-b7ec7000 rw-p 0015a000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7ec7000-b7eca000 rw-p b7ec7000 00:00 0
b7eca000-b7eee000 r-xp 00000000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7eee000-b7eef000 r--p 00023000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7eef000-b7ef0000 rw-p 00024000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7ef0000-b7f32000 r-xp 00000000 03:47 3156539 /lib/libncursesw.so.5.7
b7f32000-b7f35000 rw-p 00041000 03:47 3156539 /lib/libncursesw.so.5.7
b7f35000-b7f37000 r-xp 00000000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f37000-b7f38000 r--p 00001000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f38000-b7f39000 rw-p 00002000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f39000-b7f3c000 r-xp 00000000 03:47 3152851 /lib/libcap.so.2.16
b7f3c000-b7f3d000 rw-p 00002000 03:47 3152851 /lib/libcap.so.2.16
b7f3d000-b7f3e000 rw-p b7f3d000 00:00 0
b7f3e000-b7f45000 r--s 00000000 03:47 1896378 /usr/lib/gconv/gconv-modules.cache
b7f45000-b7f5a000 r-xp 00000000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f5a000-b7f5b000 r--p 00014000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f5b000-b7f5c000 rw-p 00015000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f5c000-b7f5e000 rw-p b7f5c000 00:00 0
b7f5e000-b7f65000 r-xp 00000000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f65000-b7f66000 r--p 00006000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f66000-b7f67000 rw-p 00007000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f67000-b7f68000 r--p 0035f000 03:47 3367552 /usr/lib/locale/locale-archive
b7f68000-b7f69000 rw-p b7f68000 00:00 0
b7f69000-b7f6a000 r-xp b7f69000 00:00 0 [vdso]
b7f6a000-b7f86000 r-xp 00000000 03:47 3156250 /lib/ld-2.9.so
b7f86000-b7f87000 r--p 0001b000 03:47 3156250 /lib/ld-2.9.so
b7f87000-b7f88000 rw-p 0001c000 03:47 3156250 /lib/ld-2.9.so
bff71000-bff87000 rw-p bffea000 00:00 0 [stack]
*** glibc detected *** zsh: corrupted double-linked list: 0x0813aa20 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.6[0xb7dc836f]
/lib/i686/cmov/libc.so.6[0xb7dc9e6d]
/lib/i686/cmov/libc.so.6(__libc_malloc+0x95)[0xb7dcbcd5]
zsh(zalloc+0x24)[0x808de44]
zsh[0x809e347]
zsh(parse_event+0x2f)[0x80a3fff]
zsh(loop+0x6c)[0x807f5bc]
zsh(zsh_main+0x1ce)[0x808036e]
zsh(main+0x22)[0x8054c92]
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7d6f7a5]
zsh[0x8054bd1]
======= Memory map: ========
08048000-080ca000 r-xp 00000000 03:47 2940818 /bin/zsh4
080ca000-080ce000 rw-p 00081000 03:47 2940818 /bin/zsh4
080ce000-080e1000 rw-p 080ce000 00:00 0
0812c000-0814d000 rw-p 0812c000 00:00 0 [heap]
b7900000-b7921000 rw-p b7900000 00:00 0
b7921000-b7a00000 ---p b7921000 00:00 0
b7a8a000-b7ab4000 r-xp 00000000 03:47 3154466 /lib/libgcc_s.so.1
b7ab4000-b7ab5000 rw-p 00029000 03:47 3154466 /lib/libgcc_s.so.1
b7adf000-b7ae9000 r-xp 00000000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7ae9000-b7aea000 r--p 00009000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7aea000-b7aeb000 rw-p 0000a000 03:47 3170741 /lib/i686/cmov/libnss_files-2.9.so
b7aeb000-b7af4000 r-xp 00000000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7af4000-b7af5000 r--p 00008000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7af5000-b7af6000 rw-p 00009000 03:47 3170754 /lib/i686/cmov/libnss_nis-2.9.so
b7b17000-b7b1c000 rw-p b7b17000 00:00 0
b7b1c000-b7b1e000 r-xp 00000000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b1e000-b7b1f000 r--p 00001000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b1f000-b7b20000 rw-p 00002000 03:47 1901992 /usr/lib/gconv/ISO8859-15.so
b7b20000-b7b57000 r--p 001f5000 03:47 3367552 /usr/lib/locale/locale-archive
b7b57000-b7d57000 r--p 00000000 03:47 3367552 /usr/lib/locale/locale-archive
b7d57000-b7d59000 rw-p b7d57000 00:00 0
b7d59000-b7eb1000 r-xp 00000000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7eb1000-b7eb2000 ---p 00158000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7eb2000-b7eb4000 r--p 00158000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7eb4000-b7eb5000 rw-p 0015a000 03:47 3170597 /lib/i686/cmov/libc-2.9.so
b7eb5000-b7eb8000 rw-p b7eb5000 00:00 0
b7eb8000-b7edc000 r-xp 00000000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7edc000-b7edd000 r--p 00023000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7edd000-b7ede000 rw-p 00024000 03:47 3170714 /lib/i686/cmov/libm-2.9.so
b7ede000-b7f20000 r-xp 00000000 03:47 3156539 /lib/libncursesw.so.5.7
b7f20000-b7f23000 rw-p 00041000 03:47 3156539 /lib/libncursesw.so.5.7
b7f23000-b7f25000 r-xp 00000000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f25000-b7f26000 r--p 00001000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f26000-b7f27000 rw-p 00002000 03:47 3170758 /lib/i686/cmov/libdl-2.9.so
b7f27000-b7f2a000 r-xp 00000000 03:47 3152851 /lib/libcap.so.2.16
b7f2a000-b7f2b000 rw-p 00002000 03:47 3152851 /lib/libcap.so.2.16
b7f2b000-b7f2c000 rw-p b7f2b000 00:00 0
b7f2c000-b7f33000 r--s 00000000 03:47 1896378 /usr/lib/gconv/gconv-modules.cache
b7f33000-b7f48000 r-xp 00000000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f48000-b7f49000 r--p 00014000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f49000-b7f4a000 rw-p 00015000 03:47 3170743 /lib/i686/cmov/libnsl-2.9.so
b7f4a000-b7f4c000 rw-p b7f4a000 00:00 0
b7f4c000-b7f53000 r-xp 00000000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f53000-b7f54000 r--p 00006000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f54000-b7f55000 rw-p 00007000 03:47 3170735 /lib/i686/cmov/libnss_compat-2.9.so
b7f55000-b7f56000 r--p 0035f000 03:47 3367552 /usr/lib/locale/locale-archive
b7f56000-b7f57000 rw-p b7f56000 00:00 0
b7f57000-b7f58000 r-xp b7f57000 00:00 0 [vdso]
b7f58000-b7f74000 r-xp 00000000 03:47 3156250 /lib/ld-2.9.so
b7f74000-b7f75000 r--p 0001b000 03:47 3156250 /lib/ld-2.9.so
b7f75000-b7f76000 rw-p 0001c000 03:47 3156250 /lib/ld-2.9.so
bfb60000-bfb76000 rw-p bffea000 00:00 0 [stack]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author