Skip to content

Commit a155ee6

Browse files
ptarjangitster
authored andcommitted
fsmonitor: fix split-index bitmap bounds in tweak_fsmonitor()
When GIT_TEST_SPLIT_INDEX=yes is set and the fsmonitor daemon is active, tweak_fsmonitor() can hit a BUG() assertion: BUG: fsmonitor.c:27: fsmonitor_dirty has more entries than the index (2 > 0) The fsmonitor_dirty EWAH bitmap may reference positions from a previous index state. With split-index, cache_nr can be smaller than the bitmap expects because entries have not been merged yet. This is related to the issue that 05f28e4 (scalar: use index.skipHash=true for performance, 2025-06-04) worked around by disabling GIT_TEST_SPLIT_INDEX in t9210, noting "the issue should be resolved in a series focused on the split index." This fixes the fsmonitor bitmap side; the index.skipHash interaction remains. Two places hit this: - tweak_fsmonitor() calls assert_index_minimum() without the !istate->split_index guard that the read path (line 98) and write path (line 128) already have. Add the same guard. - fsmonitor_ewah_callback() unconditionally asserts and then accesses istate->cache[pos], which is out of bounds with split-index. Replace the assertion with a bounds check that silently skips positions beyond cache_nr. Signed-off-by: Paul Tarjan <github@paulisageek.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e93431a commit a155ee6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fsmonitor.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static void fsmonitor_ewah_callback(size_t pos, void *is)
3333
struct index_state *istate = (struct index_state *)is;
3434
struct cache_entry *ce;
3535

36-
assert_index_minimum(istate, pos + 1);
36+
if (pos >= istate->cache_nr)
37+
return;
3738

3839
ce = istate->cache[pos];
3940
ce->ce_flags &= ~CE_FSMONITOR_VALID;
@@ -805,7 +806,8 @@ void tweak_fsmonitor(struct index_state *istate)
805806
}
806807

807808
/* Mark all previously saved entries as dirty */
808-
assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size);
809+
if (!istate->split_index)
810+
assert_index_minimum(istate, istate->fsmonitor_dirty->bit_size);
809811
ewah_each_bit(istate->fsmonitor_dirty, fsmonitor_ewah_callback, istate);
810812

811813
refresh_fsmonitor(istate);

0 commit comments

Comments
 (0)