From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28587 invoked by alias); 6 Nov 2009 20:23:33 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27355 Received: (qmail 19332 invoked from network); 6 Nov 2009 20:23:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: none (ns1.primenet.com.au: domain at dan.emsphone.com does not designate permitted sender hosts) Date: Fri, 6 Nov 2009 13:59:14 -0600 From: Dan Nelson To: Stefano Lattarini Cc: zsh-workers@zsh.org Subject: Re: [MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian Message-ID: <20091106195914.GD89052@dan.emsphone.com> References: <200911061949.32084.stefano.lattarini@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200911061949.32084.stefano.lattarini@gmail.com> X-OS: FreeBSD 7.2-STABLE User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: ClamAV version 0.94.1, clamav-milter version 0.94.1 on email1.allantgroup.com X-Virus-Status: Clean X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (email1.allantgroup.com [199.67.51.78]); Fri, 06 Nov 2009 13:59:15 -0600 (CST) X-Scanned-By: MIMEDefang 2.45 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@allantgroup.com