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

Re: segfault due to chpwd_function



On Fri, 11 Dec 2009 11:01:58 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Dec 11,  6:41pm, Peter Stephenson wrote:
> }
> } Are you able to post a self-contained function that shows the problem,
> } with no external depenencies?
> 
> This seems to do it:
> 
> autoload -U promptinit
> promptinit
> prompt_chpwd() {
>   ((RANDOM % 2)) && prompt bart || prompt zefram 
> }
> precmd_functions=(prompt_chpwd)

Yes, that's pretty effective.

> Note that I don't get the crash if I change from precmd_functions to
> chpwd_functions, so my suspicion about "add-zsh-hook -D" seems to be
> correct.

Right, this seems to make it go away...

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.234
diff -u -r1.234 utils.c
--- Src/utils.c	3 Nov 2009 10:00:34 -0000	1.234
+++ Src/utils.c	11 Dec 2009 22:14:53 -0000
@@ -1181,6 +1181,7 @@
 	memcpy(arrnam + namlen, HOOK_SUFFIX, HOOK_SUFFIX_LEN);
 
 	if ((arrptr = getaparam(arrnam))) {
+	    arrptr = arrdup(arrptr);
 	    for (; *arrptr; arrptr++) {
 		if ((shfunc = getshfunc(*arrptr))) {
 		    int newret = doshfunc(shfunc, lnklst, 1);

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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