Re: [RFC PATCH 00/10] range-diff: fix segfault due to integer overflow
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Dec 10, 2021, 15:07 UTC
- Message-ID
- <211210.864k7gcx3r.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <nycvar.QRO.7.76.6.2112101528200.90@tvgsbejvaqbjf.bet>
On Fri, Dec 10 2021, Johannes Schindelin wrote:
Show 17 quoted lines
> Hi Ævar,
>
> On Thu, 9 Dec 2021, Ævar Arnfjörð Bjarmason wrote:
>
>> The difference between "master" and "git-for-windows/main" is large
>> enough that comparing the two will segfault on my system. This is
>> because the range-diff code does some expensive calculations and will
>> overflow the "int" type.
>
> You are holding this thing wrong.
>
> The `main` branch of Git for Windows uses merging rebases, therefore you
> need to use a commit range like
> `git-for-windows/main^{/^Start.the.merging}..git-for-windows/main` and
> compare it to `git-for-windows/main..master`.
>
> Failing that, you will receive only bogus results.Indeed. FWIW I got this segfault on an actual local range-diff that's useful for a very large range & started digging.
I then tried to come up with some arbitrary command someone with a git.git clone might be able to run that would reproduce it without having to tell them to clone chromium.git or <other very large repo>.
> As to the patch series, it likely does the wrong thing. Just like we error > out on insanely large input in libxdiff, `range-diff` should do the same.
I haven't come up with an actual use-case for diffing something large (maybe someone storing DNA sequences as text would?), but have run into practical cases where range-diff would be useful on range where it currently segfaults. E.g. repos that get 500-1000 commits/day someone cherry-picks commits between branches & rewords/adjusts, and you're trying to range-diff it 2 months later looking for differences...