You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FileStream position is not updated when sync write partially succeeds #127854
When this loop round on a partial write, and on the next iteration it throws at FileStreamHelpers.CheckFileCall, then FileStream position does not match that of the partial write.
I am not 100% sure, from my experience we usually don't ensure a valid state after an exception is throw. At the same time, I would not mind passing the offset by ref to this method to get it updated on every iteration.
I think it makes sense to try to maintain valid consistent state for these types of errors.
we usually don't ensure a valid state after an exception is throw.
It primarily applies to fatal state situations where it is not reasonable to do that. For example, if a lock throws an exception and we need to take the lock to update the state to be valid.
Activity
dotnet-policy-service commentedon May 6, 2026
Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.
adamsitnik commentedon May 6, 2026
RandomAccess.WriteAtOffsetis responsible for ensuring that it writes all bytes:runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Unix.cs
Lines 146 to 149 in c0bea40
tmds commentedon May 6, 2026
When this loop round on a partial write, and on the next iteration it throws at
FileStreamHelpers.CheckFileCall, thenFileStreamposition does not match that of the partial write.Is that the intended behavior?
adamsitnik commentedon May 6, 2026
I am not 100% sure, from my experience we usually don't ensure a valid state after an exception is throw. At the same time, I would not mind passing the offset by
refto this method to get it updated on every iteration.@jkotas @stephentoub what is our official guidance?
tmds commentedon May 6, 2026
Because the async methods handle this, I'd expect the sync methods to handle it too.
jkotas commentedon May 7, 2026
I think it makes sense to try to maintain valid consistent state for these types of errors.
It primarily applies to fatal state situations where it is not reasonable to do that. For example, if a lock throws an exception and we need to take the lock to update the state to be valid.
Fix FileStream position not updated when sync write partially succeeds
Update FileStream position when sync write partially succeeds (#130687)