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

Re: Segfault in the attr stack

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 1, 2016, 22:46 UTC
Message-ID
<xmqqh9dcwmrr.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAPc5daXuQAeWvJAciRA_Kzyoxa=atEntGzKhqzjiN+ho6TnQyg@mail.gmail.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
> Gaah, of course.
>
> This is coming from the cache preload codepath, where multiple threads
> try to run ce_path_match().
> It used to be OK because pathspec magic never looked at attributes,
> but now it does, and attribute system is not thread-safe.

The symlink check code has dealt with a similar issue in the past in the codepath. threaded_has_symlink_leading_path() is called with per-thread data structure called "cache", because the leading symbolic link check uses a cache that is shared across different invocations of the check.

We need something similar to duplicate the attribute stack per thread. git_check_attrs() currently uses the singleton instance of attr_stack chain, that is rooted at the file scope global "attr_stack", and no wonder that would be clobbered when multiple threads try to use it. The result of attribute collection is also accumulated in a file scope global, which should probably be moved to the "struct git_attr_check" introduced in the jc/attr topic.

We need to teach the callchain that includes prepare_attr_stack() and bootstrap_attr_stack() to take a pointer to the attr_stack root, give git_check_attr_threaded() that takes such root so that threaded code can use per-thread attr stack, and for non-threaded applications use &the_default_attr just like the file scope global "default_cache" is used in symlinks.c. Then a threaded attribute lookup can maintain its own attr_stack when running more than one instance of lookup.

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 12 in “Segfault in the attr stack”
  1. Stefan BellerJun 1, 2016
  2. Junio C HamanoJun 1, 2016
  3. Stefan BellerJun 1, 2016
  4. Junio C HamanoJun 1, 2016
  5. Stefan BellerJun 1, 2016
  6. Junio C HamanoJun 1, 2016
  7. Junio C HamanoJun 1, 2016
  8. Junio C HamanoJun 2, 2016
  9. Junio C HamanoJun 2, 2016
  10. Stefan BellerJun 2, 2016
  11. Duy NguyenJun 2, 2016
  12. Duy NguyenJun 2, 2016

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.