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

Re: Segfault in =( ) substitution



On Sun, 14 Oct 2012 23:30:28 -0400
Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx> wrote:
> Starting very recently, I'm getting a core dump from this code:
>...
> [[ -n $pat1 ]] && diff1=( =(perl -p -e $pat1 < $file1) )

This should fix the crash, however the resulting code isn't very useful.
The job created for the assignment finishes after the assigment
finishes, so the contents of the array is a file that's already been
deleted.

I'm not really sure if there's anything sensible to be done about this.
It might be possible to detect that the assignment is within some other
structure, e.g. shell function, and associate it with that (maybe this
used to happen by accident before), but in a top-level script or
interactive shell there's no such job, so this doesn't generally work.

Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.92
diff -p -u -r1.92 parse.c
--- Src/parse.c	11 Oct 2012 20:14:03 -0000	1.92
+++ Src/parse.c	17 Oct 2012 19:16:13 -0000
@@ -1610,6 +1610,11 @@ par_simple(int *complex, int nr)
 	} else if (tok == ENVARRAY) {
 	    int oldcmdpos = incmdpos, n, type2;
 
+	    /*
+	     * We consider array setting complex because it can
+	     * contain process substitutions, which need a valid job.
+	     */
+	    *complex = c = 1;
 	    p = ecadd(0);
 	    incmdpos = 0;
 	    if ((type2 = strlen(tokstr) - 1) && tokstr[type2] == '+') {

-- 
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