Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian



In the last episode (Nov 06), Stefano Lattarini said:
> 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 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 ***              

Here's valgrind output on a FreeBSD box:

==73378== Memcheck, a memory error detector.
==73378== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==73378== Using Valgrind-3.5.0.SVN and LibVEX; rerun with -h for copyright info
==73378== Command: /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh main2.zsh
==73378== 
==73378== Invalid read of size 1
==73378==    at 0x80540E5: bin_dot (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x805946F: execbuiltin (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8069475: execcmd (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806A284: execpline2 (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806A66E: execpline (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B609: execlist (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B739: execode (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807D3BC: loop (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807E168: zsh_main (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8052C01: main (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==  Address 0x31bd51 is 1 bytes inside a block of size 11 free'd
==73378==    at 0x48B95: free (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so)
==73378==    by 0x8093376: strvarsetfn (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80958B9: setstrvalue (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8099CEE: assignsparam (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806509A: addvars (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80652C6: execsimple (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B13F: execlist (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B739: execode (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807D3BC: loop (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807DAE4: source (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80540E1: bin_dot (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x805946F: execbuiltin (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378== 
==73378== Invalid free() / delete / delete[]
==73378==    at 0x48B95: free (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so)
==73378==    by 0x8054065: bin_dot (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x805946F: execbuiltin (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8069475: execcmd (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806A284: execpline2 (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806A66E: execpline (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B609: execlist (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B739: execode (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807D3BC: loop (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807E168: zsh_main (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8052C01: main (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==  Address 0x31bd50 is 0 bytes inside a block of size 11 free'd
==73378==    at 0x48B95: free (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so)
==73378==    by 0x8093376: strvarsetfn (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80958B9: setstrvalue (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x8099CEE: assignsparam (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806509A: addvars (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80652C6: execsimple (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B13F: execlist (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x806B739: execode (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807D3BC: loop (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x807DAE4: source (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x80540E1: bin_dot (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
==73378==    by 0x805946F: execbuiltin (in /usr/ports/shells/zsh/work/zsh-4.3.10/Src/zsh)
0=main2.zsh
v=x

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author