git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: segfault during git-prune

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Jul 2, 2007, 11:45 UTC
Message-ID
<alpine.LFD.0.98.0707020441460.3323@woody.linux-foundation.org>
In-Reply-To
<200707021100.16610.andyparkins@gmail.com>
On Mon, 2 Jul 2007, Andy Parkins wrote:
Show 6 quoted lines
> 
> Looking at your patch: is it possible that S_ISDIR() is true for gitlinks as 
> well as S_ISGITLINK()?  S_ISDIR() is from unistd.h; and is presumably 
> something like:
>  
>  S_ISDIR() { return mode & S_IFDIR; }

No, it's going to be something like "(mode & S_IFMASK) == S_IFDIR", so that part should be ok.

BUT:
Show 6 quoted lines
> Given the hints you gave me in your previous reply, I've looked at the 
> backtrace again and understood more what's happening.
> 
>  - mark_reachable_objects() calls add_cache_refs()
>  - which uses lookup_blob() to mark every hash in the index as an OBJ_BLOB 
>    type of hash; including the GITLINK entries.
Yes, this sounds like the real issue (or the remaining issue, at least).
> I think the fault is in add_cache_refs() which assumes that every hash in the 
> index is an OBJ_BLOB.  I think that add_cache_refs() shouldn't be calling 
> lookup_blob() for S_ISGITLINK() index entries.  Therefore I think this patch 
> is the right one; what do you reckon?
Looks good to me.
Show 9 quoted lines
> +       /*
> +        * The index can contain blobs and GITLINKs, GITLINKs are hashes
> +        * that don't actually point to objects in the repository, it's
> +        * almost guaranteed that they are NOT blobs, so we don't call
> +        * lookup_blob() on them, to avoid populating the hash table
> +        * with invalid information
> +        */
> +       if (S_ISGITLINK(ntohl(active_cache[i]->ce_mode)))
> +           continue;

Just for clarity, I'd use "process_gitlink()" here (and it would probably be a good idea to use process_blob() on the blob we look up too), and the proper tab indentation, but yes, I think you're otherwise exactly right.

		Linus
Previous: Andy ParkinsNext: Andy Parkins
Message 9 of 11 in “Bug: segfault during git-prune”
  1. Andy ParkinsJun 28, 2007
  2. Andy ParkinsJun 28, 2007
  3. Linus TorvaldsJun 28, 2007
  4. Linus TorvaldsJun 28, 2007
  5. Andy ParkinsJun 28, 2007
  6. Linus TorvaldsJun 28, 2007
  7. Andy ParkinsJun 29, 2007
  8. Andy ParkinsJul 2, 2007
  9. Linus TorvaldsJul 2, 2007
  10. Andy ParkinsJul 2, 2007
  11. Linus TorvaldsJul 2, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.