Skip to content

Fix race in git-bundle(1) by removing unneeded code

Earlier I reported1 a race condition bug could occur if a ref is updated while a git-bundle(1) creation process is running. I've demonstrated it's possible to reproduce this by using a debugger.

To reproduce, I've been running git-bundle(1) with create my.bndl --all --ignore-missing in a debugger. I've set a breakpoint at bundle.c:5151 where setup_revisions() is called. After stepping over this line I see in the debugger revs.pending is populated.

(gdb) p *revs.pending.objects
$6 = {item = 0x7a2fb0, name = 0x78d7e0 "refs/heads/master", path = 0x0, mode = 12288}
(gdb) p *revs.pending.objects.item
$7 = {parsed = 1, type = 1, flags = 0, oid = {hash = "R\026\370\365\304\b\236\302\234\344\232\372\024t4\302>\017\001c\000\000\000\000sS\344\367\377\177\000", algo = 1}}

The hash value is the binary representation of 5216f8f5c4089ec29ce49afa147434c23e0f0163, the current HEAD of master. At this point I've updated master in another terminal window:

git commit --allow-empty -m"dummy"

Then in the debugger I continue the process to create the bundle. The resulting bundle seems to be missing refs/heads/master.

I started digging into this bug again. And I've discovered the changes made by c06793a4 (allow git-bundle to create bottomless bundle, 2007-08-08) cause some trouble. Those changes look up the refs for a second time, and if they mismatch, they might not get written to the bundle output file.

It seems the workaround is not needed anymore since 895c5ba3 (revision: do not peel tags used in range notation, 2013-09-19) and thus I'm removing it while adding some tests. Unfortunately, I was not able to implement a test that hits the race condition bug.

Signed-off-by: Toon Claes toon@iotcl.com

--- b4-submit-tracking ---

This section is used internally by b4 prep for tracking purposes.

{ "series": { "revision": 1, "change-id": "20241204-fix-bundle-create-race-d0bdca1bf999", "prefixes": [] } }

Edited by Toon Claes

Merge request reports

Loading