diff mbox series

[1/1] package/gawk: fix double free during kernel build

Message ID 20221030215458.3773991-1-james.hilliard1@gmail.com
State Accepted
Headers show
Series [1/1] package/gawk: fix double free during kernel build | expand

Commit Message

James Hilliard Oct. 30, 2022, 9:54 p.m. UTC
Backport an upstream patch to fix a crash during kernel build.

Details: https://bugs.gentoo.org/868567

Fixes:
  GEN     /home/buildroot/buildroot/output/build/linux-6.0.6/tools/objtool/arch/x86/lib/inat-tables.c
free(): double free detected in tcache 2
Aborted

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 .../0002-Fix-a-bug-with-Node_elem_new.patch   | 155 ++++++++++++++++++
 1 file changed, 155 insertions(+)
 create mode 100644 package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch

Comments

Yann E. MORIN Oct. 31, 2022, 7:50 a.m. UTC | #1
James, All,

On 2022-10-30 15:54 -0600, James Hilliard spake thusly:
> Backport an upstream patch to fix a crash during kernel build.
> 
> Details: https://bugs.gentoo.org/868567
> 
> Fixes:
>   GEN     /home/buildroot/buildroot/output/build/linux-6.0.6/tools/objtool/arch/x86/lib/inat-tables.c
> free(): double free detected in tcache 2
> Aborted
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

Applied to master, thanks.

That made me notice some cruft we've been carying for gawk, if you could
have a quick look (patch renumbering missing, I sent it before applying
your patch):
    https://patchwork.ozlabs.org/project/buildroot/patch/20221031072634.2986903-1-yann.morin.1998@free.fr/

Regards,
Yann E. MORIN.

