zsh-workers
 help / color / mirror / code / Atom feed
From: Dan Nelson <dnelson@allantgroup.com>
To: Stefano Lattarini <stefano.lattarini@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: [MAYBE BUG] resetting `$0' in sourced script causes zsh to crash on Debian
Date: Fri, 6 Nov 2009 13:59:14 -0600	[thread overview]
Message-ID: <20091106195914.GD89052@dan.emsphone.com> (raw)
In-Reply-To: <200911061949.32084.stefano.lattarini@gmail.com>

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


  reply	other threads:[~2009-11-06 20:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-06 18:49 Stefano Lattarini
2009-11-06 19:59 ` Dan Nelson [this message]
2009-11-06 20:38   ` Mikael Magnusson
2009-11-08 12:05     ` Stefano Lattarini
2009-11-06 21:30 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091106195914.GD89052@dan.emsphone.com \
    --to=dnelson@allantgroup.com \
    --cc=stefano.lattarini@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).