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-5600-gccf84389


From: Arnold Robbins
Subject: [SCM] gawk branch, gawk-5.3-stable, updated. gawk-4.1.0-5600-gccf84389
Date: Thu, 23 Jan 2025 14:46:18 -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  ccf84389db2751f98df7f24a009371315fce66f6 (commit)
      from  e73fd4871a9e365d9dfbab11d2c9ba8d1f9e6ebf (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=ccf84389db2751f98df7f24a009371315fce66f6

commit ccf84389db2751f98df7f24a009371315fce66f6
Author: Arnold D. Robbins <arnold@skeeve.com>
Date:   Thu Jan 23 21:42:41 2025 +0200

    Fix a memory leak related to typed regexes.

diff --git a/ChangeLog b/ChangeLog
index c0638546..951e04de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-23         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * interpret.h (r_interpret): Case Op_store_var; free up
+       typed regex stuff to avoid memory leaks. See memleak2 test.
+       Thanks to Denis Shirokov <cosmogen@gmail.com> for the report
+       and test case.
+
 2025-01-22         Arnold D. Robbins     <arnold@skeeve.com>
 
        * configure.ac: Add hack if GCC to use -O3 instead of -O2.
diff --git a/interpret.h b/interpret.h
index afba82f8..806f6ffc 100644
--- a/interpret.h
+++ b/interpret.h
@@ -784,6 +784,15 @@ mod:
                         */
 
                        lhs = get_lhs(pc->memory, false);
+
+                       if (((*lhs)->flags & REGEX) != 0) {
+                               refree((*lhs)->typed_re->re_reg[0]);
+                               if ((*lhs)->typed_re->re_reg[1] != NULL)
+                                       refree((*lhs)->typed_re->re_reg[1]);
+                               unref((*lhs)->typed_re->re_exp);
+                               freenode((*lhs)->typed_re);
+                       }
+
                        unref(*lhs);
                        r = pc->initval;        /* constant initializer */
                        if (r != NULL) {
diff --git a/pc/ChangeLog b/pc/ChangeLog
index e7898486..437bb55e 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,7 @@
+2025-01-23         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.tst: Regenerated.
+
 2025-01-22         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.tst: Regenerated.
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index b37a36f1..029a5dbb 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -223,7 +223,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 \
+       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
 ARRAYDEBUG_TESTS = arrdbg
@@ -3684,6 +3684,11 @@ indirectbuiltin4:
        @-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: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 typeof4:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/ChangeLog b/test/ChangeLog
index da30c8f9..d7a0b05c 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2025-01-23         Arnold D. Robbins     <arnold@skeeve.com>
+
+       * Makefile.am (EXTRADIST): New test, memleak2.
+       * memleak2.awk, memleak2.ok: New files.
+
 2025-01-22         Arnold D. Robbins     <arnold@skeeve.com>
 
        * Makefile.am (EXTRADIST): New test, indirectbuiltin4.
diff --git a/test/Makefile.am b/test/Makefile.am
index 7480527d..505f7966 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -803,6 +803,8 @@ EXTRA_DIST = \
        membug1.ok \
        memleak.awk \
        memleak.ok \
+       memleak2.awk \
+       memleak2.ok \
        messages.awk \
        minusstr.awk \
        minusstr.ok \
@@ -1607,7 +1609,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 \
+       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
 ARRAYDEBUG_TESTS = arrdbg
diff --git a/test/Makefile.in b/test/Makefile.in
index 31c11880..1c3bc61d 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1067,6 +1067,8 @@ EXTRA_DIST = \
        membug1.ok \
        memleak.awk \
        memleak.ok \
+       memleak2.awk \
+       memleak2.ok \
        messages.awk \
        minusstr.awk \
        minusstr.ok \
@@ -1871,7 +1873,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 \
+       delmessy indirectbuiltin3 indirectbuiltin4 memleak2 \
        typeof4 typeof5 typeof6 typeof7 typeof8 typeof9 unicode1 watchpoint1
 
 ARRAYDEBUG_TESTS = arrdbg
@@ -5510,6 +5512,11 @@ indirectbuiltin4:
        @-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: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 typeof4:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/Maketests b/test/Maketests
index de282763..2322d88f 100644
--- a/test/Maketests
+++ b/test/Maketests
@@ -2362,6 +2362,11 @@ indirectbuiltin4:
        @-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: 
$$? >>_$@
+       @-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+
 typeof4:
        @echo $@
        @-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: 
$$? >>_$@
diff --git a/test/memleak2.awk b/test/memleak2.awk
new file mode 100644
index 00000000..2e50c05b
--- /dev/null
+++ b/test/memleak2.awk
@@ -0,0 +1,18 @@
+BEGIN {
+       #r = ""
+       r = @//
+       test(r)
+       #      while ( 1 ) { }
+}
+
+
+function test(r, q, rp, c, t)
+{
+       #q = 500000
+       q = 50
+       rp = @/ /
+       for (c = 0; c < q; c++) {
+               s = r
+               sub(//, rp, s)
+       }
+}
diff --git a/test/memleak2.ok b/test/memleak2.ok
new file mode 100644
index 00000000..e69de29b

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

Summary of changes:
 ChangeLog                          |  7 +++++++
 interpret.h                        |  9 +++++++++
 pc/ChangeLog                       |  4 ++++
 pc/Makefile.tst                    |  7 ++++++-
 test/ChangeLog                     |  5 +++++
 test/Makefile.am                   |  4 +++-
 test/Makefile.in                   |  9 ++++++++-
 test/Maketests                     |  5 +++++
 test/memleak2.awk                  | 18 ++++++++++++++++++
 test/{arrayprm2.ok => memleak2.ok} |  0
 10 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100644 test/memleak2.awk
 copy test/{arrayprm2.ok => memleak2.ok} (100%)


hooks/post-receive
-- 
gawk



reply via email to

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