> ---
>  .../0002-Fix-a-bug-with-Node_elem_new.patch   | 155 ++++++++++++++++++
>  1 file changed, 155 insertions(+)
>  create mode 100644 package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch
> 
> diff --git a/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch b/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch
> new file mode 100644
> index 0000000000..502f7dcd95
> --- /dev/null
> +++ b/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch
> @@ -0,0 +1,155 @@
> +From baab183439ff4e0c6b77d62156d447e61fc1dcfb Mon Sep 17 00:00:00 2001
> +From: "Arnold D. Robbins" <arnold@skeeve.com>
> +Date: Wed, 14 Sep 2022 21:08:59 +0300
> +Subject: [PATCH] Fix a bug with Node_elem_new.
> +
> +Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> +[james.hilliard1@gmail.com: backport from upstream commit
> +baab183439ff4e0c6b77d62156d447e61fc1dcfb]
> +---
> + ChangeLog         | 8 ++++++++
> + interpret.h       | 1 +
> + test/ChangeLog    | 5 +++++
> + test/Makefile.am  | 4 +++-
> + test/Makefile.in  | 9 ++++++++-
> + test/Maketests    | 5 +++++
> + test/elemnew1.awk | 9 +++++++++
> + test/elemnew1.ok  | 0
> + 8 files changed, 39 insertions(+), 2 deletions(-)
> + create mode 100644 test/elemnew1.awk
> + create mode 100644 test/elemnew1.ok
> +
> +diff --git a/ChangeLog b/ChangeLog
> +index 5fb25483..cd9d9fcd 100644
> +--- a/ChangeLog
> ++++ b/ChangeLog
> +@@ -1,3 +1,11 @@
> ++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
> ++
> ++	* interpret.h (r_interpret): For the `push' opcodes, upref
> ++	the Node_elem_new. See test case elemnew1. Thanks to
> ++	Emanuel Attila Czirai <corre.a.buscar@gmail.com> for the report,
> ++	and to Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
> ++	for the fix.
> ++	
> + 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
> + 
> + 	* 5.2.0: Release tar ball made.
> +diff --git a/interpret.h b/interpret.h
> +index 57d060e6..268655b2 100644
> +--- a/interpret.h
> ++++ b/interpret.h
> +@@ -238,6 +238,7 @@ uninitialized_scalar:
> + 						_("reference to uninitialized argument `%s'") :
> + 						_("reference to uninitialized variable `%s'"),
> + 								save_symbol->vname);
> ++				UPREF(m);
> + 				PUSH(m);
> + 				break;
> + 
> +diff --git a/test/ChangeLog b/test/ChangeLog
> +index a73637bf..ea08edee 100644
> +--- a/test/ChangeLog
> ++++ b/test/ChangeLog
> +@@ -1,3 +1,8 @@
> ++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
> ++
> ++	* Makefile.am (EXTRA_DIST): New test: elemnew1.
> ++	* elemnew1.awk, elemnew1.ok: New files.
> ++
> + 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
> + 
> + 	* 5.2.0: Release tar ball made.
> +diff --git a/test/Makefile.am b/test/Makefile.am
> +index ab06974c..8a5c3c49 100644
> +--- a/test/Makefile.am
> ++++ b/test/Makefile.am
> +@@ -282,6 +282,8 @@ EXTRA_DIST = \
> + 	dumpvars.ok \
> + 	dynlj.awk \
> + 	dynlj.ok \
> ++	elemnew1.awk \
> ++	elemnew1.ok \
> + 	escapebrace.awk \
> + 	escapebrace.in \
> + 	escapebrace.ok \
> +@@ -1480,7 +1482,7 @@ GAWK_EXT_TESTS = \
> + 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
> + 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
> + 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
> +-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
> ++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
> + 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
> + 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
> + 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
> +diff --git a/test/Makefile.in b/test/Makefile.in
> +index 834feb09..a4fb1cc1 100644
> +--- a/test/Makefile.in
> ++++ b/test/Makefile.in
> +@@ -550,6 +550,8 @@ EXTRA_DIST = \
> + 	dumpvars.ok \
> + 	dynlj.awk \
> + 	dynlj.ok \
> ++	elemnew1.awk \
> ++	elemnew1.ok \
> + 	escapebrace.awk \
> + 	escapebrace.in \
> + 	escapebrace.ok \
> +@@ -1748,7 +1750,7 @@ GAWK_EXT_TESTS = \
> + 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
> + 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
> + 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
> +-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
> ++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
> + 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
> + 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
> + 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
> +@@ -4476,6 +4478,11 @@ dfacheck1:
> + 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> + 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> + 
> ++elemnew1:
> ++	@echo $@
> ++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> ++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> ++
> + exit:
> + 	@echo $@
> + 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> +diff --git a/test/Maketests b/test/Maketests
> +index 3a667af8..90828e7f 100644
> +--- a/test/Maketests
> ++++ b/test/Maketests
> +@@ -1432,6 +1432,11 @@ dfacheck1:
> + 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> + 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> + 
> ++elemnew1:
> ++	@echo $@
> ++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> ++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> ++
> + exit:
> + 	@echo $@
> + 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> +diff --git a/test/elemnew1.awk b/test/elemnew1.awk
> +new file mode 100644
> +index 00000000..58dc9fcd
> +--- /dev/null
> ++++ b/test/elemnew1.awk
> +@@ -0,0 +1,9 @@
> ++function add_flags(old) {
> ++  if (old)
> ++    return 0
> ++  if (!old)
> ++    return 1
> ++}
> ++BEGIN {
> ++  a[0]=add_flags(a[0])
> ++}
> +diff --git a/test/elemnew1.ok b/test/elemnew1.ok
> +new file mode 100644
> +index 00000000..e69de29b
> +-- 
> +2.34.1
> +
> -- 
> 2.34.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Yann E. MORIN Oct. 31, 2022, 2:34 p.m. UTC | #2
James, All,

On 2022-10-30 15:54 -0600, James Hilliard spake thusly:
> Backport an upstream patch to fix a crash during kernel build.
> 
> Details: https://bugs.gentoo.org/868567
> 
> Fixes:
>   GEN     /home/buildroot/buildroot/output/build/linux-6.0.6/tools/objtool/arch/x86/lib/inat-tables.c
> free(): double free detected in tcache 2
> Aborted
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[--SNIP--]
> +---
> + ChangeLog         | 8 ++++++++
> + interpret.h       | 1 +
> + test/ChangeLog    | 5 +++++
> + test/Makefile.am  | 4 +++-
> + test/Makefile.in  | 9 ++++++++-

As noticed by Romain, this triggers hidden autoreconf, which obviously
fails most of the time.

I noticed the issue when applying your patch this morning, but a build
here did not trigger the silent autoreconf, and since Makefile.in is
patched after Makefile.am, it seemed all was going to tbe OK.

