Git development
 help / color / mirror / Atom feed
From: Tian Yuchen <cat@malon.dev>
To: Jeff King <peff@peff.net>
Cc: Justin Tobler <jltobler@gmail.com>,
	Luca Stefani <luca.stefani.ge1@gmail.com>,
	git@vger.kernel.org
Subject: Re: [BUG] git diff --no-index segfaults on large files (NULL object database)
Date: Sun, 5 Apr 2026 10:48:16 +0800	[thread overview]
Message-ID: <7841c013-1f6e-49e3-9f47-f25044764a11@malon.dev> (raw)
In-Reply-To: <20260404230939.GA1360412@coredump.intra.peff.net>

On 4/5/26 07:09, Jeff King wrote:

> Alternatively, should the odb transaction system be more forgiving here,
> and act as a noop when there is no odb?
> 
> Bisecting the segfault yields ce1661f9da (odb: add transaction
> interface, 2025-09-16). Before then, we passed around the
> object_database itself, saw that its transaction field was NULL, and
> returned immediately. After that commit, we pass the object_databse to
> odb_transaction_begin(), which narrows it to odb->sources (which is
> NULL) while passing to object_file_transaction_begin(). And then that
> function looks at source->odb to go back to the object_database! But
> the source being NULL, it segfaults.
> 
> Immediately after that commit, the switch from taking an odb to a source
> is not helpful, though I think eventually it is used to set
> transaction->base.source. But should the whole thing check for a NULL
> source and return early? Or otherwise establish some kind of noop
> transaction?
> 

In a nutshell, are you suggesting that odb_transaction_begin() should 
return silently when source is NULL?

I understand and agree with your intention, but in practical terms, if 
the odb has not been initialised correctly, data will be lost silently 
here and the caller will not receive an error message. I’m concerned 
that doing this might lead to more bugs in certain situations

Would it make more sense to treat this as a bug instead, e.g. by
triggering a BUG() when source is NULL?

> I haven't thought about the implications (nor even really looked at odb
> transaction code before). But doing it that way would fix not only this
> bug, but also other potential bugs throughout the code base when callers
> start a noop transaction.
> 
> +cc Justin (author of ce1661f9da) for any thoughts.
> 
> -Peff

Thanks! Yuchen

  reply	other threads:[~2026-04-05  2:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-04 10:39 [BUG] git diff --no-index segfaults on large files (NULL object database) Luca Stefani
2026-04-04 16:45 ` Tian Yuchen
2026-04-04 16:53   ` Luca Stefani
2026-04-04 17:07     ` Tian Yuchen
2026-04-04 23:09       ` Jeff King
2026-04-05  2:48         ` Tian Yuchen [this message]
2026-04-05  6:14           ` Jeff King
2026-04-06 17:57         ` Justin Tobler
2026-04-06 20:45           ` 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=7841c013-1f6e-49e3-9f47-f25044764a11@malon.dev \
    --to=cat@malon.dev \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=luca.stefani.ge1@gmail.com \
    --cc=peff@peff.net \
    /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