bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Assert error in `debug.c:set_breakpoint` triggered by an


From: Aharon Robbins
Subject: Re: [bug-gawk] Assert error in `debug.c:set_breakpoint` triggered by an empty `b` command
Date: Tue, 24 Sep 2013 15:19:26 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Hi. Thanks for the report.

> Date: Tue, 24 Sep 2013 12:15:31 +0800
> From: Ray Song <address@hidden>
> To: address@hidden
> Subject: [bug-gawk] Assert error in `debug.c:set_breakpoint` triggered by an
>  empty `b` command
>
> gawk-4.1.0
> debug.c:2318          assert(rp != NULL);
>
> Here is a 
>
>     % ./gawk --version
>     GNU Awk 4.1.0, API: 1.0 (GNU MPFR 3.1.1-p2, GNU MP 5.1.0)
>     ...
>     
>     % ./gawk -D -f =(echo 1)
>     gawk> b 1
>     Breakpoint 1 set at file `/tmp/zshTH8H8Y', line 1
>     gawk> r
>     Starting program:
>     a
>     Stopping in Rule ...
>     Breakpoint 1, main() at `/tmp/zshTH8H8Y':1
>     1       1
>     gawk> cle
>     Deleted breakpoint 1
>     gawk> b
>     gawk: /tmp/zshTH8H8Y:1: (FILENAME=- FNR=1) fatal error: internal error: 
> segfault
>     [1]    767 abort      ./gawk -D -f =(echo 1)

I'm not familiar with the =(...) syntax. I'm guessing it's the tcsh
equivalent of the ksh/bash <(...) syntax.  Anyway. I was able to reproduce
the crash.

The patch below fixes it, although I'm not sure that it handles the
general case and I should probably do some more work on it.  I will push
this, or something close, shortly.

Thanks,

Arnold

diff --git a/debug.c b/debug.c
index 949ebb4..357ce72 100644
--- a/debug.c
+++ b/debug.c
@@ -2068,12 +2068,18 @@ find_rule(char *src, long lineno)
 {
        INSTRUCTION *rp;
 
-       assert(lineno > 0);
-       for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
-               if ((rp - 1)->source_file == src
-                               && lineno >= (rp + 1)->first_line
-                               && lineno <= (rp + 1)->last_line)
-                       return (rp - 1);
+       if (lineno == 0) {
+               for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
+                       if ((rp - 1)->source_file == src && (rp - 
1)->source_line > 0)
+                               return (rp - 1);
+               }
+       } else {
+               for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) {
+                       if ((rp - 1)->source_file == src
+                                       && lineno >= (rp + 1)->first_line
+                                       && lineno <= (rp + 1)->last_line)
+                               return (rp - 1); +              } }
        return NULL;
 }



reply via email to

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