Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problems with source command in precmd()
- X-seq: zsh-workers 27556
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Problems with source command in precmd()
- Date: Mon, 4 Jan 2010 12:15:12 +0000
- In-reply-to: <091219155732.ZM9104@xxxxxxxxxxxxxxxxxxxxxx>
- 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
- Organization: CSR
- References: <20091219224933.GA2785040@xxxxxxxxxxxxxxxxxxxxxxxx> <091219155732.ZM9104@xxxxxxxxxxxxxxxxxxxxxx>
On Sat, 19 Dec 2009 15:57:32 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 19, 10:49pm, Daniel Friesel wrote:
> }
> } there appear to be some crashes when using the source command in the
> } precmd function.
>
> I can reproduce this. It's sufficient to run zsh -f and enter
>
> precmd() { source /dev/null }
>
> at the prompt, then accept-line a second time.
This took some hunting down. valgrind was silent until the point where the
crash happened.
There is a recently added execsave() / execrestore() in the file execution
loop. This is a good thing to do, but it wasn't sanitising enough of the
state that it was saving to ensure it could be restored cleanly. In
particular there appears to be a ghastly hack whereby setting "stophist ==
3" is being used in precmd functions to influence a future iteration
(instead of doing its proper job of controlling the history mechanism for
each iteration), and this was causing nameless horrors to happen to the
data referred to by the saved exec information.
This is hard to test for without a handler for interactive tests. I
couldn't provoke the problem with zsh -ci.
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.52
diff -u -r1.52 lex.c
--- Src/lex.c 3 Mar 2009 17:26:07 -0000 1.52
+++ Src/lex.c 4 Jan 2010 12:00:45 -0000
@@ -248,8 +248,11 @@
ls->histactive = histactive;
ls->histdone = histdone;
ls->stophist = stophist;
+ stophist = 0;
ls->hline = chline;
+ chline = NULL;
ls->hptr = hptr;
+ hptr = NULL;
ls->hlinesz = hlinesz;
ls->cstack = cmdstack;
ls->csp = cmdsp;
@@ -259,7 +262,9 @@
ls->tokstr = tokstr;
ls->zshlextext = zshlextext;
ls->bptr = bptr;
+ tokstr = zshlextext = bptr = NULL;
ls->bsiz = bsiz;
+ bsiz = 256;
ls->len = len;
ls->chwords = chwords;
ls->chwordlen = chwordlen;
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
Messages sorted by:
Reverse Date,
Date,
Thread,
Author