zsh-workers
 help / color / mirror / code / Atom feed
* "Overlarge EPROG nref" with functions -c
@ 2021-09-22  7:02 Mikael Magnusson
  2021-09-22 14:26 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2021-09-22  7:02 UTC (permalink / raw)
  To: zsh-workers

Someone in IRC was defining thousands of functions with brace
expansions, and I thought perhaps they could save some memory by using
functions -c instead, and came across the following:

% orig() {}
% for i in {1..2000}; do functions -c orig copy_$i; done
% for i in {1..2000}; do functions -c orig copy_$i; done
 parse.c:2816: Overlarge EPROG nref
[message repeats many times]

I'm assuming this is indicative of something bad, but I didn't look
into it, hoping that perhaps someone else knows more.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Overlarge EPROG nref" with functions -c
  2021-09-22  7:02 "Overlarge EPROG nref" with functions -c Mikael Magnusson
@ 2021-09-22 14:26 ` Bart Schaefer
  2021-09-22 15:01   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2021-09-22 14:26 UTC (permalink / raw)
  To: Mikael Magnusson; +Cc: Zsh hackers list

On Wed, Sep 22, 2021 at 12:03 AM Mikael Magnusson <mikachu@gmail.com> wrote:
>
>  parse.c:2816: Overlarge EPROG nref

This means that the number of references to the function exceeds
MAX_FUNCTION_DEPTH.  I presume it checks this because most of the time
these references come from recursive calls to the function.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Overlarge EPROG nref" with functions -c
  2021-09-22 14:26 ` Bart Schaefer
@ 2021-09-22 15:01   ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2021-09-22 15:01 UTC (permalink / raw)
  To: Zsh hackers list

> On 22 September 2021 at 15:26 Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Wed, Sep 22, 2021 at 12:03 AM Mikael Magnusson <mikachu@gmail.com> wrote:
> >
> >  parse.c:2816: Overlarge EPROG nref
> 
> This means that the number of references to the function exceeds
> MAX_FUNCTION_DEPTH.  I presume it checks this because most of the time
> these references come from recursive calls to the function.

Yes, agreed.

The path of least resistance is probably just to remove this debug warning,
which has no further effect and which I don't think we've ever seen in anger.
"functions -c" is supposed to be transparently using the existing reference
mechanism, so adding code for this specific case looks to me more likely to
introduce bugs than help track down bugs we've never seen down.

Unless anyone has smart suggestions...

pws

diff --git a/Src/parse.c b/Src/parse.c
index 10d193ba1..d612b7e17 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -2811,10 +2811,6 @@ freeeprog(Eprog p)
        DPUTS(p->nref > 0 && (p->flags & EF_HEAP), "Heap EPROG has nref > 0");
        DPUTS(p->nref < 0 && !(p->flags & EF_HEAP), "Real EPROG has nref < 0");
        DPUTS(p->nref < -1, "Uninitialised EPROG nref");
-#ifdef MAX_FUNCTION_DEPTH
-       DPUTS(zsh_funcnest >=0 && p->nref > zsh_funcnest + 10,
-             "Overlarge EPROG nref");
-#endif
        if (p->nref > 0 && !--p->nref) {
            for (i = p->npats, pp = p->pats; i--; pp++)
                freepatprog(*pp);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-22 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  7:02 "Overlarge EPROG nref" with functions -c Mikael Magnusson
2021-09-22 14:26 ` Bart Schaefer
2021-09-22 15:01   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).