gawk-diffs
[Top][All Lists]
Advanced

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

[SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5611-g8e00d6f7


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5611-g8e00d6f7
Date: Wed, 5 Feb 2025 14:03:16 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".

The branch, gawk-5.3-stable has been updated
       via  8e00d6f75321b38fbbacbc69a2fca99adc0d31bd (commit)
       via  3fcf4ea97e1875717979dafc8a8bdbf2bb8b50e0 (commit)
       via  516079d0dbbf0cda3c6226c93b7c96bee0c3ab70 (commit)
       via  ca91101068fa3b84006aca5764ce10d3d56e2486 (commit)
      from  05e85466a2db546a65e2514e8a10b1fbf977ff44 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=8e00d6f75321b38fbbacbc69a2fca99adc0d31bd

commit 8e00d6f75321b38fbbacbc69a2fca99adc0d31bd
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Feb 5 20:44:17 2025 +0200

    Fix a memory leak.

diff --git a/ChangeLog b/ChangeLog
index 1383dda1..6e94266e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,8 @@
         the case that the regex is Node_var_new or Node_elem_new.
         Same for the text. Push text onto the stack first, then
         everything else.
+        Also, free the vname for the regex argument if it's a Node_var_new;
+        same for the text argument.
         * eval.c (setup_frame): Handle Node_regex and Node_dynregex.
         * field.c (do_patsplit): Handle the case of the source being
         Node_param_list, and then if Node_var_new or Node_elem_new.
diff --git a/builtin.c b/builtin.c
index 982c158e..53863f0b 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2315,6 +2315,8 @@ call_match(int nargs)
        else if (regex->type == Node_var_new || regex->type == Node_elem_new) {
                if (regex->type == Node_elem_new)
                        elem_new_reset(regex);
+               else if (regex->type == Node_var_new && regex->vname != NULL)
+                       efree(regex->vname);
                memset(regex, 0, sizeof(*regex));
                regex->type = Node_dynregex;
                regex->re_exp = dupnode(Nnull_string);
@@ -2326,6 +2328,8 @@ call_match(int nargs)
        if (text->type == Node_var_new || text->type == Node_elem_new) {
                if (text->type == Node_elem_new)
                        elem_new_reset(text);
+               else if (text->type == Node_var_new && text->vname != NULL)
+                       efree(text->vname);
                text = dupnode(Nnull_string);
        }
 

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=3fcf4ea97e1875717979dafc8a8bdbf2bb8b50e0

commit 3fcf4ea97e1875717979dafc8a8bdbf2bb8b50e0
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Feb 5 15:39:34 2025 +0200

    Add indirectbuiltin5 test.

diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index 2f13281a..eb457fa6 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -224,7 +224,7 @@ GAWK_EXT_TESTS = \
        symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
        symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
        typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
-       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
+       delmessy indirectbuiltin3 indirectbuiltin4 indirectbuiltin5 memleak2 \
        memleak3 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
@@ -3711,6 +3711,11 @@ indirectbuiltin4:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+indirectbuiltin5:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 memleak2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index 77b3d2c6..b76dee49 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2025-02-05         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.am (EXTRADIST): New test, indirectbuiltin5.
+       * indirectbuiltin5.awk, indirectbuiltin5.ok: New files.
+
 2025-02-05         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRADIST): New test, memleak3.
diff --git a/test/Makefile.am b/test/Makefile.am
index 8b1ebeb9..c32e5223 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -643,6 +643,8 @@ EXTRA_DIST = \
        indirectbuiltin3.ok \
        indirectbuiltin4.awk \
        indirectbuiltin4.ok \
+       indirectbuiltin5.awk \
+       indirectbuiltin5.ok \
        indirectcall2.awk \
        indirectcall2.ok \
        indirectcall3.awk \
@@ -1622,7 +1624,7 @@ GAWK_EXT_TESTS = \
        symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
        symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
        typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
-       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
+       delmessy indirectbuiltin3 indirectbuiltin4 indirectbuiltin5 memleak2 \
        memleak3 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
diff --git a/test/Makefile.in b/test/Makefile.in
index 326b35c1..6b38510b 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -907,6 +907,8 @@ EXTRA_DIST = \
        indirectbuiltin3.ok \
        indirectbuiltin4.awk \
        indirectbuiltin4.ok \
+       indirectbuiltin5.awk \
+       indirectbuiltin5.ok \
        indirectcall2.awk \
        indirectcall2.ok \
        indirectcall3.awk \
@@ -1886,7 +1888,7 @@ GAWK_EXT_TESTS = \
        symtab3 symtab4 symtab5 symtab6 symtab7 symtab8 symtab9 symtab10 \
        symtab11 symtab12 timeout typedregex1 typedregex2 typedregex3 \
        typedregex4 typedregex5 typedregex6 typeof1 typeof2 typeof3 \
-       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
+       delmessy indirectbuiltin3 indirectbuiltin4 indirectbuiltin5 memleak2 \
        memleak3 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
@@ -5551,6 +5553,11 @@ indirectbuiltin4:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+indirectbuiltin5:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 memleak2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index 15dd7bbf..6d62fe52 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -2387,6 +2387,11 @@ indirectbuiltin4:
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
        @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
+indirectbuiltin5:
+       @echo $@
+       @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 memleak2:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/indirectbuiltin5.awk b/test/indirectbuiltin5.awk
new file mode 100644
index 00000000..4d7ad1c4
--- /dev/null
+++ b/test/indirectbuiltin5.awk
@@ -0,0 +1,20 @@
+BEGIN {
+       print "test 1"
+       if (1) {
+               f = "awk::match"
+               @f(a, b, c)
+               # error: gawk: ./bug.gwk:7: fatal error: internal error
+       }
+       print "test 2"
+       if (1) {
+               f = "f1"
+               f1_ = "awk::patsplit"   # or split, asort, asorti, index, 
substr ...
+               @f(a, b, c, d)
+               # error: Assertion failed: r->valref > 0, file awk.h, line 1295
+       }
+}
+
+function f1(a, b, c, d)
+{
+       return @f1_(a, b)
+}
diff --git a/test/indirectbuiltin5.ok b/test/indirectbuiltin5.ok
new file mode 100644
index 00000000..0ca98dd3
--- /dev/null
+++ b/test/indirectbuiltin5.ok
@@ -0,0 +1,4 @@
+test 1
+test 2
+gawk: indirectbuiltin5.awk:19: fatal: patsplit: second argument is not an array
+EXIT CODE: 2

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=516079d0dbbf0cda3c6226c93b7c96bee0c3ab70

commit 516079d0dbbf0cda3c6226c93b7c96bee0c3ab70
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Feb 5 15:35:54 2025 +0200

    Update fixes and ChangeLog.

diff --git a/ChangeLog b/ChangeLog
index 55efff0f..1383dda1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-02-05         Arnold D. Robbins     <arnold@skeeve.com>
+
+       Bug fixes for indirect calls of match and patsplit.
+       Thanks to Denis Shirokov <cosmogen@gmail.com> for the report
+       and test case.
+
+        * builtin.c (call_match): Pop the text of the stack. Handle
+        the case that the regex is Node_var_new or Node_elem_new.
+        Same for the text. Push text onto the stack first, then
+        everything else.
+        * eval.c (setup_frame): Handle Node_regex and Node_dynregex.
+        * field.c (do_patsplit): Handle the case of the source being
+        Node_param_list, and then if Node_var_new or Node_elem_new.
+
 2025-02-05         Arnold D. Robbins     <arnold@skeeve.com>
 
        * node.c (r_unref): For Node_var_new, free the vname.
diff --git a/builtin.c b/builtin.c
index 069d0ee4..982c158e 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2313,6 +2313,8 @@ call_match(int nargs)
        if ((regex->flags & REGEX) != 0)
                regex = regex->typed_re;
        else if (regex->type == Node_var_new || regex->type == Node_elem_new) {
+               if (regex->type == Node_elem_new)
+                       elem_new_reset(regex);
                memset(regex, 0, sizeof(*regex));
                regex->type = Node_dynregex;
                regex->re_exp = dupnode(Nnull_string);
@@ -2321,8 +2323,11 @@ call_match(int nargs)
                need_free = true;
        }
 
-       if (text->type == Node_var_new || text->type == Node_elem_new)
+       if (text->type == Node_var_new || text->type == Node_elem_new) {
+               if (text->type == Node_elem_new)
+                       elem_new_reset(text);
                text = dupnode(Nnull_string);
+       }
 
        PUSH(text);
        PUSH(regex);
@@ -2363,12 +2368,11 @@ call_split_func(const char *name, int nargs)
                seps = POP();
 
        bool need_free = false;
-       bool use_split = false;
        if (nargs >= 3) {
                regex = POP_STRING();
-               if ((regex->flags & REGEX) != 0) {
+               if ((regex->flags & REGEX) != 0)
                        regex = regex->typed_re;
-               } else {
+               else {
                        regex = make_regnode(Node_regex, regex);
                        need_free = true;
                }
diff --git a/field.c b/field.c
index dae0bca5..2eb02cb1 100644
--- a/field.c
+++ b/field.c
@@ -1250,6 +1250,8 @@ do_patsplit(int nargs)
                if (src->type == Node_array_ref)
                        src = src->orig_array;
                if (src->type == Node_var_new || src->type == Node_elem_new) {
+                       if (src->type == Node_elem_new)
+                               elem_new_reset(src);
                        src->type = Node_var;
                        src->valref = 1;
                        src->var_value = dupnode(Nnull_string);

http://git.sv.gnu.org/cgit/gawk.git/commit/?id=ca91101068fa3b84006aca5764ce10d3d56e2486

commit ca91101068fa3b84006aca5764ce10d3d56e2486
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Wed Jan 15 16:07:05 2025 +0200

    Start on fixes for indirect call weird cases.

diff --git a/builtin.c b/builtin.c
index ee75157b..069d0ee4 100644
--- a/builtin.c
+++ b/builtin.c
@@ -2307,17 +2307,24 @@ call_match(int nargs)
        if (nargs == 3)
                array = POP();
        regex = POP();
-
-       /* Don't need to pop the string just to push it back ... */
+       text = POP();
 
        bool need_free = false;
        if ((regex->flags & REGEX) != 0)
                regex = regex->typed_re;
-       else {
+       else if (regex->type == Node_var_new || regex->type == Node_elem_new) {
+               memset(regex, 0, sizeof(*regex));
+               regex->type = Node_dynregex;
+               regex->re_exp = dupnode(Nnull_string);
+       } else {
                regex = make_regnode(Node_regex, regex);
                need_free = true;
        }
 
+       if (text->type == Node_var_new || text->type == Node_elem_new)
+               text = dupnode(Nnull_string);
+
+       PUSH(text);
        PUSH(regex);
 
        if (array)
@@ -2356,11 +2363,12 @@ call_split_func(const char *name, int nargs)
                seps = POP();
 
        bool need_free = false;
+       bool use_split = false;
        if (nargs >= 3) {
                regex = POP_STRING();
-               if ((regex->flags & REGEX) != 0)
+               if ((regex->flags & REGEX) != 0) {
                        regex = regex->typed_re;
-               else {
+               } else {
                        regex = make_regnode(Node_regex, regex);
                        need_free = true;
                }
diff --git a/eval.c b/eval.c
index cc19d705..abcc0204 100644
--- a/eval.c
+++ b/eval.c
@@ -1347,6 +1347,13 @@ setup_frame(INSTRUCTION *pc)
                        r->var_value = dupnode(Nnull_string);
                        break;
 
+               case Node_regex:
+               case Node_dynregex:
+                       // 1/2025:
+                       // These are weird; they can happen through
+                       // indirect calls to some of the builtins, so
+                       // handle them if we get them by ....
+                       // ... falling through! Yay!
                case Node_val:
                        r->type = Node_var;
                        r->var_value = m;
diff --git a/field.c b/field.c
index ced32066..dae0bca5 100644
--- a/field.c
+++ b/field.c
@@ -1244,7 +1244,17 @@ do_patsplit(int nargs)
        check_symtab_functab(arr, "patsplit",
                        _("%s: cannot use %s as second argument"));
 
-       src = TOP_STRING();
+       src = POP_SCALAR();
+       if (src->type == Node_param_list) {
+               src = GET_PARAM(src->param_cnt);
+               if (src->type == Node_array_ref)
+                       src = src->orig_array;
+               if (src->type == Node_var_new || src->type == Node_elem_new) {
+                       src->type = Node_var;
+                       src->valref = 1;
+                       src->var_value = dupnode(Nnull_string);
+               }
+       }
 
        if ((sep->flags & REGEX) != 0)
                sep = sep->typed_re;
@@ -1272,7 +1282,7 @@ do_patsplit(int nargs)
                /*
                 * Skip the work if first arg is the null string.
                 */
-               tmp =  make_number((AWKNUM) 0);
+               tmp = make_number((AWKNUM) 0);
        } else {
                rp = re_update(sep);
                s = src->stptr;
@@ -1281,7 +1291,6 @@ do_patsplit(int nargs)
                                set_element, arr, sep_arr, false));
        }
 
-       src = POP_SCALAR();     /* really pop off stack */
        DEREF(src);
        return tmp;
 }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 | 16 ++++++++++++++++
 builtin.c                 | 22 +++++++++++++++++++---
 eval.c                    |  7 +++++++
 field.c                   | 17 ++++++++++++++---
 pc/Makefile.tst           |  7 ++++++-
 test/ChangeLog            |  5 +++++
 test/Makefile.am          |  4 +++-
 test/Makefile.in          |  9 ++++++++-
 test/Maketests            |  5 +++++
 test/indirectbuiltin5.awk | 20 ++++++++++++++++++++
 test/indirectbuiltin5.ok  |  4 ++++
 11 files changed, 107 insertions(+), 9 deletions(-)
 create mode 100644 test/indirectbuiltin5.awk
 create mode 100644 test/indirectbuiltin5.ok


hooks/post-receive
-- 
gawk



reply via email to

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