Subject: Re: bug#5847: [Hubert Gosselmeyer] Re: bug#5847: ETAGS: Segmentation fault, because of incorrect scope presumption

From: Eli Zaretskii <[email-masked]>
Date: Wed, 31 Aug 2016 18:59:20 +0300

> Date: Sat, 20 Aug 2016 19:27:21 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked], Hubert Gosselmeyer <[email-masked]>
> 
> > Date: Sat, 20 Aug 2016 18:55:36 +0300
> > From: Eli Zaretskii <[email-masked]>
> > Cc: [email-masked]
> > 
> > That file blows up the runtime stack because of recursive calls to
> > put_entries when etags writes out the tree of nodes it collected.
> > Since recovery from stack overflow is inherently OS dependent and
> > unreliable, I don't see what we can do in this case.  Even if we do
> > detect the upcoming stack overflow, the only thing we can do is print
> > an error message and quit.
> 
> Actually, one way of avoiding stack overflow would be to use some BFS
> algorithm that allocates memory off the heap.  Patches welcome.

I've done that now and committed the changes on the master branch.
The resulting etags successfully tagged a dozen of large source trees
together, whereas the original version crashed quite quickly.  The
test file posted here also no longer causes a crash.

The non-recursive version is somewhat slower, so patches to speed it
up are welcome.

I'm closing this bug.