zsh-workers
 help / color / mirror / code / Atom feed
* Re: zsh 4.3.13 released
       [not found] <15488.1322689558@pws-pc.ntlworld.com>
@ 2011-12-01 12:27 ` Oliver Kiddle
  2011-12-01 12:52   ` Peter Stephenson
       [not found] ` <20111203191925.GB1294@coredump.raveland.priv>
  1 sibling, 1 reply; 13+ messages in thread
From: Oliver Kiddle @ 2011-12-01 12:27 UTC (permalink / raw)
  To: Zsh workers

Peter Stephenson wrote:
> I've uploaded zsh 4.3.13 to ftp://ftp.zsh.org/pub/.  If you get a chance
> to try it out before I upload it to Sourceforge, too, that would be
> great.

On Solaris, I get the following test failure. It is just slightly
different error message wording so probably harmless. Is part of
that message perhaps coming from strerror?

./A04redirect.ztst: starting.
*** /tmp/zsh.ztst.err.26521     Thu Dec  1 12:16:47 2011
--- /tmp/zsh.ztst.terr.26521    Thu Dec  1 12:16:47 2011
***************
*** 1 ****
! (eval):1: failed to close file descriptor 3: bad file descriptor
--- 1 ----
! (eval):1: failed to close file descriptor 3: bad file number
Test ./A04redirect.ztst failed: error output differs from expected as
shown above for:
  (exec 3<&-
  read foo <&-)
Was testing: '<&-' redirection

Oliver


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-01 12:27 ` zsh 4.3.13 released Oliver Kiddle
@ 2011-12-01 12:52   ` Peter Stephenson
  2011-12-01 21:27     ` PATCH: test output pattern matching Peter Stephenson
  2011-12-01 23:48     ` zsh 4.3.13 released Baptiste Daroussin
  0 siblings, 2 replies; 13+ messages in thread
From: Peter Stephenson @ 2011-12-01 12:52 UTC (permalink / raw)
  To: Zsh workers

On Thu, 1 Dec 2011 13:27:10 +0100
Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
> Peter Stephenson wrote:
> > I've uploaded zsh 4.3.13 to ftp://ftp.zsh.org/pub/.  If you get a chance
> > to try it out before I upload it to Sourceforge, too, that would be
> > great.
> 
> On Solaris, I get the following test failure. It is just slightly
> different error message wording so probably harmless. Is part of
> that message perhaps coming from strerror?

Yes, that's the problem; it's entirely harmless.  We really need a way
of telling the test system that it should match output by pattern, but
I've never got round to it.

Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.20
diff -p -u -r1.20 A04redirect.ztst
--- Test/A04redirect.ztst	26 Oct 2011 18:48:13 -0000	1.20
+++ Test/A04redirect.ztst	1 Dec 2011 12:50:23 -0000
@@ -153,17 +153,31 @@
 >goodbye
 
   (exec 3<&-
-  read foo <&-)
-1:'<&-' redirection
-?(eval):1: failed to close file descriptor 3: bad file descriptor
+  read foo <&-) 2>errmsg1.txt
+  mystat=$?
+  (( $mystat == 1 )) || print "Unexpected error status $mystat" >&2
+  input=("${(f)$(<errmsg1.txt)}")
+  if [[ ${#input} != 1 || \
+        $input[1] !=   "(eval):1: failed to close file descriptor 3:"* ]];
+  then
+    print "Unexpected error output:\n$input" >&2
+  fi
+0:'<&-' redirection
 
   print foo >&-
 0:'>&-' redirection
 
   (exec >&-
-  print foo)
+  print foo) 2>errmsg2.txt
+  mystat=$?
+  (( $mystat == 0 )) || print "Unexpected error status $mystat" >&2
+  input=("${(f)$(<errmsg2.txt)}")
+  if [[ ${#input} != 1 || \
+        $input[1] !=   "(eval):2: write error:"* ]];
+  then
+    print "Unexpected error output:\n$input" >&2
+  fi
 0:'>&-' with attempt to use closed fd
-?(eval):2: write error: bad file descriptor
 
   fn() { local foo; read foo; print $foo; }
   coproc fn

-- 
Peter Stephenson <pws@csr.com>            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
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* PATCH: test output pattern matching
  2011-12-01 12:52   ` Peter Stephenson
