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

Re: Bug in 2.48 with `git refs migrate`

From
Karthik Nayak <karthik.188@gmail.com>
Date
Jan 16, 2025, 07:29 UTC
Message-ID
<CAOLa=ZS2ZQRSbirW1HLYJ1d1HAwmfugKdNGBCNGtS-yS1rcKEA@mail.gmail.com>
In-Reply-To
<Z4hpXwtv-ChwAGeG@tapette.crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
Show 38 quoted lines
> On 2025-01-15 at 11:54:51, Karthik Nayak wrote:
>> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
>>
>> I'm attaching a patch below which should fixes the issue for me and also
>> adding a test to test against the same. I'd be grateful if you could
>> also test the patch against the repositoryies you mention.
>
> Fantastic, I'll try to do that tomorrow and get back to you.  I really
> appreciate such a prompt response.
>
>> diff --git a/refs/refs-internal.h b/refs/refs-internal.h
>> index 16550862d3..aaab711bb9 100644
>> --- a/refs/refs-internal.h
>> +++ b/refs/refs-internal.h
>> @@ -203,6 +203,7 @@ struct ref_transaction {
>>  	enum ref_transaction_state state;
>>  	void *backend_data;
>>  	unsigned int flags;
>> +	unsigned int max_index;
>>  };
>>
>>  /*
>> diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
>> index 00d95a9a2f..289496058e 100644
>> --- a/refs/reftable-backend.c
>> +++ b/refs/reftable-backend.c
>> @@ -942,6 +942,7 @@ struct write_transaction_table_arg {
>>  	size_t updates_nr;
>>  	size_t updates_alloc;
>>  	size_t updates_expected;
>> +	unsigned int max_index;
>
> I wonder if this and the above should be `uint64_t` instead of `unsigned
> int`.  From the file names and the data format, it looks like we
> intentionally use a 64-bit integer.  That's good, because I have
> unfortunately seen some people who have created giant test repositories
> with really unreasonable numbers of commits and I could see us possibly
> exceeding a 32-bit integer here.

Ideally it should be okay, since this only comes into play when we're migrating reflogs. So the index would be the number of reflog entries for a given ref. I suppose even for large repositories this number should be low. But I'd rather be safe here, so let me modify this in the next version to be 'uint64_t'.

> --
> brian m. carlson (they/them or he/him)
> Toronto, Ontario, CA
Previous: brian m. carlsonNext: brian m. carlson
Message 7 of 21 in “Bug in 2.48 with `git refs migrate`”
  1. brian m. carlsonJan 13, 2025
  2. Patrick SteinhardtJan 13, 2025
  3. Karthik NayakJan 15, 2025
  4. Junio C HamanoJan 15, 2025
  5. Karthik NayakJan 16, 2025
  6. brian m. carlsonJan 16, 2025
  7. Karthik NayakJan 16, 2025
  8. brian m. carlsonJan 16, 2025
  9. Junio C HamanoJan 17, 2025
  10. Karthik NayakJan 17, 2025
  11. Karthik NayakJan 17, 2025
  12. reftable: write correct max_update_index to headerKarthik Nayak, Jan 23, 2025
  13. Junio C HamanoJan 23, 2025
  14. Junio C HamanoJan 23, 2025
  15. refs: fix uninitialized memory access of `max_index`Karthik Nayak, Jan 24, 2025
  16. Patrick SteinhardtJan 24, 2025
  17. Karthik NayakJan 24, 2025
  18. Patrick SteinhardtJan 27, 2025
  19. Junio C HamanoJan 27, 2025
  20. Karthik NayakJan 24, 2025
  21. Junio C HamanoJan 24, 2025

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.