It did not:

    http://autobuild.buildroot.org/results/068/0686697cb52d22c42ae2249db3442c008082fe72/
    http://autobuild.buildroot.org/results/754/75463639cb9cbc32108f059bd6044810a078db06/

So I dropped all the hunks about Makfile.am and Makefile .in, as they
are only about tests, which we don't care much about, and while at it
I also dropped the hunks about changelogs, which we really don't care
much about either, and pushed that to master.

Regards,
Yann E. MORIN.

> + test/Maketests    | 5 +++++
> + test/elemnew1.awk | 9 +++++++++
> + test/elemnew1.ok  | 0
> + 8 files changed, 39 insertions(+), 2 deletions(-)
> + create mode 100644 test/elemnew1.awk
> + create mode 100644 test/elemnew1.ok
> +
> +diff --git a/ChangeLog b/ChangeLog
> +index 5fb25483..cd9d9fcd 100644
> +--- a/ChangeLog
> ++++ b/ChangeLog
> +@@ -1,3 +1,11 @@
> ++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
> ++
> ++	* interpret.h (r_interpret): For the `push' opcodes, upref
> ++	the Node_elem_new. See test case elemnew1. Thanks to
> ++	Emanuel Attila Czirai <corre.a.buscar@gmail.com> for the report,
> ++	and to Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
> ++	for the fix.
> ++	
> + 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
> + 
> + 	* 5.2.0: Release tar ball made.
> +diff --git a/interpret.h b/interpret.h
> +index 57d060e6..268655b2 100644
> +--- a/interpret.h
> ++++ b/interpret.h
> +@@ -238,6 +238,7 @@ uninitialized_scalar:
> + 						_("reference to uninitialized argument `%s'") :
> + 						_("reference to uninitialized variable `%s'"),
> + 								save_symbol->vname);
> ++				UPREF(m);
> + 				PUSH(m);
> + 				break;
> + 
> +diff --git a/test/ChangeLog b/test/ChangeLog
> +index a73637bf..ea08edee 100644
> +--- a/test/ChangeLog
> ++++ b/test/ChangeLog
> +@@ -1,3 +1,8 @@
> ++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
> ++
> ++	* Makefile.am (EXTRA_DIST): New test: elemnew1.
> ++	* elemnew1.awk, elemnew1.ok: New files.
> ++
> + 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
> + 
> + 	* 5.2.0: Release tar ball made.
> +diff --git a/test/Makefile.am b/test/Makefile.am
> +index ab06974c..8a5c3c49 100644
> +--- a/test/Makefile.am
> ++++ b/test/Makefile.am
> +@@ -282,6 +282,8 @@ EXTRA_DIST = \
> + 	dumpvars.ok \
> + 	dynlj.awk \
> + 	dynlj.ok \
> ++	elemnew1.awk \
> ++	elemnew1.ok \
> + 	escapebrace.awk \
> + 	escapebrace.in \
> + 	escapebrace.ok \
> +@@ -1480,7 +1482,7 @@ GAWK_EXT_TESTS = \
> + 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
> + 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
> + 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
> +-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
> ++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
> + 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
> + 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
> + 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
> +diff --git a/test/Makefile.in b/test/Makefile.in
> +index 834feb09..a4fb1cc1 100644
> +--- a/test/Makefile.in
> ++++ b/test/Makefile.in
> +@@ -550,6 +550,8 @@ EXTRA_DIST = \
> + 	dumpvars.ok \
> + 	dynlj.awk \
> + 	dynlj.ok \
> ++	elemnew1.awk \
> ++	elemnew1.ok \
> + 	escapebrace.awk \
> + 	escapebrace.in \
> + 	escapebrace.ok \
> +@@ -1748,7 +1750,7 @@ GAWK_EXT_TESTS = \
> + 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
> + 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
> + 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
> +-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
> ++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
> + 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
> + 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
> + 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
> +@@ -4476,6 +4478,11 @@ dfacheck1:
> + 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> + 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> + 
> ++elemnew1:
> ++	@echo $@
> ++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> ++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> ++
> + exit:
> + 	@echo $@
> + 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> +diff --git a/test/Maketests b/test/Maketests
> +index 3a667af8..90828e7f 100644
> +--- a/test/Maketests
> ++++ b/test/Maketests
> +@@ -1432,6 +1432,11 @@ dfacheck1:
> + 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> + 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> + 
> ++elemnew1:
> ++	@echo $@
> ++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> ++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
> ++
> + exit:
> + 	@echo $@
> + 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
> +diff --git a/test/elemnew1.awk b/test/elemnew1.awk
> +new file mode 100644
> +index 00000000..58dc9fcd
> +--- /dev/null
> ++++ b/test/elemnew1.awk
> +@@ -0,0 +1,9 @@
> ++function add_flags(old) {
> ++  if (old)
> ++    return 0
> ++  if (!old)
> ++    return 1
> ++}
> ++BEGIN {
> ++  a[0]=add_flags(a[0])
> ++}
> +diff --git a/test/elemnew1.ok b/test/elemnew1.ok
> +new file mode 100644
> +index 00000000..e69de29b
> +-- 
> +2.34.1
> +
> -- 
> 2.34.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Peter Korsgaard Nov. 13, 2022, 4:10 p.m. UTC | #3
>>>>> "James" == James Hilliard <james.hilliard1@gmail.com> writes:

 > Backport an upstream patch to fix a crash during kernel build.
 > Details: https://bugs.gentoo.org/868567

 > Fixes:
 >   GEN     /home/buildroot/buildroot/output/build/linux-6.0.6/tools/objtool/arch/x86/lib/inat-tables.c
 > free(): double free detected in tcache 2
 > Aborted

 > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>