@ 2011-12-01 21:27     ` Peter Stephenson
  2011-12-02 17:03       ` ports
  2011-12-01 23:48     ` zsh 4.3.13 released Baptiste Daroussin
  1 sibling, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2011-12-01 21:27 UTC (permalink / raw)
  To: Zsh workers

On Thu, 1 Dec 2011 12:52:47 +0000
Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> We really need a way of telling the test system that it should match
> output by pattern, but I've never got round to it.

This could probably be used in other places.

Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.21
diff -p -u -r1.21 A04redirect.ztst
--- Test/A04redirect.ztst	1 Dec 2011 14:22:56 -0000	1.21
+++ Test/A04redirect.ztst	1 Dec 2011 21:24:02 -0000
@@ -153,31 +153,17 @@
 >goodbye
 
   (exec 3<&-
-  read foo <&-) 2>errmsg1.txt
-  mystat=$?
-  (( $mystat == 1 )) || print "Unexpected error status $mystat" >&2
-  input=("${(f)$(<errmsg1.txt)}")
-  if [[ ${#input} != 1 || \
-        $input[1] !=   "(eval):1: failed to close file descriptor 3:"* ]];
-  then
-    print "Unexpected error output:\n$input" >&2
-  fi
-0:'<&-' redirection
+  read foo <&-)
+1:'<&-' redirection
+*?\(eval\):1: failed to close file descriptor 3:*
 
   print foo >&-
 0:'>&-' redirection
 
   (exec >&-
-  print foo) 2>errmsg2.txt
-  mystat=$?
-  (( $mystat == 0 )) || print "Unexpected error status $mystat" >&2
-  input=("${(f)$(<errmsg2.txt)}")
-  if [[ ${#input} != 1 || \
-        $input[1] !=   "(eval):2: write error:"* ]];
-  then
-    print "Unexpected error output:\n$input" >&2
-  fi
+  print foo)
 0:'>&-' with attempt to use closed fd
+*?\(eval\):2: write error:*
 
   fn() { local foo; read foo; print $foo; }
   coproc fn
Index: Test/B01cd.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/B01cd.ztst,v
retrieving revision 1.4
diff -p -u -r1.4 B01cd.ztst
--- Test/B01cd.ztst	20 Mar 2009 22:52:56 -0000	1.4
+++ Test/B01cd.ztst	1 Dec 2011 21:24:02 -0000
@@ -57,6 +57,14 @@
 # lines are not subject to any substitution unless the `q' flag (see
 # below) is set.
 #
+# '>' and '?' may be preceded by a '*', in which case all lines
+# in the chunk must be so delimited (i.e. all lines must start either
+# '*>' or '>' but not a mixture).  If the '*' is present, the lines
+# in the actual output are pattern matched against the lines in the
+# test output.  The entire line following '*>' or '*?' must be a
+# valid pattern, so characters special to patterns such as parentheses
+# must be quoted.  The EXTENDED_GLOB option is used for all such patterns.
+#
 # Each chunk of indented code is to be evaluated in one go and is to
 # be followed by a line starting (in the first column) with
 # the expected status returned by the code when run, or - if it is
