-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[release/6.0] Fix Int32 overflow bug in buffering logic #60460
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsBackport of #60459 to release/6.0 /cc @adamsitnik Customer ImpactTestingRisk
|
Co-authored-by: Carlos Sanchez <[email protected]>
@danmoseley since @jeffhandley is offline today, could you PTAL? The bug is serious, but it's an edge case and the change is very small. |
@adamsitnik I think we should take this. Please send the usual email. |
(It would meet the servicing bar, I think) |
Looks like this test is too mighty for Window 7 x86 -- it's failed twice there. Not enough virtual memory?
|
@danmoseley why that error doesn't show up in |
My guess is because we have moved some configurations post commit and that isn't ported to 6.0 yet. @aik-jahoda |
Because we are no longer testing the .NET 5 Compat implementation in main (#57735) |
@adamsitnik do you have a concrete theory why we saw the hang/extreme slowness on 32bit? It would make it impossible to allocate a full 2GB array, but if the implementation is even trying to do that (I assume not) it would cause an exception. No doubt the machine has many GB memory so I would not expect paging (although that is OS decision). |
I can merge this if you guys think it is ready now |
I've tried to repro it on my Windows 10 machine and I've failed.
It's a very simple case: just sync file IO. Was it Windows 7? In such case I would imagine that it may block instead of throwing it when runs out of disk space. But I am just guessing.
I do think it's ready to solve the immediate problem (Int32Overflow in the buffering logic) For large files support for Win 7 x86, we might have just discovered an issue, similar like I did with WASM: #45954 (comment) That is going to require a separate investigation. |
whats the status of this one ? should we merge it ? tomorrow is the last day |
It has been approved, please merge it. |
Backport of #60459 to release/6.0
/cc @adamsitnik
Customer Impact
Customers who use Seek() in FileStream or BufferedStream with an offset larger than 4GB and then proceed to Read() might get the incorrect data as the buffering logic won't notice that the position has changed and the data present in the buffer should be flushed, this is due an arithmetic overflow error in the Seek implementation.
Some pseudocode to show the problem:
Testing
A unit test that exercises the edge case scenario has been added. It was failing before the fix has been applied, now it's passing.
Risk
We believe it's a minimal change required to fix the bug. It's low risk as it's just removing the cast from long to int which was causing the problem.
Furthermore, this issue has been present in BufferedStream since 1.0 and it was found now that FileStream copies its logic internally.