Re: [PATCH v3] range-diff: add configurable memory limit for cost matrix
- From
Elijah Newren <newren@gmail.com>
- Date
- Aug 29, 2025, 15:21 UTC
- Message-ID
- <CABPp-BHnCHiTFNKCrnpKF5STkeGNQWMxdVMZ_v-Rp2judZVEgw@mail.gmail.com>
- In-Reply-To
- <pull.1958.v3.git.1756465231183.gitgitgadget@gmail.com>
On Fri, Aug 29, 2025 at 4:00 AM Paulo Casaretto via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 18 quoted lines
> -
> - ALLOC_ARRAY(cost, st_mult(n, n));
> + size_t cost_size = st_mult(n, n);
> + size_t cost_bytes = st_mult(sizeof(int), cost_size);
> + if (cost_bytes >= max_memory) {
> + struct strbuf cost_str = STRBUF_INIT;
> + struct strbuf max_str = STRBUF_INIT;
> + strbuf_humanise_bytes(&cost_str, cost_bytes);
> + strbuf_humanise_bytes(&max_str, max_memory);
> + die(_("range-diff: unable to compute the range-diff, since it "
> + "exceeds the maximum memory for the cost matrix: %s "
> + "(%"PRIuMAX" bytes) needed, %s (%"PRIuMAX" bytes) available"),
> + cost_str.buf, (uintmax_t)cost_bytes, max_str.buf, (uintmax_t)max_memory);
> + }
> + ALLOC_ARRAY(cost, cost_size);
> ALLOC_ARRAY(a2b, n);
> ALLOC_ARRAY(b2a, n);
>This still has the same wording issue that I commented on in v2: https://lore.kernel.org/git/CABPp-BEDje5dYZHEyYMN6j_LdR5CqRN1cxc0riRK06qK-OxiTA@mail.gmail.com/