git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 7/8] pack-bitmap: reject pseudo-merge "sampleRate" of 0

From
Elijah Newren <newren@gmail.com>
Date
Apr 19, 2026, 00:26 UTC
Message-ID
<CABPp-BH2Zsf03DT8MOtCn=3Sn=Tz_7MF1VwosPjVLdAGo42OCA@mail.gmail.com>
In-Reply-To
<1b0f7295c21bf6240bef975e5f3fb9da685f29d3.1776124589.git.me@ttaylorr.com>
On Mon, Apr 13, 2026 at 4:56 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 40 quoted lines
>
> The "bitmapPseudoMerge.*.sampleRate" configuration controls what
> fraction of unstable commits are included in each pseudo-merge group.
> The config validation accepts values in the range `[0, 1]`, but a value
> of exactly 0 causes a division by zero in `select_pseudo_merges_1()`:
>
>     if (j % (uint32_t)(1.0 / group->sample_rate))
>
> When `sample_rate` is 0, `1.0 / 0.0` produces `+inf`, and casting
> infinity to `uint32_t` is undefined behavior in C. On most platforms
> this yields 0, making the subsequent modulo operation (`j % 0`) a
> fatal arithmetic trap.
>
> This path was not previously reachable because an earlier bug caused
> all pseudo-merge candidates to be classified as "stable" (where the
> sampling rate is not used), regardless of their actual commit date. Now
> that the date classification is fixed, the unstable path is exercised
> and the division by zero can fire.
>
> Fix this by changing the validation to require a strict lower bound and
> thus reject 0.
>
> Signed-off-by: Taylor Blau <me@ttaylorr.com>
> ---
>  pseudo-merge.c                  | 4 ++--
>  t/t5333-pseudo-merge-bitmaps.sh | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/pseudo-merge.c b/pseudo-merge.c
> index d79e5fb649a..75bed043602 100644
> --- a/pseudo-merge.c
> +++ b/pseudo-merge.c
> @@ -169,8 +169,8 @@ static int pseudo_merge_config(const char *var, const char *value,
>                 }
>         } else if (!strcmp(key, "samplerate")) {
>                 group->sample_rate = git_config_double(var, value, ctx->kvi);
> -               if (!(0 <= group->sample_rate && group->sample_rate <= 1)) {
> -                       warning(_("%s must be between 0 and 1, using default"), var);
> +               if (!(0 < group->sample_rate && group->sample_rate <= 1)) {
> +                       warning(_("%s must be between 0 (exclusive) and 1, using default"), var);

The documentation for `bitmapPseudoMerge.<name>.sampleRate` in Documentation/config/bitmap-pseudo-merge.adoc still claims that 0 is allowed; should that be fixed as part of this patch?

Also:

``` $ git grep -B 4 -i samplerate.*= Documentation/gitpacking.adoc-[bitmapPseudoMerge "all"] Documentation/gitpacking.adoc- pattern = "refs/" Documentation/gitpacking.adoc- threshold = now Documentation/gitpacking.adoc- stableThreshold = never Documentation/gitpacking.adoc: sampleRate = 100 -- Documentation/gitpacking.adoc-[bitmapPseudoMerge "all"] Documentation/gitpacking.adoc- pattern = "refs/virtual/([0-9]+)/(heads|tags)/" Documentation/gitpacking.adoc- threshold = now Documentation/gitpacking.adoc- stableThreshold = never Documentation/gitpacking.adoc: sampleRate = 100 ```

Should those sampleRates be fixed?
Previous: Taylor BlauNext: Taylor Blau
Message 18 of 46 in “pack-bitmap: fix various pseudo-merge bugs”
  1. 0/8 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, Apr 13, 2026
  2. 1/8 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, Apr 13, 2026
  3. Junio C HamanoApr 14, 2026
  4. Taylor BlauApr 14, 2026
  5. Junio C HamanoApr 14, 2026
  6. Taylor BlauApr 14, 2026
  7. Junio C HamanoApr 14, 2026
  8. Taylor BlauApr 14, 2026
  9. Elijah NewrenApr 19, 2026
  10. Taylor BlauApr 21, 2026
  11. 2/8 t5333: demonstrate various pseudo-merge bugsTaylor Blau, Apr 13, 2026
  12. Elijah NewrenApr 19, 2026
  13. 3/8 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, Apr 13, 2026
  14. 4/8 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, Apr 13, 2026
  15. 5/8 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, Apr 13, 2026
  16. 6/8 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, Apr 13, 2026
  17. 7/8 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, Apr 13, 2026
  18. Elijah NewrenApr 19, 2026
  19. 8/8 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, Apr 13, 2026
  20. 0/9 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, Apr 21, 2026
  21. 1/9 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, Apr 21, 2026
  22. 2/9 t5333: demonstrate various pseudo-merge bugsTaylor Blau, Apr 21, 2026
  23. 3/9 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, Apr 21, 2026
  24. 4/9 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, Apr 21, 2026
  25. 5/9 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, Apr 21, 2026
  26. 6/9 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, Apr 21, 2026
  27. 7/9 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, Apr 21, 2026
  28. 8/9 Documentation: fix broken `sampleRate` in gitpacking(7)Taylor Blau, Apr 21, 2026
  29. 9/9 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, Apr 21, 2026
  30. Elijah NewrenApr 22, 2026
  31. Junio C HamanoMay 11, 2026
  32. Taylor BlauMay 12, 2026
  33. Taylor BlauMay 12, 2026
  34. 0/9 pack-bitmap: fix various pseudo-merge bugsTaylor Blau, May 12, 2026
  35. 1/9 t/helper: add 'test-tool bitmap write' subcommandTaylor Blau, May 12, 2026
  36. 2/9 t5333: demonstrate various pseudo-merge bugsTaylor Blau, May 12, 2026
  37. 3/9 pack-bitmap-write: sort pseudo-merge commit lookup table in pack orderTaylor Blau, May 12, 2026
  38. 4/9 pack-bitmap: fix inverted binary search in `pseudo_merge_at()`Taylor Blau, May 12, 2026
  39. 5/9 pack-bitmap: fix pseudo-merge lookup for shared commitsTaylor Blau, May 12, 2026
  40. 6/9 pack-bitmap: parse commits in `find_pseudo_merge_group_for_ref()`Taylor Blau, May 12, 2026
  41. 7/9 pack-bitmap: reject pseudo-merge "sampleRate" of 0Taylor Blau, May 12, 2026
  42. 8/9 Documentation: fix broken `sampleRate` in gitpacking(7)Taylor Blau, May 12, 2026
  43. 9/9 pack-bitmap: prevent pattern leak on pseudo-merge re-assignmentTaylor Blau, May 12, 2026
  44. Junio C HamanoMay 12, 2026
  45. Taylor BlauMay 12, 2026
  46. Junio C HamanoMay 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.