From: Junio C Hamano <gitster@pobox.com>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Karthik Nayak <karthik.188@gmail.com>,
Anders Kaseorg <andersk@MIT.EDU>
Subject: Re: [PATCH] last-modified: fix bug caused by inproper initialized memory
Date: Fri, 28 Nov 2025 18:01:24 -0800 [thread overview]
Message-ID: <xmqq8qfpioln.fsf@gitster.g> (raw)
In-Reply-To: <20251128-toon-big-endian-ci-v1-1-80da0f629c1e@iotcl.com> (Toon Claes's message of "Fri, 28 Nov 2025 17:37:13 +0100")
Toon Claes <toon@iotcl.com> writes:
> git-last-modified(1) uses a scratch bitmap to keep track of paths that
> have been changed between commits. To avoid reallocating a bitmap on
> each call of process_parent(), the scratch bitmap is kept and reused.
> Although, it seems an incorrect length is passed to memset(3).
>
> `struct bitmap` uses `eword_t` to for internal storage. This type is
> typedef'd to uint64_t. To fully zero the memory used by the bitmap,
> multiply the length (saved in `struct bitmap::word_alloc`) by the size
> of `eword_t`.
>
> Reported-by: Anders Kaseorg <andersk@mit.edu>
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Toon Claes <toon@iotcl.com>
> ---
> It was reported [1] the tests in t8020 fail on s390x. After some
> research, it seems it was related to s390x being big-endian. Well,
> actually, not really. Using big-endian simply uncovered the problem in
> test.
>
> [1]: https://lore.kernel.org/git/4dc4c8cd-c0cc-4784-8fcf-defa3a051087@mit.edu/
> ---
> builtin/last-modified.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
This dates back to v2.52.0~4 and is clearly a maint material.
Thanks for finding and fixing.
>
> diff --git a/builtin/last-modified.c b/builtin/last-modified.c
> index b0ecbdc540..cc5fd2e795 100644
> --- a/builtin/last-modified.c
> +++ b/builtin/last-modified.c
> @@ -327,7 +327,7 @@ static void process_parent(struct last_modified *lm,
> if (!(parent->object.flags & PARENT1))
> active_paths_free(lm, parent);
>
> - memset(lm->scratch->words, 0x0, lm->scratch->word_alloc);
> + memset(lm->scratch->words, 0x0, lm->scratch->word_alloc * sizeof(eword_t));
> diff_queue_clear(&diff_queued_diff);
> }
>
>
> ---
> base-commit: 6ab38b7e9cc7adafc304f3204616a4debd49c6e9
> change-id: 20251126-toon-big-endian-ci-fe62bb361974
next prev parent reply other threads:[~2025-11-29 2:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-28 16:37 [PATCH] last-modified: fix bug caused by inproper initialized memory Toon Claes
2025-11-28 20:55 ` Jeff King
2025-11-28 22:20 ` Anders Kaseorg
2025-11-29 10:50 ` Jeff King
2025-12-08 11:47 ` Toon Claes
2025-12-08 20:15 ` Jeff King
2025-12-08 22:42 ` Junio C Hamano
2025-11-29 2:01 ` Junio C Hamano [this message]
2025-11-29 2:11 ` Junio C Hamano
2025-11-29 9:38 ` Toon Claes
2025-12-08 11:46 ` [PATCH v2] last-modified: fix use of uninitialized memory Toon Claes
2025-12-08 13:26 ` Junio C Hamano
2025-12-09 8:43 ` Toon Claes
2025-12-09 12:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq8qfpioln.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=andersk@MIT.EDU \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=peff@peff.net \
--cc=toon@iotcl.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).