]> git.ipfire.org Git - thirdparty/git.git/commit
Makefile: turn on NO_MMAP when building with ASan
authorJeff King <peff@peff.net>
Tue, 18 Nov 2025 09:12:13 +0000 (04:12 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Nov 2025 17:36:06 +0000 (09:36 -0800)
commita9990f8ec0e750a68802f7d79d2aa2293c4811b4
treeec09ef5af2c266ea964a8f324037e0437bf1fb54
parent4deb882e54152c31bef23f8b33ad38b7bc26d398
Makefile: turn on NO_MMAP when building with ASan

Git often uses mmap() to access on-disk files. This leaves a blind spot
in our SANITIZE=address builds, since ASan does not seem to handle mmap
at all. Nor does the OS notice most out-of-bounds access, since it tends
to round up to the nearest page size (so depending on how big the map
is, you might have to overrun it by up to 4095 bytes to trigger a
segfault).

The previous commit demonstrates a memory bug that we missed. We could
have made a new test where the out-of-bounds access was much larger, or
where the mapped file ended closer to a page boundary. But the point of
running the test suite with sanitizers is to catch these problems
without having to construct specific tests.

Let's enable NO_MMAP for our ASan builds by default, which should give
us better coverage. This does increase the memory usage of Git, since
we're copying from the filesystem into heap. But the repositories in the
test suite tend to be small, so the overhead isn't really noticeable
(and ASan already has quite a performance penalty).

There are a few other known bugs that this patch will help flush out.
However, they aren't directly triggered in the test suite (yet). So
it's safe to turn this on now without breaking the test suite, which
will help us add new tests to demonstrate those other bugs as we fix
them.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
meson.build