git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Dragos Foianu <dragos.foianu@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] Segfault on git describe
Date: Thu, 20 Mar 2014 19:33:08 -0400	[thread overview]
Message-ID: <20140320233307.GB7774@sigill.intra.peff.net> (raw)
In-Reply-To: <loom.20140319T224201-156@post.gmane.org>

On Wed, Mar 19, 2014 at 10:34:29PM +0000, Dragos Foianu wrote:

> The name_rev function recursively calls itself which is why the backtrace is
> so big. Unfortunately, for repos with long histories it can lead to Stack
> Overflows. This is pretty much what happened in your case.
> 
> I tested it on my computer and I get the same results. I managed to get it
> working by doubling my default stacksize:
> 
> ulimit -S -s 16192
> 
> Considering your project is a very large one and merely allocating a few
> more resources fixes the problem, I'm not sure it warrants rewriting the
> function to use less stack. You will have to wait for one of the maintainers
> to give you a definitive answer.

Thanks for looking into the problem.

As a general rule, I think we are interested in reducing recursion in
functions which can go O(depth of history) or deeper. I'd say that
O(lg(depth of history)) is probably OK.

There is some precedent in 941ba8d (Eliminate recursion in
setting/clearing marks in commit list, 2012-01-14), for example.

Also, in:

  abe601b (sha1_file: remove recursion in unpack_entry, 2013-03-27)

  790d96c (sha1_file: remove recursion in packed_object_info,
  2013-03-25)

  2baad22 (index-pack: eliminate recursion in find_unresolved_deltas,
  2012-01-14)

though I think those recurse in the size of delta chain, which is not
nearly so big.

So I think we'd be happy to see it converted to an iterative process
(probably with a stack on the heap). In addition to name-rev, I believe
that "tag --contains" will recurse down the longest history path, too (I
think there may have been experimental patches for the latter, but you'd
have to search the list archive).

-Peff

  reply	other threads:[~2014-03-20 23:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 10:48 [BUG] Segfault on git describe Sylvestre Ledru
2014-03-19 12:03 ` Sylvestre Ledru
2014-03-19 22:34 ` Dragos Foianu
2014-03-20 23:33   ` Jeff King [this message]
2014-03-22 10:18     ` Dragos Foianu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140320233307.GB7774@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=dragos.foianu@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).