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

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

Re: too long source lines that are in error can core dump gawk 3.1.0


From: Aharon Robbins
Subject: Re: too long source lines that are in error can core dump gawk 3.1.0
Date: Tue, 27 Nov 2001 14:50:32 +0200

> From address@hidden  Mon Nov 26 19:53:21 2001
> X-From_: address@hidden Mon Nov 26 19:25:01 2001
> To: address@hidden (Aharon Robbins)
> Cc: address@hidden
> Subject: Re: too long source lines that are in error can core dump gawk 3.1.0
> X-Yow: I like your SNOOPY POSTER!!
> From: Andreas Schwab <address@hidden>
> Date: 26 Nov 2001 17:15:27 +0100
> Content-Type: text/plain; charset=iso-8859-15
> Content-Transfer-Encoding: quoted-printable
>
> address@hidden (Aharon Robbins) writes:
>
> |> > To: address@hidden
Hi Andreas.  Re this:

> |> > Subject: found awk "internal error"
> |> > Date: Tue, 30 Oct 2001 12:39:40 +0800 (CST)
> |> > From: Dan Jacobson
> |> >
> |> > I don't know that it was importaint, but i thought you should know...
> |> > it said "internal error" so I thoght you should know...
> |> > it is a product of some symple typo that i will now fix...
> |>=20
> |> It was a memory overrun.  In keeping with the "no arbitrary limits"
> |> principle of GNU software, this is now fixed.  Thanks for the report,
> |> and here's a patch.
>
> When I applied this patch three of the awk tests fail now, for example:
>
> --- noparms.ok        Wed Jun  4 18:38:15 1997
> +++ _noparms  Mon Nov 26 16:43:51 2001
> @@ -1,4 +1,4 @@
>  gawk: noparms.awk:1: function x(a, b, c , ,) {}
> -gawk: noparms.awk:1:                      ^ parse error
> +           ^ gawk: noparms.awk:1: parse error
>  gawk: noparms.awk:1: function x(a, b, c , ,) {}
> -gawk: noparms.awk:1:                       ^ parse error
> +           ^ gawk: noparms.awk:1: parse error
>
> Andreas.
>
> --=20
> Andreas Schwab                                  "And now for something
> address@hidden                                completely different."
> SuSE Labs, SuSE GmbH, Schanz=E4ckerstr. 10, D-90443 N=FCrnberg
> Key fingerprint =3D 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

Yes.  I've fixed it.  Here is a patch against 3.1.0 that fixes that
problem, and a few others.

Arnold
------------------------------------
*** ../gawk-3.1.0/awkgram.y     Mon Apr 23 10:25:58 2001
--- awkgram.y   Tue Nov 13 17:27:26 2001
***************
*** 438,444 ****
                {
                        $$ = node($3, $1, $5);
                        if ($$->type == Node_K_printf)
!                               count_args($$)
                }
        | print opt_rexpression_list output_redir statement_term
                {
--- 438,444 ----
                {
                        $$ = node($3, $1, $5);
                        if ($$->type == Node_K_printf)
!                               count_args($$);
                }
        | print opt_rexpression_list output_redir statement_term
                {
***************
*** 460,466 ****
  
                        $$ = node($2, $1, $3);
                        if ($$->type == Node_K_printf)
!                               count_args($$)
                }
        | LEX_NEXT statement_term
                { NODETYPE type;
--- 460,466 ----
  
                        $$ = node($2, $1, $3);
                        if ($$->type == Node_K_printf)
!                               count_args($$);
                }
        | LEX_NEXT statement_term
                { NODETYPE type;
***************
*** 819,825 ****
  
        | '-' simp_exp    %prec UNARY
                {
!                 if ($2->type == Node_val) {
                        $2->numbr = -(force_number($2));
                        $$ = $2;
                  } else
--- 819,825 ----
  
        | '-' simp_exp    %prec UNARY
                {
!                 if ($2->type == Node_val && ($2->flags & (STR|STRING)) == 0) {
                        $2->numbr = -(force_number($2));
                        $$ = $2;
                  } else
***************
*** 1006,1012 ****
        const char *mesg = NULL;
        register char *bp, *cp;
        char *scan;
!       char buf[120];
        static char end_of_file_line[] = "(END OF FILE)";
  
        errcount++;
--- 1006,1013 ----
        const char *mesg = NULL;
        register char *bp, *cp;
        char *scan;
!       char *buf;
!       int count;
        static char end_of_file_line[] = "(END OF FILE)";
  
        errcount++;
***************
*** 1033,1043 ****
                bp = thisline + strlen(thisline);
        }
        msg("%.*s", (int) (bp - thisline), thisline);
        bp = buf;
!       cp = buf + sizeof(buf) - 24;    /* 24 more than longest msg. input */
        if (lexptr != NULL) {
                scan = thisline;
!               while (bp < cp && scan < lexeme)
                        if (*scan++ == '\t')
                                *bp++ = '\t';
                        else
--- 1034,1057 ----
                bp = thisline + strlen(thisline);
        }
        msg("%.*s", (int) (bp - thisline), thisline);
+ 
+ #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
+       va_start(args, m);
+       if (mesg == NULL)
+               mesg = m;
+ #else
+       va_start(args);
+       if (mesg == NULL)
+               mesg = va_arg(args, char *);
+ #endif
+       count = (bp - thisline) + strlen(mesg) + 2 + 1;
+       emalloc(buf, char *, count, "yyerror");
+ 
        bp = buf;
! 
        if (lexptr != NULL) {
                scan = thisline;
!               while (scan < lexeme)
                        if (*scan++ == '\t')
                                *bp++ = '\t';
                        else
***************
*** 1045,1062 ****
                *bp++ = '^';
                *bp++ = ' ';
        }
- #if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__
-       va_start(args, m);
-       if (mesg == NULL)
-               mesg = m;
- #else
-       va_start(args);
-       if (mesg == NULL)
-               mesg = va_arg(args, char *);
- #endif
        strcpy(bp, mesg);
        err("", buf, args);
        va_end(args);
  }
  
  /* get_src_buf --- read the next buffer of source program */
--- 1059,1068 ----
                *bp++ = '^';
                *bp++ = ' ';
        }
        strcpy(bp, mesg);
        err("", buf, args);
        va_end(args);
+       free(buf);
  }
  
  /* get_src_buf --- read the next buffer of source program */



reply via email to

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