Conversation
QualityProfile.MinimumSize and MaximumSize are int megabytes, and the scorer multiplied them by 1024 * 1024 in int arithmetic. 2048 MB is one byte past int.MaxValue once multiplied, so a profile capped at 2 GB or more wraps negative and the two gates fail in opposite directions: every release is "larger than" a negative maximum and is rejected as too large, and nothing is "smaller than" a negative minimum so the minimum silently stops applying. The quality profile form puts no upper bound on either input, and a 2 GB ceiling on an audiobook profile is an ordinary thing to set. The fix is the cast the indexer size gate one block above already uses. Both theories carry a control row below the overflow, so a fix that simply stopped rejecting, or simply started rejecting, fails them. Without the casts the four overflow rows fail and the two control rows pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
m4bard
force-pushed
the
fix/profile-size-int-overflow
branch
from
September 15, 2026 18:35
3701a1e to
5d3937f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #977.
SearchResultScorer's size gate multipliesQualityProfile.MinimumSizeandMaximumSize, bothintmegabytes, by1024 * 1024before comparing against a result'slongbyte size. At 2048 MB the multiply overflowsintand wraps to -2147483648, so the two gates fail in opposite directions: Maximum rejects every size, since everything is greater than a negative number, and Minimum stops rejecting anything, since nothing is smaller than one. The indexer size gate a few lines above already casts tolongfirst, which is what makes the two profile lines next to it look like an oversight rather than a design choice.The fix is the same cast the indexer gate already uses, applied to both lines.
Two theories, each with a control row below the overflow threshold so a change that simply stopped rejecting, or simply started rejecting, would fail the control. Without the casts, the four overflow rows fail and the two controls pass.
Suite run against current canary (
upstream/canaryata630572e9, which this branch is built on): targeted filterQualityProfileScoringTests, 23 passed, 0 failed.Found while wiring
Indexer.MaximumSizein #921 and kept out of that PR as a separate bug. Full mechanism and the repro test are in the issue.Disclosure: drafted with Claude Code at my direction; I read the cited code at commit a630572 and reviewed this before posting.