This presumably only triggers after our recent update to gawk 5.2.0?
James Hilliard Nov. 13, 2022, 4:32 p.m. UTC | #4
On Sun, Nov 13, 2022 at 12:10 PM Peter Korsgaard <peter@korsgaard.com> wrote:
>
> >>>>> "James" == James Hilliard <james.hilliard1@gmail.com> writes:
>
>  > Backport an upstream patch to fix a crash during kernel build.
>  > Details: https://bugs.gentoo.org/868567
>
>  > Fixes:
>  >   GEN     /home/buildroot/buildroot/output/build/linux-6.0.6/tools/objtool/arch/x86/lib/inat-tables.c
>  > free(): double free detected in tcache 2
>  > Aborted
>
>  > Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
>
> This presumably only triggers after our recent update to gawk 5.2.0?

Yeah, seems to be the case.

>
> --
> Bye, Peter Korsgaard
diff mbox series

Patch

diff --git a/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch b/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch
new file mode 100644
index 0000000000..502f7dcd95
--- /dev/null
+++ b/package/gawk/0002-Fix-a-bug-with-Node_elem_new.patch
@@ -0,0 +1,155 @@ 
+From baab183439ff4e0c6b77d62156d447e61fc1dcfb Mon Sep 17 00:00:00 2001
+From: "Arnold D. Robbins" <arnold@skeeve.com>
+Date: Wed, 14 Sep 2022 21:08:59 +0300
+Subject: [PATCH] Fix a bug with Node_elem_new.
+
+Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
+[james.hilliard1@gmail.com: backport from upstream commit
+baab183439ff4e0c6b77d62156d447e61fc1dcfb]
+---
+ ChangeLog         | 8 ++++++++
+ interpret.h       | 1 +
+ test/ChangeLog    | 5 +++++
+ test/Makefile.am  | 4 +++-
+ test/Makefile.in  | 9 ++++++++-
+ test/Maketests    | 5 +++++
+ test/elemnew1.awk | 9 +++++++++
+ test/elemnew1.ok  | 0
+ 8 files changed, 39 insertions(+), 2 deletions(-)
+ create mode 100644 test/elemnew1.awk
+ create mode 100644 test/elemnew1.ok
+
+diff --git a/ChangeLog b/ChangeLog
+index 5fb25483..cd9d9fcd 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,11 @@
++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
++
++	* interpret.h (r_interpret): For the `push' opcodes, upref
++	the Node_elem_new. See test case elemnew1. Thanks to
++	Emanuel Attila Czirai <corre.a.buscar@gmail.com> for the report,
++	and to Jan Alexander Steffens (heftig)" <heftig@archlinux.org>
++	for the fix.
++	
+ 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
+ 
+ 	* 5.2.0: Release tar ball made.
+diff --git a/interpret.h b/interpret.h
+index 57d060e6..268655b2 100644
+--- a/interpret.h
++++ b/interpret.h
+@@ -238,6 +238,7 @@ uninitialized_scalar:
+ 						_("reference to uninitialized argument `%s'") :
+ 						_("reference to uninitialized variable `%s'"),
+ 								save_symbol->vname);
++				UPREF(m);
+ 				PUSH(m);
+ 				break;
+ 
+diff --git a/test/ChangeLog b/test/ChangeLog
+index a73637bf..ea08edee 100644
+--- a/test/ChangeLog
++++ b/test/ChangeLog
+@@ -1,3 +1,8 @@
++2022-09-14         Arnold D. Robbins     <arnold@skeeve.com>
++
++	* Makefile.am (EXTRA_DIST): New test: elemnew1.
++	* elemnew1.awk, elemnew1.ok: New files.
++
+ 2022-09-04         Arnold D. Robbins     <arnold@skeeve.com>
+ 
+ 	* 5.2.0: Release tar ball made.
+diff --git a/test/Makefile.am b/test/Makefile.am
+index ab06974c..8a5c3c49 100644
+--- a/test/Makefile.am
++++ b/test/Makefile.am
+@@ -282,6 +282,8 @@ EXTRA_DIST = \
+ 	dumpvars.ok \
+ 	dynlj.awk \
+ 	dynlj.ok \
++	elemnew1.awk \
++	elemnew1.ok \
+ 	escapebrace.awk \
+ 	escapebrace.in \
+ 	escapebrace.ok \
+@@ -1480,7 +1482,7 @@ GAWK_EXT_TESTS = \
+ 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
+ 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
+ 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
+-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
+ 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
+ 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
+ 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
+diff --git a/test/Makefile.in b/test/Makefile.in
+index 834feb09..a4fb1cc1 100644
+--- a/test/Makefile.in
++++ b/test/Makefile.in
+@@ -550,6 +550,8 @@ EXTRA_DIST = \
+ 	dumpvars.ok \
+ 	dynlj.awk \
+ 	dynlj.ok \
++	elemnew1.awk \
++	elemnew1.ok \
+ 	escapebrace.awk \
+ 	escapebrace.in \
+ 	escapebrace.ok \
+@@ -1748,7 +1750,7 @@ GAWK_EXT_TESTS = \
+ 	binmode1 charasbytes clos1way clos1way2 clos1way3 clos1way4 \
+ 	clos1way5 clos1way6 colonwarn commas crlf dbugeval dbugeval2 \
+ 	dbugeval3 dbugtypedre1 dbugtypedre2 delsub devfd devfd1 devfd2 \
+-	dfacheck1 dumpvars errno exit fieldwdth forcenum fpat1 fpat2 \
++	dfacheck1 dumpvars elemnew1 errno exit fieldwdth forcenum fpat1 fpat2 \
+ 	fpat3 fpat4 fpat5 fpat6 fpat7 fpat8 fpat9 fpatnull fsfwfs functab1 \
+ 	functab2 functab3 functab6 funlen fwtest fwtest2 fwtest3 fwtest4 \
+ 	fwtest5 fwtest6 fwtest7 fwtest8 genpot gensub gensub2 gensub3 \
+@@ -4476,6 +4478,11 @@ dfacheck1:
+ 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+ 
++elemnew1:
++	@echo $@
++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
++
+ exit:
+ 	@echo $@
+ 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+diff --git a/test/Maketests b/test/Maketests
+index 3a667af8..90828e7f 100644
+--- a/test/Maketests
++++ b/test/Maketests
+@@ -1432,6 +1432,11 @@ dfacheck1:
+ 	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  < "$(srcdir)"/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+ 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
+ 
++elemnew1:
++	@echo $@
++	@-AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
++	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
++
+ exit:
+ 	@echo $@
+ 	@-$(LOCALES) AWK="$(AWKPROG)" "$(srcdir)"/$@.sh  > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@
+diff --git a/test/elemnew1.awk b/test/elemnew1.awk
+new file mode 100644
+index 00000000..58dc9fcd
+--- /dev/null
++++ b/test/elemnew1.awk
+@@ -0,0 +1,9 @@
++function add_flags(old) {
++  if (old)
++    return 0
++  if (!old)
++    return 1
++}
++BEGIN {
++  a[0]=add_flags(a[0])
++}
+diff --git a/test/elemnew1.ok b/test/elemnew1.ok
+new file mode 100644
+index 00000000..e69de29b
+-- 
+2.34.1
+