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

Re: Crash Re: Trial for 5.0.7



On Oct 2,  8:33pm, Bart Schaefer wrote:
}
} git-bisect says this is the bad revision:
} 
} commit 8189e12312ede991827efc6683b7ce8463deb0bf
} 
}     32552 (updated by 32560): fix segfault when using process substitution in
} anonymous function argument list
}     
}     Also disallow process substitution in function name position.

OK, I've narrowed it down to the parse.c hunks of the patch.  Remove
just that change, and the crash on piping to an anonymous function is
fixed, but this test fails:

./C04funcdef.ztst: starting.
Test ./C04funcdef.ztst failed: bad status 1, expected 0 from:
  () (cat $1 $2) <(print process expanded) =(print expanded to file)
Error output:
(eval):1: process substitution <(print process expanded) cannot be used here
Was testing: Process substitution with anonymous functions
./C04funcdef.ztst: test failed.

Here's the patch to revert workers/32552 (parse.c).  I haven't figured
out why fiddling with *complex here mangles the wordcode, some help is
appreciated.  Obviously the above test needs to pass.

diff --git a/Src/parse.c b/Src/parse.c
index 6cba050..a3fa83a 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1486,6 +1486,7 @@ par_funcdef(int *complex)
 	if (num == 0) {
 	    /* Anonymous function, possibly with arguments */
 	    incmdpos = 0;
+	    *complex = 1;
 	}
 	zshlex();
     } else if (unset(SHORTLOOPS)) {
@@ -1517,7 +1518,6 @@ par_funcdef(int *complex)
 	    num++;
 	    zshlex();
 	}
-	*complex = (num > 0);
 	ecbuf[parg] = ecused - parg; /*?*/
 	ecbuf[parg+1] = num;
     }
@@ -1751,6 +1751,7 @@ par_simple(int *complex, int nr)
 		if (argc == 0) {
 		    /* Anonymous function, possibly with arguments */
 		    incmdpos = 0;
+		    *complex = 1;
 		}
 		zshlex();
 	    } else {
@@ -1790,7 +1791,6 @@ par_simple(int *complex, int nr)
 		    argc++;
 		    zshlex();
 		}
-		*complex = (argc > 0);
 		ecbuf[parg] = ecused - parg; /*?*/
 		ecbuf[parg+1] = argc;
 	    }



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