Skip to content

test-lib, tree-walk: fix large-file test failures on Git 2.98-rc0 - #173

Closed
ttaylorr-oai wants to merge 3 commits into
codexfrom
tb/codex/serialize-expensive-tests
Closed

ttaylorr-oai wants to merge 3 commits into
codexfrom
tb/codex/serialize-expensive-tests

Conversation

@ttaylorr-oai

@ttaylorr-oai ttaylorr-oai commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

This topic fixes two failures in the large-file tests ahead of the codex rebuild on upstream Git 2.98-rc0 (566b6997dd). Please approve this review-only PR to admit it to the production plan. The release controller handles integration.

  • Kaartic Sivaraam’s scheduling fix and lock tests come from Git’s seen branch. Cases marked EXPENSIVE take turns across scripts sharing a results directory. Other cases still run in parallel. The 5 GiB filtered hash test in t1007 used 13.8 GiB under LeakSanitizer locally and repeatedly stalled in CI when it overlapped with t1600.
  • Kristofer Karlsson’s tree-walk fix is still under upstream review. It rejects names longer than INT32_MAX before storing their length in an int. This fixes the misleading malformed-tree error in t1600.13–15 introduced by 53d5cfc3b8. No tests are disabled.

The review branch starts at the current production base, eacee88cf8, to keep the diff to these three commits. I verified that applying the topic to 566b6997dd and to the rebuilt production candidate gives the same trees as cherry-picking all three changes directly on the new base. Brett’s Windows patch stays separate.

All 157 cases in t0000, t1007, and t1600 passed locally on Git 2.98-rc0 with all three changes, LeakSanitizer, GIT_TEST_LONG=true, and three parallel jobs. Without the tree-walk change, t1600.13–15 failed.

sivaraam and others added 3 commits December 2, 2026 17:31
Recently, we've acquired quite a few expensive tests in our test suite.
For instance, these commits add several tests that require
multiple gigabytes of memory:

  - 89048b4 (t1600-index: add expensive tests for over-long
    tree paths, 2026-10-16) added tests to t1600

  - 288266c (xdiff: use size_t for merge buffer size computations,
    2026-10-16) added tests to t4300

  - 55c54fd (apply: reject binary patches greater than MAX_APPLY_SIZE,
    2026-03-25) added tests to t4141

We also have the memory hungry 5GB filtered hash-object test in t1007.

When GIT_TEST_LONG is set, "prove --jobs" happily runs several of these
at once. On the 16GB GitLab CI runners this exhausts memory: the
sanitizer jobs have been hanging in t1007 until they hit the job
timeout ever since the new EXPENSIVE tests in t1600 started running
alongside it. Running the two under a 16GB memory cap reproduces it,
with the t1007 git process getting OOM-killed.

GitHub CI runners are no exception and experience the same behaviour.

Take a lock shared by all test scripts around each EXPENSIVE test, so
only one of them runs at a time. Cheap tests in the same scripts keep
running in parallel. Only the expensive ones wait for each other.

The lock is a file in TEST_RESULTS_DIR holding its owner's PID. A
script writes its PID to a file of its own and hard links it into place
with ln(1). Like mkdir(1), that is atomic and fails if the lock exists,
but the lock never exists without its owner recorded in it.

The lock is released after the test and its cleanup finish, and from
the EXIT trap. A lock whose owner is gone was left by a killed script,
and a waiter removes it after re-reading it, so that a lock another
waiter has just taken is left alone. Two waiters clearing the same
stale lock at once may let two expensive tests run together, which is
rare and better than hanging. If the lock cannot be taken although
nobody holds it, e.g. without hard link support or on a read-only or
full disk, the test runs anyway.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
(cherry picked from commit 2db3f30)
The previous commit serializes EXPENSIVE tests with a lock that a
waiter takes over when its holder was killed, and that the EXIT trap
releases when a script dies while holding it.

Add subtests checking that:

  - a lock left by a dead process is taken over, held while the test
    runs, and released afterwards;

  - a lock carrying the script's own PID, which can only be left by a
    dead holder whose PID was reused, is taken over;

  - a script exiting in the middle of an EXPENSIVE test does not leave
    the lock behind.

None of them has to wait, as a stale lock is cleared without polling.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
(cherry picked from commit 156a722)
The EXPENSIVE tests 13-15 in t1600 have been failing in CI on all
64-bit platforms since 53d5cfc (tree-walk: use size_t for the size
of tree buffers, 2026-10-30) was merged:

  -fatal: index entry path is too long (4294967298 bytes)
  +fatal: malformed mode in tree entry

The tests were added in 89048b4 (t1600-index: add expensive tests
for over-long tree paths, 2026-10-16).  They use a tree with a single
entry whose name is 2^32 - 2 bytes long.  decode_tree_entry() stores
that length in the "int" pathlen of struct name_entry, where it wraps
to -2.  update_tree_entry() then uses it to find the next entry, ends
up in the middle of the name, and fails to parse it.

Before 53d5cfc the tree size was truncated to 32 bits as well, so
the walk saw the 2^32 + 26 byte tree as 26 bytes.  That is exactly
what the wrapped entry length consumed, so the walk stopped without an
error and read-cache rejected the path as the tests expect.  Fixing
the tree size exposed the pathlen bug.

Fix this by keeping the name length in a size_t and rejecting names
longer than INT32_MAX.  This is what fits in pathlen on every platform
we support, and using a fixed-width limit means that the same trees
are accepted everywhere.  read-cache already has the same limit for
index entries, and index.maxPathLen cannot be set higher, so such
names could never be used anyway.

Update the tests to expect the new error.  The tests no longer reach
read-cache, but its limit is still covered by the "test-tool
cache-entry" tests.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
(cherry picked from commit 7bfcb21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants