bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Increased RAM memory usage in gawk 5.0.1 compared to gawk


From: arnold
Subject: Re: [bug-gawk] Increased RAM memory usage in gawk 5.0.1 compared to gawk 4.1.4
Date: Thu, 29 Aug 2019 01:15:40 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi Andy.

THANK YOU for the analysis and detective work.  Pretty amzaing.

> OK. On 3rd thought, I think the attached patch fixes the problem and
> is safer than the 1st version. I think this one is a winner.

There are some cases I'd like to test for that patch. I hope I
can find some time.

It seems that my response on this thread didn't make it out to the
list, so I'll regenerate it.

I used "git bisect" to find the guilty commit. It tells me:

| f8424b236fabb881cc977b9e8e2e7c8debf56da0 is the first bad commit
| commit f8424b236fabb881cc977b9e8e2e7c8debf56da0
| Author: Andrew J. Schorr <address@hidden>
| Date:   Wed Jul 6 18:11:10 2016 -0400
| 
|     Now that all fields are NUL-terminated, we can eliminate $n copying in 
the interpreter.
| 
| :100644 100644 2699ef0cbd7943d822a7915120f4dd8a21558a86 
1eb2fa0a1f1decdafda3256e2ee77bf9393e7ac0 M    ChangeLog
| :100644 100644 bbddd5a7315e6d92b2153cc9838d45af44de8413 
106367f72efaf9cc6232f22c60d1a19ab9951fea M    interpret.h

Below is a patch that reverts this change. For me it fixes the issue
on master.

Andy - how does this jive with the analysis you did? It looks to me
like the original code, which this goes back to, made a new copy of
the field, that was used for the regex match, and that is what was
freed by the code as it stands now.

It'd be nice to be sure we've fixed this in a fundamental way.

Thanks,

Arnold
-------------------------------------------
diff --git a/interpret.h b/interpret.h
index 3215833..0e91e69 100644
--- a/interpret.h
+++ b/interpret.h
@@ -376,8 +376,12 @@ uninitialized_scalar:
                        lhs = r_get_field(t1, (Func_ptr *) 0, true);
                        decr_sp();
                        DEREF(t1);
-                       r = *lhs;
-                       UPREF(r);
+                       /* only for $0, up ref count */
+                       if (*lhs == fields_arr[0]) {
+                               r = *lhs;
+                               UPREF(r);
+                       } else
+                               r = dupnode(*lhs);
                        PUSH(r);
                        break;
 



reply via email to

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