Index: Test/ztst.zsh
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/ztst.zsh,v
retrieving revision 1.29
diff -p -u -r1.29 ztst.zsh
--- Test/ztst.zsh	25 Dec 2007 01:40:18 -0000	1.29
+++ Test/ztst.zsh	1 Dec 2011 21:24:02 -0000
@@ -285,12 +285,52 @@ $ZTST_code" && return 0
 
 # diff wrapper
 ZTST_diff() {
-  local diff_out diff_ret
+  emulate -L zsh
+  setopt extendedglob
 
-  diff_out=$(diff "$@")
-  diff_ret="$?"
-  if [[ "$diff_ret" != "0" ]]; then
-    print -r "$diff_out"
+  local diff_out
+  integer diff_pat diff_ret
+
+  case $1 in
+    (p)
+    diff_pat=1
+    ;;
+
+    (d)
+    ;;
+
+    (*)
+    print "Bad ZTST_diff code: d for diff, p for pattern match"
+    ;;
+  esac
+  shift
+      
+  if (( diff_pat )); then
+    local -a diff_lines1 diff_lines2
+    integer failed i
+
+    diff_lines1=("${(f)$(<$argv[-2])}")
+    diff_lines2=("${(f)$(<$argv[-1])}")
+    if (( ${#diff_lines1} != ${#diff_lines2} )); then
+      failed=1
+    else
+      for (( i = 1; i <= ${#diff_lines1}; i++ )); do
+	if [[ ${diff_lines2[i]} != ${~diff_lines1[i]} ]]; then
+	  failed=1
+	  break
+	fi
+      done
+    fi
+    if (( failed )); then
+      print -rl "Pattern match failed:" \<${^diff_lines1} \>${^diff_lines2}
+      diff_ret=1
+    fi
+  else
+    diff_out=$(diff "$@")
+    diff_ret="$?"
+    if [[ "$diff_ret" != "0" ]]; then
+      print -r "$diff_out"
+    fi
   fi
 
   return "$diff_ret"
@@ -298,6 +338,7 @@ ZTST_diff() {
     
 ZTST_test() {
   local last match mbegin mend found substlines
+  local diff_out diff_err
 
   while true; do
     rm -f $ZTST_in $ZTST_out $ZTST_err
@@ -305,6 +346,8 @@ ZTST_test() {
     ZTST_message=''
     ZTST_failmsg=''
     found=0
+    diff_out=d
+    diff_err=d
 
     ZTST_verbose 2 "ZTST_test: looking for new test"
 
@@ -343,10 +386,20 @@ $ZTST_curline"
 	('<'*) ZTST_getredir || return 1
 	  found=1
 	  ;;
-	('>'*) ZTST_getredir || return 1
+	('*>'*)
+	  ZTST_curline=${ZTST_curline[2,-1]}
+	  diff_out=p
+	  ;&
+	('>'*)
+	  ZTST_getredir || return 1
 	  found=1
 	  ;;
-	('?'*) ZTST_getredir || return 1
+	('*?'*)
+	  ZTST_curline=${ZTST_curline[2,-1]}
+	  diff_err=p
+	  ;&
+	('?'*)
+	  ZTST_getredir || return 1
 	  found=1
 	  ;;
 	('F:'*) ZTST_failmsg="${ZTST_failmsg:+${ZTST_failmsg}
@@ -390,7 +443,7 @@ $(<$ZTST_terr)"
 	rm -rf $ZTST_out
 	print -r -- "${(e)substlines}" >$ZTST_out
       fi
-      if [[ $ZTST_flags != *d* ]] && ! ZTST_diff -c $ZTST_out $ZTST_tout; then
+      if [[ $ZTST_flags != *d* ]] && ! ZTST_diff $diff_out -c $ZTST_out $ZTST_tout; then
 	ZTST_testfailed "output differs from expected as shown above for:
 $ZTST_code${$(<$ZTST_terr):+
 Error output:
@@ -402,7 +455,7 @@ $(<$ZTST_terr)}"
 	rm -rf $ZTST_err
 	print -r -- "${(e)substlines}" >$ZTST_err
       fi
-      if [[ $ZTST_flags != *D* ]] && ! ZTST_diff -c $ZTST_err $ZTST_terr; then
+      if [[ $ZTST_flags != *D* ]] && ! ZTST_diff $diff_err -c $ZTST_err $ZTST_terr; then
 	ZTST_testfailed "error output differs from expected as shown above for:
 $ZTST_code"
 	return 1

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-01 12:52   ` Peter Stephenson
  2011-12-01 21:27     ` PATCH: test output pattern matching Peter Stephenson
@ 2011-12-01 23:48     ` Baptiste Daroussin
  2011-12-02 13:34       ` Peter Stephenson
  1 sibling, 1 reply; 13+ messages in thread
From: Baptiste Daroussin @ 2011-12-01 23:48 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh workers

2011/12/1 Peter Stephenson <Peter.Stephenson@csr.com>:
> On Thu, 1 Dec 2011 13:27:10 +0100
> Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>> Peter Stephenson wrote:
>> > I've uploaded zsh 4.3.13 to ftp://ftp.zsh.org/pub/.  If you get a chance
>> > to try it out before I upload it to Sourceforge, too, that would be
>> > great.
>>

On FreeBSD I have the following error in make test:
Test ./D07multibyte.ztst failed: output differs from expected as shown above for
:
  (print $'\u00e9') 2>&1 | read
  if [[ $REPLY != \xc3\xa9 ]]; then
    print "warning: your system can't do simple Unicode conversion." >&$ZTST_fd
    print "Check you have a correctly installed iconv library." >&$ZTST_fd
    # cheat
    repeat 4 print OK
  else
    testfn() { (LC_ALL=C; print $'\u00e9') }
    repeat 4 testfn 2>&1 | while read line; do
      if [[ $line = *"character not in range"* ]]; then
        print OK
      elif [[ $line = "?" ]]; then
        print OK
      else
        print Failed: no error message and no question mark
      fi
    done
  fi
  true
Was testing: error handling in Unicode quoting

The same problem occurs with zsh 4.3.12 by the way, so not a regression

regards,
Bapt


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-01 23:48     ` zsh 4.3.13 released Baptiste Daroussin
@ 2011-12-02 13:34       ` Peter Stephenson
  2011-12-02 23:06         ` Baptiste Daroussin
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2011-12-02 13:34 UTC (permalink / raw)
  To: Zsh workers

On Thu, 1 Dec 2011 23:48:26 +0000
Baptiste Daroussin <baptiste.daroussin@gmail.com> wrote:
> On FreeBSD I have the following error in make test:
> Test ./D07multibyte.ztst failed: output differs from expected as shown
> above for

I've a vague memory of this --- it's fairly well down the tests so my
guess is it's to do with different handling of invalid characters for
the locale, which isn't a big issue and probably not really a shell
issue at all.  However, that's a guess.

-- 
Peter Stephenson <pws@csr.com>            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
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: PATCH: test output pattern matching
  2011-12-01 21:27     ` PATCH: test output pattern matching Peter Stephenson
@ 2011-12-02 17:03       ` ports
  2011-12-02 17:23         ` Peter Stephenson
  0 siblings, 1 reply; 13+ messages in thread
From: ports @ 2011-12-02 17:03 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh workers

On Thu, Dec 01, 2011 at 09:27:42PM +0000, Peter Stephenson wrote:
> On Thu, 1 Dec 2011 12:52:47 +0000
> Peter Stephenson <Peter.Stephenson@csr.com> wrote:
> > We really need a way of telling the test system that it should match
> > output by pattern, but I've never got round to it.
> 
> This could probably be used in other places.
[snip..]

Hi,

I still have an error on OpenBSD with this patch:

./A04redirect.ztst: starting.
*** /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.err.6420     Fri Dec  2 17:58:33 2011
--- /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.terr.6420    Fri Dec  2 17:58:33 2011
***************
*** 1 ****
- (eval):1: failed to close file descriptor 3: bad file descriptor
--- 0 ----
Test ./A04redirect.ztst failed: error output differs from expected as shown above for:
  (exec 3<&-
  read foo <&-)
Was testing: '<&-' redirection
./A04redirect.ztst: test failed.


Regards,


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: PATCH: test output pattern matching
  2011-12-02 17:03       ` ports
@ 2011-12-02 17:23         ` Peter Stephenson
  2011-12-03 19:17           ` ports
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2011-12-02 17:23 UTC (permalink / raw)
  To: Zsh workers

On Fri, 2 Dec 2011 18:03:56 +0100
<ports@raveland.org> wrote:
> ./A04redirect.ztst: starting.
> *** /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.err.6420     Fri Dec  2 17:58:33 2011
> --- /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.terr.6420    Fri Dec  2 17:58:33 2011
> ***************
> *** 1 ****
> - (eval):1: failed to close file descriptor 3: bad file descriptor
> --- 0 ----

That might mean file descriptor 3 is open, so closing it didn't
fail.  What we could do is ensure it's closed, ignoring the status and
error output, then try to close it again.

Index: Test/A04redirect.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
retrieving revision 1.22
diff -p -u -r1.22 A04redirect.ztst
--- Test/A04redirect.ztst	1 Dec 2011 21:52:55 -0000	1.22
+++ Test/A04redirect.ztst	2 Dec 2011 17:22:56 -0000
@@ -152,10 +152,11 @@
 >hello
 >goodbye
 
-  (exec 3<&-
+  ({ exec 3<&- } 2>/dev/null
+  exec 3<&-
   read foo <&-)
 1:'<&-' redirection
-*?\(eval\):1: failed to close file descriptor 3:*
+*?\(eval\):*: failed to close file descriptor 3:*
 
   print foo >&-
 0:'>&-' redirection

-- 
Peter Stephenson <pws@csr.com>            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
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-02 13:34       ` Peter Stephenson
@ 2011-12-02 23:06         ` Baptiste Daroussin
  0 siblings, 0 replies; 13+ messages in thread
From: Baptiste Daroussin @ 2011-12-02 23:06 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh workers

2011/12/2 Peter Stephenson <Peter.Stephenson@csr.com>:
> On Thu, 1 Dec 2011 23:48:26 +0000
> Baptiste Daroussin <baptiste.daroussin@gmail.com> wrote:
>> On FreeBSD I have the following error in make test:
>> Test ./D07multibyte.ztst failed: output differs from expected as shown
>> above for
>
> I've a vague memory of this --- it's fairly well down the tests so my
> guess is it's to do with different handling of invalid characters for
> the locale, which isn't a big issue and probably not really a shell
> issue at all.  However, that's a guess.
>
> --
> Peter Stephenson <pws@csr.com>            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
> More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog

All my zsh scripts, works the way they should :), and I used it all
the day now, no problem so far, and the same "errors" are shown in
4.3.12, everyone lives with 4.3.12 on freebsd with no complaints so
far, should be the same with 4.3.13, as far as I'm concerned 4.3.13 is
ok on freebsd.

Sorry for noise.

regards,
Bapt


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: PATCH: test output pattern matching
  2011-12-02 17:23         ` Peter Stephenson
@ 2011-12-03 19:17           ` ports
  0 siblings, 0 replies; 13+ messages in thread
From: ports @ 2011-12-03 19:17 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh workers

On Fri, Dec 02, 2011 at 05:23:53PM +0000, Peter Stephenson wrote:
> On Fri, 2 Dec 2011 18:03:56 +0100
> <ports@raveland.org> wrote:
> > ./A04redirect.ztst: starting.
> > *** /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.err.6420     Fri Dec  2 17:58:33 2011
> > --- /usr/ports/pobj/zsh-4.3.13/zsh-4.3.13/tmp.ztst.terr.6420    Fri Dec  2 17:58:33 2011
> > ***************
> > *** 1 ****
> > - (eval):1: failed to close file descriptor 3: bad file descriptor
> > --- 0 ----
> 
> That might mean file descriptor 3 is open, so closing it didn't
> fail.  What we could do is ensure it's closed, ignoring the status and
> error output, then try to close it again.
> 
> Index: Test/A04redirect.ztst
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Test/A04redirect.ztst,v
> retrieving revision 1.22
> diff -p -u -r1.22 A04redirect.ztst
> --- Test/A04redirect.ztst	1 Dec 2011 21:52:55 -0000	1.22
> +++ Test/A04redirect.ztst	2 Dec 2011 17:22:56 -0000
> @@ -152,10 +152,11 @@
>  >hello
>  >goodbye
>  
> -  (exec 3<&-
> +  ({ exec 3<&- } 2>/dev/null
> +  exec 3<&-
>    read foo <&-)
>  1:'<&-' redirection
> -*?\(eval\):1: failed to close file descriptor 3:*
> +*?\(eval\):*: failed to close file descriptor 3:*
>  
>    print foo >&-
>  0:'>&-' redirection
> 

Thanks. With this diff, i no longer have the error.
Regards,


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
       [not found] ` <20111203191925.GB1294@coredump.raveland.priv>
@ 2011-12-03 19:44   ` Peter Stephenson
  2011-12-03 22:19     ` ports
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2011-12-03 19:44 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sat, 3 Dec 2011 20:19:25 +0100
ports@raveland.org wrote:
> Running test: Check that loading a nonexistent module fails
> **************************************
> 0 successful test scripts, 1 failure, 0 skipped
> **************************************
> 
> The last test fails silently.

So what does running "zmodload -i bogus/notamodule" by hand do?

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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-03 19:44   ` Peter Stephenson
@ 2011-12-03 22:19     ` ports
  2011-12-03 22:56       ` Peter Stephenson
  0 siblings, 1 reply; 13+ messages in thread
From: ports @ 2011-12-03 22:19 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Hackers' List

On Sat, Dec 03, 2011 at 07:44:42PM +0000, Peter Stephenson wrote:
> On Sat, 3 Dec 2011 20:19:25 +0100
> ports@raveland.org wrote:
> > Running test: Check that loading a nonexistent module fails
> > **************************************
> > 0 successful test scripts, 1 failure, 0 skipped
> > **************************************
> > 
> > The last test fails silently.
> 
> So what does running "zmodload -i bogus/notamodule" by hand do?

zsh crashes..

% zmodload -i bogus/notamodule
Segmentation fault (core dumped)
$ gdb /usr/local/bin/zsh zsh.core
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-unknown-openbsd5.0"...
Core was generated by `zsh'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/local/lib/libpcre.so.2.5...done.
Loaded symbols for /usr/local/lib/libpcre.so.2.5
Reading symbols from /usr/local/lib/libiconv.so.6.0...done.
Loaded symbols for /usr/local/lib/libiconv.so.6.0
Reading symbols from /usr/lib/libncursesw.so.12.1...done.
Loaded symbols for /usr/lib/libncursesw.so.12.1
Reading symbols from /usr/lib/libm.so.7.0...done.
Loaded symbols for /usr/lib/libm.so.7.0
Reading symbols from /usr/lib/libc.so.61.0...done.
Loaded symbols for /usr/lib/libc.so.61.0
Reading symbols from /usr/libexec/ld.so...done.
Loaded symbols for /usr/libexec/ld.so
Reading symbols from /usr/local/lib/zsh/4.3.13/zsh/zle.so...done.
Loaded symbols for /usr/local/lib/zsh/4.3.13/zsh/zle.so
Reading symbols from /usr/local/lib/zsh/4.3.13/zsh/complete.so...done.
Loaded symbols for /usr/local/lib/zsh/4.3.13/zsh/complete.so
Reading symbols from /usr/local/lib/zsh/4.3.13/zsh/zutil.so...done.
Loaded symbols for /usr/local/lib/zsh/4.3.13/zsh/zutil.so
Reading symbols from /usr/local/lib/zsh/4.3.13/zsh/parameter.so...done.
Loaded symbols for /usr/local/lib/zsh/4.3.13/zsh/parameter.so
Reading symbols from /usr/local/lib/zsh/4.3.13/zsh/computil.so...done.
Loaded symbols for /usr/local/lib/zsh/4.3.13/zsh/computil.so
#0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006
4006        *e = '\0';
(gdb) bt
#0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006
#1  0x0000000000456c53 in do_load_module (name=0x995240 "bogus/notamodule", silent=0) at module.c:1600
#2  0x000000000045786d in load_module (name=0x995240 "bogus/notamodule", enablesarr=0x0, silent=0) at module.c:2202
#3  0x000000000045821d in require_module (module=0x995240 "bogus/notamodule", features=0x0) at module.c:2335
#4  0x0000000000459acd in bin_zmodload_load (nam=0x995228 "zmodload", args=0x7f7ffffd3ff8, ops=0x7f7ffffd40d0) at module.c:2971
#5  0x0000000000458914 in bin_zmodload (nam=0x995228 "zmodload", args=0x7f7ffffd3ff8, ops=0x7f7ffffd40d0, func=0) at module.c:2486
#6  0x000000000040edb8 in execbuiltin (args=0x9951c8, bn=0x6a42e0) at builtin.c:450
#7  0x0000000000429a60 in execcmd (state=0x7f7ffffd46e0, input=0, output=0, how=18, last1=2) at exec.c:3208
#8  0x000000000042535e in execpline2 (state=0x7f7ffffd46e0, pcode=259, how=18, input=0, output=0, last1=0) at exec.c:1640
#9  0x00000000004248d1 in execpline (state=0x7f7ffffd46e0, slcode=5122, how=18, last1=0) at exec.c:1424
#10 0x0000000000424119 in execlist (state=0x7f7ffffd46e0, dont_change_job=0, exiting=0) at exec.c:1207
#11 0x0000000000423b6c in execode (p=0x995100, dont_change_job=0, exiting=0, context=0x597eb7 "toplevel") at exec.c:1028
#12 0x000000000043f587 in loop (toplevel=1, justonce=0) at init.c:185
#13 0x00000000004423d9 in zsh_main (argc=1, argv=0x7f7ffffd4830) at init.c:1528
#14 0x000000000040e19b in main (argc=1, argv=0x7f7ffffd4830) at ./main.c:93
(gdb)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-03 22:19     ` ports
@ 2011-12-03 22:56       ` Peter Stephenson
  2011-12-04 12:42         ` ports
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Stephenson @ 2011-12-03 22:56 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sat, 3 Dec 2011 23:19:54 +0100
ports@raveland.org wrote:
> % zmodload -i bogus/notamodule
> Segmentation fault (core dumped)
>....
> #0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006
> 4006        *e = '\0';
> (gdb) bt
> #0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006

heap=1 is META_USEHEAP: "get memory from the heap.  This leaves buf
unchanged."  However, the function unconditionally attempts to add nullL
termination.  A defence lawyer could probably claim that adding a null
when there was one already there wasn't actually modification.  Not sure
how we've avoided seeing this before.

It seems some parts of the code are relying on the fact that the NULL
gets added even if the string doesn't need metafying.  Treating the
absence of NULL termination as a reason for modifying the buffer was the
neatest of the three fixes I came up with.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.264
diff -p -u -r1.264 utils.c
--- Src/utils.c	15 Nov 2011 15:08:57 -0000	1.264
+++ Src/utils.c	3 Dec 2011 22:51:19 -0000
@@ -3959,7 +3959,7 @@ metafy(char *buf, int len, int heap)
 	    if (imeta(*e++))
 		meta++;
 
-    if (meta || heap == META_DUP || heap == META_HEAPDUP) {
+    if (meta || heap == META_DUP || heap == META_HEAPDUP || *e != '\0') {
 	switch (heap) {
 	case META_REALLOC:
 	    buf = zrealloc(buf, len + meta + 1);
@@ -4002,8 +4002,8 @@ metafy(char *buf, int len, int heap)
 		meta--;
 	    }
 	}
+	*e = '\0';
     }
-    *e = '\0';
     return buf;
 }
 
-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: zsh 4.3.13 released
  2011-12-03 22:56       ` Peter Stephenson
@ 2011-12-04 12:42         ` ports
  0 siblings, 0 replies; 13+ messages in thread
From: ports @ 2011-12-04 12:42 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Hackers' List

On Sat, Dec 03, 2011 at 10:56:10PM +0000, Peter Stephenson wrote:
> On Sat, 3 Dec 2011 23:19:54 +0100
> ports@raveland.org wrote:
> > % zmodload -i bogus/notamodule
> > Segmentation fault (core dumped)
> >....
> > #0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006
> > 4006        *e = '\0';
> > (gdb) bt
> > #0  0x000000000048f5bc in metafy (buf=0x207a096d7 "File not found", len=14, heap=1) at utils.c:4006
> 
> heap=1 is META_USEHEAP: "get memory from the heap.  This leaves buf
> unchanged."  However, the function unconditionally attempts to add nullL
> termination.  A defence lawyer could probably claim that adding a null
> when there was one already there wasn't actually modification.  Not sure
> how we've avoided seeing this before.
> 
> It seems some parts of the code are relying on the fact that the NULL
> gets added even if the string doesn't need metafying.  Treating the
> absence of NULL termination as a reason for modifying the buffer was the
> neatest of the three fixes I came up with.
> 
> Index: Src/utils.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
> retrieving revision 1.264
> diff -p -u -r1.264 utils.c
> --- Src/utils.c	15 Nov 2011 15:08:57 -0000	1.264
> +++ Src/utils.c	3 Dec 2011 22:51:19 -0000
> @@ -3959,7 +3959,7 @@ metafy(char *buf, int len, int heap)
>  	    if (imeta(*e++))
>  		meta++;
>  
> -    if (meta || heap == META_DUP || heap == META_HEAPDUP) {
> +    if (meta || heap == META_DUP || heap == META_HEAPDUP || *e != '\0') {
>  	switch (heap) {
>  	case META_REALLOC:
>  	    buf = zrealloc(buf, len + meta + 1);
> @@ -4002,8 +4002,8 @@ metafy(char *buf, int len, int heap)
>  		meta--;
>  	    }
>  	}
> +	*e = '\0';
>      }
> -    *e = '\0';
>      return buf;
>  }
>  

Works fine::
% zmodload -i bogus/notamodule
zsh: failed to load module `bogus/notamodule': File not found

Now Zsh works fine on OpenBSD. Thanks !
40 successful test scripts, 0 failures, 0 skipped

Regards,

-- 
Pierre-Emmanuel André <pea at raveland.org>
GPG key: 0x7AE329DC


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-12-04 12:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <15488.1322689558@pws-pc.ntlworld.com>
2011-12-01 12:27 ` zsh 4.3.13 released Oliver Kiddle
2011-12-01 12:52   ` Peter Stephenson
2011-12-01 21:27     ` PATCH: test output pattern matching Peter Stephenson
2011-12-02 17:03       ` ports
2011-12-02 17:23         ` Peter Stephenson
2011-12-03 19:17           ` ports
2011-12-01 23:48     ` zsh 4.3.13 released Baptiste Daroussin
2011-12-02 13:34       ` Peter Stephenson
2011-12-02 23:06         ` Baptiste Daroussin
     [not found] ` <20111203191925.GB1294@coredump.raveland.priv>
2011-12-03 19:44   ` Peter Stephenson
2011-12-03 22:19     ` ports
2011-12-03 22:56       ` Peter Stephenson
2011-12-04 12:42         ` ports

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