From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26254 invoked by alias); 6 Nov 2009 20:38:50 -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: 27356 Received: (qmail 21732 invoked from network); 6 Nov 2009 20:38:47 -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.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.219.209 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=61uZwBwFI/r1/HAN6u9hx2+MvAvHEbBOkbcIzKxfhHo=; b=WRdEsz0D2ANZpaAwpOwjYO3cwI/JEEjuO3XBN92aK+npwlTZg6+rt3q0UdQ8vDLMFl fjlrgOl9qRVkQKDcrcqqirT+b6hDNkR6y1GQDPjplD2Cqr9Fjiz43Y7R/hNKLYkJCd2k XlmUskrnszz4I5hTQPr3bmwWpB6XHiaLiOelQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=c12z/NDqyhi6NlmzdMgR+8/tZwvkunEx+Fhc24O+juB6ZI5c4dpyIjZ8L9YXprdofQ bhCAZ/x6yjz49wUDyzL9hNetSByv1S1uy0GtHUy1F7BE1uaFsuojx7xjXJVz1Xz8BtVq qhPd+/qqfVLGZcceolveX4ltn/gZh6hDW2SEg= MIME-Version: 1.0 In-Reply-To: <20091106195914.GD89052@dan.emsphone.com> References: <200911061949.32084.stefano.lattarini@gmail.com> <20091106195914.GD89052@dan.emsphone.com> Date: Fri, 6 Nov 2009 21:38:42 +0100 Message-ID: <237967ef0911061238y3916ec41l3df655b1ef8c3450@mail.gmail.com> Subject: Re: [MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian From: Mikael Magnusson To: Dan Nelson Cc: Stefano Lattarini , zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2009/11/6 Dan Nelson : > 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 no= t >> be done; hopefully you can tell. >> >> Here are some minimal examples exposing the problem: >> >> =C2=A0 $ cat main2.zsh >> =C2=A0 . ./inc2.zsh >> =C2=A0 echo 0=3D"$0"' >> =C2=A0 echo v=3D"$v" >> >> =C2=A0 $ cat inc2.zsh >> =C2=A0 0=3Dx >> =C2=A0 v=3D$0 >> >> =C2=A0 $ zsh main2.zsh; echo e=3D$? =C2=A0# this causes zsh to crash >> =C2=A0 *** glibc detected *** zsh: double free or corruption (!prev): 0x= 08d91a18 *** > > Here's valgrind output on a FreeBSD box: > > 0=3Dmain2.zsh > v=3Dx Are you sure? I get 2:4: unmatched ' If you modify the script you should say so. That said, I get the crash both with and without the extraneous quote, and your output with the quote removed. If you get that output with it left, something is really really strange though. With MALLOC_CHECK_ set to show errors, I get the slightly more useful *** glibc detected *** zsh: free(): invalid pointer: 0x08102c90 *** (than the "double free or corruption") With MALLOC_CHECK_ set to ignore errors, I get the output as under valgrind= . My valgrind output has line numbers so I'll include it too. =3D=3D1260=3D=3D Invalid read of size 1 =3D=3D1260=3D=3D at 0x8063D84: bin_dot (builtin.c:4771) =3D=3D1260=3D=3D by 0x8055D9F: execbuiltin (builtin.c:439) =3D=3D1260=3D=3D by 0x8070836: execcmd (exec.c:3104) =3D=3D1260=3D=3D by 0x806C4CB: execpline2 (exec.c:1579) =3D=3D1260=3D=3D by 0x806B8DD: execpline (exec.c:1364) =3D=3D1260=3D=3D by 0x806B14B: execlist (exec.c:1161) =3D=3D1260=3D=3D by 0x806ABE2: execode (exec.c:988) =3D=3D1260=3D=3D by 0x8084761: loop (init.c:185) =3D=3D1260=3D=3D by 0x8087322: zsh_main (init.c:1454) =3D=3D1260=3D=3D by 0x80553D5: main (main.c:93) =3D=3D1260=3D=3D Address 0x40a5fb9 is 1 bytes inside a block of size 11 fr= ee'd =3D=3D1260=3D=3D at 0x40071EA: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) =3D=3D1260=3D=3D by 0x8098BBB: zsfree (mem.c:1508) =3D=3D1260=3D=3D by 0x80A809C: strvarsetfn (params.c:3215) =3D=3D1260=3D=3D by 0x80A535B: setstrvalue (params.c:2227) =3D=3D1260=3D=3D by 0x80A686D: assignsparam (params.c:2647) =3D=3D1260=3D=3D by 0x806D85A: addvars (exec.c:2136) =3D=3D1260=3D=3D by 0x806ACBD: execsimple (exec.c:1015) =3D=3D1260=3D=3D by 0x806B00E: execlist (exec.c:1129) =3D=3D1260=3D=3D by 0x806ABE2: execode (exec.c:988) =3D=3D1260=3D=3D by 0x8084761: loop (init.c:185) =3D=3D1260=3D=3D by 0x8086630: source (init.c:1156) =3D=3D1260=3D=3D by 0x8063D6E: bin_dot (builtin.c:4768) =3D=3D1260=3D=3D =3D=3D1260=3D=3D Invalid free() / delete / delete[] =3D=3D1260=3D=3D at 0x40071EA: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) =3D=3D1260=3D=3D by 0x8098BBB: zsfree (mem.c:1508) =3D=3D1260=3D=3D by 0x8063EFE: bin_dot (builtin.c:4801) =3D=3D1260=3D=3D by 0x8055D9F: execbuiltin (builtin.c:439) =3D=3D1260=3D=3D by 0x8070836: execcmd (exec.c:3104) =3D=3D1260=3D=3D by 0x806C4CB: execpline2 (exec.c:1579) =3D=3D1260=3D=3D by 0x806B8DD: execpline (exec.c:1364) =3D=3D1260=3D=3D by 0x806B14B: execlist (exec.c:1161) =3D=3D1260=3D=3D by 0x806ABE2: execode (exec.c:988) =3D=3D1260=3D=3D by 0x8084761: loop (init.c:185) =3D=3D1260=3D=3D by 0x8087322: zsh_main (init.c:1454) =3D=3D1260=3D=3D by 0x80553D5: main (main.c:93) =3D=3D1260=3D=3D Address 0x40a5fb8 is 0 bytes inside a block of size 11 fr= ee'd =3D=3D1260=3D=3D at 0x40071EA: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so) =3D=3D1260=3D=3D by 0x8098BBB: zsfree (mem.c:1508) =3D=3D1260=3D=3D by 0x80A809C: strvarsetfn (params.c:3215) =3D=3D1260=3D=3D by 0x80A535B: setstrvalue (params.c:2227) =3D=3D1260=3D=3D by 0x80A686D: assignsparam (params.c:2647) =3D=3D1260=3D=3D by 0x806D85A: addvars (exec.c:2136) =3D=3D1260=3D=3D by 0x806ACBD: execsimple (exec.c:1015) =3D=3D1260=3D=3D by 0x806B00E: execlist (exec.c:1129) =3D=3D1260=3D=3D by 0x806ABE2: execode (exec.c:988) =3D=3D1260=3D=3D by 0x8084761: loop (init.c:185) =3D=3D1260=3D=3D by 0x8086630: source (init.c:1156) =3D=3D1260=3D=3D by 0x8063D6E: bin_dot (builtin.c:4768) =3D=3D1260=3D=3D 2:4: unmatched ' line 4771 for that invalid read is ret =3D source(arg0); and line 4768 is else if (arg0[1] =3D=3D '.' && arg0 + 2 =3D=3D s) (Doesn't it seem like valgrind confused these two? Or am I really stupid? 4771 is the one calling source, yet the backtrace says it is called by 4768. I don't think I changed that file since compiling last time, but maybe I have.) --=20 Mikael Magnusson