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

Re: t9210-scalar.sh fails with SANITIZE=undefined

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 22, 2022, 22:56 UTC
Message-ID
<xmqq7d1vxbl6.fsf@gitster.g>
In-Reply-To
<YyzhR8CGu2CNQMfJ@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> I also wondered why other versions do not have a similar problem. After
> all, cache entries contain pathnames which are going to be of varying
> lengths. But this seems telling:
>
>   $ git grep -m1 -B1 -A2 align_padding_size
>   read-cache.c-/* These are only used for v3 or lower */
>   read-cache.c:#define align_padding_size(size, len) ((size + (len) + 8) & ~7) - (size + len)
>   read-cache.c-#define align_flex_name(STRUCT,len) ((offsetof(struct STRUCT,data) + (len) + 8) & ~7)
>   read-cache.c-#define ondisk_cache_entry_size(len) align_flex_name(ondisk_cache_entry,len)
>
> So we actually pad the entries in earlier versions to align them, but
> don't in v4. I'm not sure if that was a conscious choice to save space,
> or an unintended consequence (though it is mentioned in the docs, I
> think that came after the code).

I think we didn't even have on-disk vs in-core distinction in the early index code. The active_cache[] array used to be an array of pointers into the (read-only) mmapped memory, peeking into on-disk index we just "read". Back when v4 was introduced, that arrangement was (thought to be) long gone---we iterated over the mmapped memory and used create_from_disk() to munge the on-disk representation into a machine native form. At that point, there was no point in having the padding---we are supposed to be using get_beXX() and stuff without having to worry about alignment requirements.

Previous: Jeff King
Message 6 of 6 in “t9210-scalar.sh fails with SANITIZE=undefined”
  1. Jeff KingSep 22, 2022
  2. Derrick StoleeSep 22, 2022
  3. Jeff KingSep 22, 2022
  4. Victoria DyeSep 22, 2022
  5. Jeff KingSep 22, 2022
  6. Junio C HamanoSep 22, 2022

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.