Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflow in GetHexStringCore #111296

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Conversation

vcsjones
Copy link
Member

If destination's length is int.MaxValue, adding 1 will overflow it. To address this, we can use an unsigned shift to the right by one instead of dividing by two.

I don't think it is particularly feasible to unit test this - it would require allocating a 4GB span. Generally those yield unstable tests in CI.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@karakasa
Copy link
Contributor

karakasa commented Jan 12, 2025

I don't think it is particularly feasible to unit test this - it would require allocating a 4GB span. Generally those yield unstable tests in CI.

Just want to ask: I have a similar hex parsing overflow fix for BigInteger on a rare path (#105570). I wrote a test and put it in OuterLoop (as it requires 1.5~2GB of memory and allocating a big array). Should I remove that test?

@vcsjones
Copy link
Member Author

OuterLoop (as it requires 1.5~2GB of memory).

2.0 GB is iffy. You should probably work with the area owners on figuring out the right thing to do to decide how critical it is to have test coverage for the scenario. I would expect a 2.0 gig allocation to fail on mobile platforms (iOS and tvOS) and stress Linux. Linux's behavior can be unfortunate the oomkiller might just abort the whole test run. (TL;dr on oomkiller: sometimes a large allocation will succeed, but Linux will decide that it is starved for memory, and just do a kill -9 on the whole process)

#100558 is an example of where a 2 GB allocation was aborting test runs.

@karakasa
Copy link
Contributor

karakasa commented Jan 13, 2025

ou should probably work with the area owners

Thanks. I thought there was a repo-wide consensus/policy on memory-consuming tests.

@bartonjs
Copy link
Member

/ba-g The Windows 8.1 queue seems to be backed up. This change would not uniquely impact that OS, so signing off based on the successful legs.

@vcsjones vcsjones merged commit b8d8372 into dotnet:main Jan 13, 2025
79 of 82 checks passed
@vcsjones vcsjones deleted the fix-overflow-gethexstring branch January 13, 2025 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants