bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: /dev/fd/n bug in gawk 3.1.5


From: Aharon Robbins
Subject: Re: /dev/fd/n bug in gawk 3.1.5
Date: Tue, 16 Jan 2007 22:13:42 +0200

Greetings.  Although I fixed the code that was the cause of this some time
back, I figured that it'd be a good idea to add this into the test suite
too, in case the feature breaks again.

So, this is now in my tree, and should be reflected in the CVS on
Savanah shortly.

Thanks,

Arnold

> Date: Mon, 03 Jul 2006 16:54:19 -0400
> From: "Andrew J. Schorr" <address@hidden>
> Subject: Re: /dev/fd/n bug in gawk 3.1.5
> To: Aharon Robbins <address@hidden>
> Cc: =?iso-8859-1?Q?J=FCrgen?= Kahrs <address@hidden>,
>         address@hidden, address@hidden
>
> Hi,
>
> Note that the pid test was failing silently: "make check" was
> reporting "ALL TESTS PASSED" even though gawk was SEGV'ing
> in the pid test.  Attached is a patch to the pid test
> that fixes this problem (i.e. the test will now fail noisily).
> The problem was that the SEGV was aborting the script
> prematurely, and leaving a zero-length output file, which was
> precisely correct.  The fix was to make sure that test/pid.awk
> produces some output.  That way we get a comparison failure
> if the output file is empty.
>
> Patch attached.
>
> Regards,
> Andy
>
>
> #####################################################################################
> This Mail Was Scanned by 012.net AntiVirus Service2- Powered by TrendMicro 
> Interscan
> --xHFwDpU9dbj6ez1V
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename="pidtest.patch"
>
> Index: test/ChangeLog
> ===================================================================
> RCS file: /cvsroot/xmlgawk/xmlgawk/test/ChangeLog,v
> retrieving revision 1.2
> diff -b -u -p -r1.2 ChangeLog
> --- test/ChangeLog    1 Jan 2006 22:46:23 -0000       1.2
> +++ test/ChangeLog    3 Jul 2006 20:53:34 -0000
> @@ -1,3 +1,13 @@
> +Mon Jul  3 20:50:31 2006  Andrew J. Schorr <address@hidden>
> +
> +     * Makefile.am: In pid test, no further need to remove _pid.in,
> +     since the test no longer creates that file.
> +     * pid.awk: Do not read correct values from stdin (they are now passed
> +     as command-line variables with -v).  Make sure to produce output
> +     if the comparisons are successful.
> +     * pid.ok: No longer empty, should contain 3 lines if all goes well.
> +     * pid.sh: Do not create _pid.in; instead, pass values in with -v.
> +
>  Tue Jul 26 21:46:16 2005  Arnold D. Robbins  <address@hidden>
>  
>       * Release 3.1.5: Release tar file made.
> Index: test/Makefile.am
> ===================================================================
> RCS file: /cvsroot/xmlgawk/xmlgawk/test/Makefile.am,v
> retrieving revision 1.40
> diff -b -u -p -r1.40 Makefile.am
> --- test/Makefile.am  22 Mar 2006 21:11:35 -0000      1.40
> +++ test/Makefile.am  3 Jul 2006 20:53:34 -0000
> @@ -902,7 +902,7 @@ tradanch::
>  pid::
>       @echo pid
>       @AWKPATH=$(srcdir) AWK=$(AWKPROG) $(SHELL) $(srcdir)/pid.sh $$$$ > 
> _`basename address@hidden ; :
> -     @-$(CMP) $(srcdir)/pid.ok _`basename address@hidden && rm -f _`basename 
> address@hidden _`basename address@hidden
> +     @-$(CMP) $(srcdir)/pid.ok _`basename address@hidden && rm -f _`basename 
> address@hidden
>  
>  strftlng::
>       @echo $@
> Index: test/pid.awk
> ===================================================================
> RCS file: /cvsroot/xmlgawk/xmlgawk/test/pid.awk,v
> retrieving revision 1.1.1.1
> diff -b -u -p -r1.1.1.1 pid.awk
> --- test/pid.awk      4 Jun 1997 16:38:16 -0000       1.1.1.1
> +++ test/pid.awk      3 Jul 2006 20:53:34 -0000
> @@ -27,18 +27,20 @@
>  BEGIN {
>       getline pid <"/dev/pid"
>       getline ppid <"/dev/ppid"
> -}
> -NR == 1 {
> -     if (pid != $0) {
> -             printf "Bad pid %d, wanted %d\n", $0, pid
> -     }
> -}
> -NR == 2 {
> -     if (ppid != $0) {
> -             printf "Bad ppid %d, wanted %d\n", $0, ppid
> -     }
> -}
> -END {        # ADR --- added
> +
> +     if (pid != ok_pid)
> +             printf "Bad pid %d, wanted %d\n", pid, ok_pid
> +     else
> +             print "PID ok"
> +
> +     if (ppid != ok_ppid)
> +             printf "Bad ppid %d, wanted %d\n", ppid, ok_ppid
> +     else
> +             print "PPID ok"
> +
> +     # ADR --- added
>       close("/dev/pid")
>       close("/dev/ppid")
> +
> +     print "All Done."
>  }
> Index: test/pid.ok
> ===================================================================
> RCS file: /cvsroot/xmlgawk/xmlgawk/test/pid.ok,v
> retrieving revision 1.1.1.1
> diff -b -u -p -r1.1.1.1 pid.ok
> --- test/pid.ok       4 Jun 1997 16:38:33 -0000       1.1.1.1
> +++ test/pid.ok       3 Jul 2006 20:53:34 -0000
> @@ -0,0 +1,3 @@
> +PID ok
> +PPID ok
> +All Done.
> Index: test/pid.sh
> ===================================================================
> RCS file: /cvsroot/xmlgawk/xmlgawk/test/pid.sh,v
> retrieving revision 1.1.1.1
> diff -b -u -p -r1.1.1.1 pid.sh
> --- test/pid.sh       4 Jun 1997 17:18:10 -0000       1.1.1.1
> +++ test/pid.sh       3 Jul 2006 20:53:34 -0000
> @@ -1,5 +1,3 @@
>  #! /bin/sh
>  AWK=${AWK-../gawk}
> -echo $$ > _pid.in
> -echo $1 >> _pid.in
> -exec $AWK -f pid.awk _pid.in 2>/dev/null
> +exec $AWK -v "ok_pid=$$" -v "ok_ppid=$1" -f pid.awk 2>/dev/null




reply via email to

[Prev in Thread] Current Thread [Next in Thread]