Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2016-09-02 18:48:36 +0300
committerStephen Toub <stoub@microsoft.com>2016-09-02 18:48:36 +0300
commit5afb9f69400cbb61971a7eeb4fcfc49fbbc1080b (patch)
tree650186d40cd880b5617658e5e9207743bc0d11ec /src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
parent2f83c1c6a494a68b7f93405491ac6ca16a29aba8 (diff)
Fix FileStreamBase Begin/End race condition
The new FileStreamBase.Begin/End overloads do argument and state validation similar to that of desktop. There is a subtle but critical difference, however: in this validation, desktop checks to see whether the stream is closed via ```_handle.IsClosed```, whereas FileStreamBase does it via ```SafeFileHandle.IsClosed```. ```SafeFileHandle``` is an abstract property that returns the handle... but it also flushes. The base Stream's Begin/End implementation has synchronization to ensure that only one async operation is in flight at a time, but this call to ```SafeFileHandle.IsClosed``` comes before that synchronization kicks in (it's in the base), and as such we end up potentially having a Flush invocations concurrently with Write invocations (Write is called asynchronously from the base BeginWrite), which is very unsafe. This commit fixes it by adding an IsClosed property that goes directly to the underlying handle, bypassing the publicly exposed SafeFileHandle (that flushes so that direct access to the file via the handle is consistent with operations already performed on the FileStream). (I also fixed a small issue in the ManyConcurrentWriteAsyncs that highlighted the issue. Order of async read/write operations is only guaranteed on FileStream when in async mode; in non-async mode, it's theoretically possible (though unlikely) for operations to complete out-of-order, but the test is validating that the operations completed in order. While I've never seen this fail, I'm proactively fixing it.)
Diffstat (limited to 'src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj')
-rw-r--r--src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
index a7a02c8470..d77b91f907 100644
--- a/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
+++ b/src/System.IO.FileSystem/tests/System.IO.FileSystem.Tests.csproj
@@ -61,8 +61,7 @@
<Compile Include="FileStream\Buffering_regression.cs" />
<Compile Include="FileStream\Flush.cs" />
<Compile Include="FileStream\Dispose.cs" />
- <!-- Disable the FileStream.WriteAsync tests for netcoreapp1.1 since one of them is failing. Issue: https://github.com/dotnet/corefx/issues/11303 -->
- <Compile Condition="'$(TargetGroup)'!='netstandard1.7'" Include="FileStream\WriteAsync.cs" />
+ <Compile Include="FileStream\WriteAsync.cs" />
<Compile Include="FileStream\Write.cs" />
<Compile Include="FileStream\ToString.cs" />
<Compile Include="FileStream\WriteByte.cs" />