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: Andrew J. Schorr
Subject: Re: [bug-gawk] Increased RAM memory usage in gawk 5.0.1 compared to gawk 4.1.4
Date: Wed, 28 Aug 2019 18:46:27 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Aug 28, 2019 at 05:01:00PM -0400, Andrew J. Schorr wrote:
> On Wed, Aug 28, 2019 at 04:08:00PM -0400, Andrew J. Schorr wrote:
> Ah, OK, I see that m->re_exp was getting DEREF'ed under Op_match on a delayed
> basis, but that doesn't work when the dynamic regexp was in a field variable.
> The attached patch seems to fix Finn's problem and passes "make check"
> and "make valgrind-noleak". But I'm still not 100% confident that it's
> right. Arnold -- can you please review this?  My understanding of
> the Node_dynregex mechanism is not great, and it makes me a bit nervous
> to set m->re_exp without first DEREF'ing its contents. But it seems
> to work.
...

> diff --git a/interpret.h b/interpret.h
> index 3215833..0293436 100644
> --- a/interpret.h
> +++ b/interpret.h
> @@ -1065,6 +1065,8 @@ match_re:
>                       if (op != Op_match_rec) {
>                               decr_sp();
>                               DEREF(t1);
> +                             if (m->type == Node_dynregex)
> +                                     DEREF(m->re_exp);
>                       }
>                       r = node_Boolean[di];
>                       UPREF(r);
> @@ -1077,7 +1079,6 @@ match_re:
>                       m = pc->memory;
>                       t1 = TOP_STRING();
>                       if (m->type == Node_dynregex) {
> -                             unref(m->re_exp);
>                               m->re_exp = t1;
>                               decr_sp();
>                               t1 = TOP_STRING();

In particular, this code in Op_push_re is worrisome:

                case Op_push_re:
                        m = pc->memory;
                        if (m->type == Node_dynregex) {
                                r = POP_STRING();
                                unref(m->re_exp);
                                m->re_exp = r;

So that follows the pattern of calling unref before assigning.
This may be the only other place that assigns to m->re_exp.
Perhaps re_exp is always NULL at this point. Actually, that's not
true -- I inserted a printf, and there are many cases in "make check"
where re_exp is non-NULL there.

So I am concerned...

Regards,
Andy



reply via email to

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