Subject: Re: bug report - BUG: builtin/pack-objects.c:4310: should_include_obj should only be called on existing objects

From: Sam Estep <[email-masked]>
Date: Fri, 17 Oct 2025 11:57:54 -0400

I hit this same bug today: https://github.com/samestep/npc/issues/6

I'm using Git v2.51.0. As Nik mentioned, the issue is flaky, but I have
been able to reproduce it several times today on both x86_64-linux and
aarch64-darwin via these steps:

$ git clone --mirror --filter=tree:0 https://github.com/NixOS/nixpkgs.git
Cloning into bare repository 'nixpkgs.git'...
remote: Enumerating objects: 1403208, done.
remote: Counting objects: 100% (1204/1204), done.
remote: Compressing objects: 100% (1164/1164), done.
remote: Total 1403208 (delta 70), reused 273 (delta 40), pack-reused 1402004 (from 2)
Receiving objects: 100% (1403208/1403208), 550.95 MiB | 19.74 MiB/s, done.
Resolving deltas: 100% (71770/71770), done.
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
$ cd nixpkgs.git
$ git fetch --no-show-forced-updates
>From https://github.com/NixOS/nixpkgs
 - [deleted]                 (none)                 -> gh-readonly-queue/master/pr-452910-91484645881d96272b133ad577cbb314c3af446f
 - [deleted]                 (none)                 -> gh-readonly-queue/master/pr-452916-93e25250a9459a0d62e9156f06d9ab66fa081ebd
 - [deleted]                 (none)                 -> gh-readonly-queue/master/pr-452934-9347aa5ba848ac348dd123e5c6b28a5e69ebebee
 - [deleted]                 (none)                 -> refs/pull/435349/merge
 - [deleted]                 (none)                 -> refs/pull/452910/merge
 - [deleted]                 (none)                 -> refs/pull/452916/merge
 - [deleted]                 (none)                 -> refs/pull/452934/merge
remote: Enumerating objects: 228, done.
remote: Counting objects: 100% (228/228), done.
remote: Compressing objects: 100% (223/223), done.
remote: Total 228 (delta 5), reused 152 (delta 5), pack-reused 0 (from 0)
Receiving objects: 100% (228/228), 123.31 KiB | 17.62 MiB/s, done.
Resolving deltas: 100% (5/5), done.
BUG: builtin/pack-objects.c:4835: should_include_obj should only be called on existing objects
error: pack-objects died of signal 6
fatal: could not finish pack-objects to repack local links
fatal: index-pack failed

If the error doesn't occur immediately, it should eventually occur if
you keep re-running that last command:

$ git fetch --no-show-forced-updates

In case it's relevant, my Git version is built from Nixpkgs commit
82c2e0d6dde50b17ae366d2aa36f224dc19af469, and I have this in my global
Git config:

[fetch]
	all = true
	prune = true

On Mon, Apr 28, 2025 at 12:23 PM Jonathan Tan <[email-masked]> wrote:
> In any case, the fix is probably to change it so that
> should_include_obj() returns 0 if the object is absent.

Does this still seem like the right approach?