Repository navigation
[release/11.0] Enforce BigInteger maximum length for shifts - #137427
tannergooding merged 1 commit into
Conversation
Resolves dotnet#137327 Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @dotnet/area-system-numerics |
artl93
left a comment
There was a problem hiding this comment.
Regression. We should do math operations with consistent behavior. Was this customer reported?
jeffhandley
left a comment
There was a problem hiding this comment.
Clean backport of fix already made in main (.NET 12), addressing a customer-reported regression in .NET 11 with BigInteger left shift no longer enforces the maximum length in .NET 11 (#137327).
/cc @artl93 Yes, customer-reported after GA.
|
Hi, the code complete date for 11.0.1 (the December 2026 release) is Monday 16 November. Make sure to merge this PR on that date at the latest, or it won't make it into that release. As a reminder, if this is a product change, you also need Tactics approval before merging this PR (test-only or infra-only changes don't require Tactics approval). Happy to help with the merge if needed! |
|
/ba-g unrelated http test abort |
Fixes #137327
main PR #132709
Description
Guard inline and array-backed BigInteger left shifts before allocation so results exceeding the existing maximum limb count throw OverflowException. Add regression coverage for large shifts, BigInteger.Pow, int.MinValue right-shift reversal, and a carry that would exceed the limit.
Customer Impact
In .NET 11, oversized shifts can create invalid BigInteger values (about 256 MiB for the reported case). Later arithmetic may throw unexpectedly, and RotateLeft can return an incorrect result.
This was reported by a customer after the .NET 11 release, in BigInteger left shift no longer enforces the maximum length in .NET 11 (#137327).
Regression
Yes. .NET 11 accepts shifts whose results exceed the maximum length; .NET 10 throws OverflowException at the shift.
Testing
.\build.cmd clr+libs -rc release— passed baseline build.src\libraries\System.Runtime.Numerics\tests,dotnet build /t:Test— passed, 8,428 tests.dotnet build /t:Test /p:XunitMethodName=System.Numerics.Tests.BigIntegerPropertyTests.PowerOfTwoResultsRespectMaximumLength— failed as expected when the oversized value violated the maximum-length assertion..\build.cmd tasks -c Releaseand.\build.cmd clr+libs -rc release -lc release— passed Release test prerequisites.dotnet build /t:Test -c Release /p:XunitMethodName=System.Numerics.Tests.BigIntegerPropertyTests.PowerOfTwoResultsRespectMaximumLength— passed, 1 test.Risk
Low. Only shifts whose computed limb count exceeds the existing maximum now throw before allocating. Normal-sized shift behavior is unchanged.
Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.
Resolves #137327
Note
This pull request description was drafted with GitHub Copilot.