Skip to content

Commit 61eea52

Browse files
committed
fsmonitor: do not compare bitmap size with size of split index
3444ec2 ("fsmonitor: don't fill bitmap with entries to be removed", 2019-10-11) added a handful of sanity checks that make sure that a bit position in fsmonitor bitmap does not go beyond the end of the index. As each bit in the bitmap corresponds to a path in the index, this is the right check most of the time. Except for the case when we are in the split-index mode and looking at a delta index that is to be overlayed on the base index but before the base index has actually been merged in, namely in read_ and write_fsmonitor_extension(). In these codepaths, the entries in the split/delta index is typically a small subset of the entire set of paths (otherwise why would we be using split-index?), so the bitmap used by the fsmonitor is almost always larger than the number of entries in the partial index, and the incorrect comparison would trigger the BUG(). Reported-by: Utsav Shah <[email protected]> Helped-by: Kevin Willford <[email protected]> Helped-by: William Baker <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 460782b commit 61eea52

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
@@ -55,7 +55,8 @@ int read_fsmonitor_extension(struct index_state *istate, const void *data,
5555
}
5656
istate->fsmonitor_dirty = fsmonitor_dirty;
5757

58-
if (istate->fsmonitor_dirty->bit_size > istate->cache_nr)
58+
if (!istate->split_index &&
59+
istate->fsmonitor_dirty->bit_size > istate->cache_nr)
5960
BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)",
6061
(uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr);
6162

@@ -83,7 +84,8 @@ void write_fsmonitor_extension(struct strbuf *sb, struct index_state *istate)
8384
uint32_t ewah_size = 0;
8485
int fixup = 0;
8586

86-
if (istate->fsmonitor_dirty->bit_size > istate->cache_nr)
87+
if (!istate->split_index &&
88+
istate->fsmonitor_dirty->bit_size > istate->cache_nr)
8789
BUG("fsmonitor_dirty has more entries than the index (%"PRIuMAX" > %u)",
8890
(uintmax_t)istate->fsmonitor_dirty->bit_size, istate->cache_nr);
8991

0 commit comments

Comments
 (0)