diff options
Diffstat (limited to 'tests/src/baseservices/threading/regressions')
27 files changed, 1384 insertions, 0 deletions
diff --git a/tests/src/baseservices/threading/regressions/13662/13662-a.cs b/tests/src/baseservices/threading/regressions/13662/13662-a.cs new file mode 100644 index 0000000000..c3f5d0fd87 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/13662-a.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + + +public class Test { + + public static int Main(){ + + int rValue = 100; + Timer[] tArray = new Timer[1000]; + int val = 0; + while(val < 10){ + Interlocked.Increment(ref val); + Console.WriteLine("Loop {0}",val); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + return rValue; + } + + public static void TFunc(Object o) + { + Thread.Sleep(1); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/13662/13662-a.csproj b/tests/src/baseservices/threading/regressions/13662/13662-a.csproj new file mode 100644 index 0000000000..8e256b8fb5 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/13662-a.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="13662-a.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/13662/13662-b.cs b/tests/src/baseservices/threading/regressions/13662/13662-b.cs new file mode 100644 index 0000000000..1e7a4d9936 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/13662-b.cs @@ -0,0 +1,89 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + + +public class Test { + + public static int Main(){ + + int rValue = 100; + Timer[] tArray = new Timer[1000]; + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + + return rValue; + } + + public static void TFunc(Object o) + { + Thread.Sleep(1); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/13662/13662-b.csproj b/tests/src/baseservices/threading/regressions/13662/13662-b.csproj new file mode 100644 index 0000000000..9b8820f579 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/13662-b.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="13662-b.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/13662/13662-simple.csproj b/tests/src/baseservices/threading/regressions/13662/13662-simple.csproj new file mode 100644 index 0000000000..94e44db77c --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/13662-simple.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="simple.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/13662/simple.cs b/tests/src/baseservices/threading/regressions/13662/simple.cs new file mode 100644 index 0000000000..230c63951f --- /dev/null +++ b/tests/src/baseservices/threading/regressions/13662/simple.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + + +public class Test { + + public static int Main(){ + + int rValue = 100; + Timer[] tArray = new Timer[100]; + int val = 0; + while(val < 10){ + Interlocked.Increment(ref val); + Console.WriteLine("Loop {0}",val); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,1000000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + return rValue; + } + + public static void TFunc(Object o) + { + Thread.Sleep(1); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/17360/AVHelper.csproj b/tests/src/baseservices/threading/regressions/17360/AVHelper.csproj new file mode 100644 index 0000000000..8f639a42e2 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/17360/AVHelper.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>SharedLibrary</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="avhelper.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/17360/avhelper.cs b/tests/src/baseservices/threading/regressions/17360/avhelper.cs new file mode 100644 index 0000000000..6632139736 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/17360/avhelper.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Runtime.InteropServices; +using System.Reflection; +using System.Threading; + +namespace AVHelper +{ + public interface ICreateAV + { + void SpinThread(); + int ThreadName(); + } + + public class CreateAV : ICreateAV + { + public String myAV; + + public CreateAV(){} + + public void SpinThread() + { + myAV = "Created a new String -- Let's get an AV"; + Console.WriteLine("Running SpinThread"); + } + + public int ThreadName() + { + Console.WriteLine(myAV); + return 100; + } + + ~CreateAV() + { + Thread.Sleep(Timeout.Infinite); + } + } +} diff --git a/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs b/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs new file mode 100644 index 0000000000..60185dc496 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/269336/objmonhelper.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class ObjMonHelper { + const string FailMsg = @"Monitor.Enter appears to have mistaken a hash code in an object header for +a valid lock owned by the current thread."; + + public static int Main() { + var ok = true; + var arr = new object[1024*1024]; + + // Call GetHashCode to populate the object header with its hash + for (var i = 0; i < arr.Length; i++) { + arr[i] = new object(); + arr[i].GetHashCode(); + } + + // Attempt to lock and unlock each object. If the bug is present, the object will appear + // to be locked by the current thread and Monitor.Enter will incorrectly take a fast path. + // Monitor.Exit will then correctly take the slow path, find that the object is not locked, + // and throw. + try { + for (var i = 0; i < arr.Length; i++) + lock (arr[i]) + GC.KeepAlive(arr[i]); + } catch (SynchronizationLockException) { + ok = false; + } + + Console.WriteLine(ok ? "Test passed" : FailMsg); + return ok ? 100 : -1; + } +} diff --git a/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj b/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj new file mode 100644 index 0000000000..ae7e32f7f8 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/269336/objmonhelper.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ObjMonHelper.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/30032/30032.cs b/tests/src/baseservices/threading/regressions/30032/30032.cs new file mode 100644 index 0000000000..caf979e6b8 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/30032/30032.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + + +public class Test { + + public static int Main(){ + + int rValue = 100; + Timer[] tArray = new Timer[100]; + int val = 0; + while(val < 10){ + try{ + Interlocked.Increment(ref val); + Console.WriteLine("Loop {0}",val); + for(int i = 0;i<tArray.Length;i++) + tArray[i] = new Timer(new TimerCallback(TFunc),0,1000,100000000); + + Thread.Sleep(1000); + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + catch(Exception e){ + Console.WriteLine(e.ToString()); + rValue = -1; + } + } + Console.WriteLine("Test {0}",100 == rValue ? "Passed":"Failed"); + return rValue; + } + + public static void TFunc(Object o) + { + Thread.Sleep(1); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/30032/30032.csproj b/tests/src/baseservices/threading/regressions/30032/30032.csproj new file mode 100644 index 0000000000..2c5aed90c0 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/30032/30032.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="30032.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/576463/576463.cs b/tests/src/baseservices/threading/regressions/576463/576463.cs new file mode 100644 index 0000000000..d39acadad8 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/576463/576463.cs @@ -0,0 +1,172 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; + +class Test +{ + bool _aRun = false; + public void A() + { + _aRun = true; + Console.WriteLine("A"); + } + + bool _bRun = false; + public void B() + { + _bRun = true; + Console.WriteLine("B"); + } + + volatile bool _cRun = false; + public void C() + { + _cRun = true; + Console.WriteLine("C"); + if (s_takeLock) + { + Console.WriteLine("C: Entering -- Monitor on _objLock"); + + Monitor.Enter(_objLock); + + Console.WriteLine("C: Entered -- Monitor on _objLock"); + + Console.WriteLine("C: Exiting -- Monitor on _objLock"); + Monitor.Exit(_objLock); + Console.WriteLine("C: Exited -- Monitor on _objLock"); + } + } + + bool _dRun = false; + public void D() + { + _dRun = true; + Console.WriteLine("D"); + } + + public bool Pass() + { + bool testPassed = true; + if (_aRun == false) + { + Console.WriteLine("Delegate A did not run"); + testPassed = false; + } + + if (_bRun == false) + { + Console.WriteLine("Delegate B did not run"); + testPassed = false; + } + + if (_cRun == false) + { + Console.WriteLine("Delegate C did not run"); + testPassed = false; + } + + if (_dRun == false) + { + Console.WriteLine("Delegate D did not run"); + testPassed = false; + } + + return testPassed; + } + + public void Send() + { + if (_cb != null) + _cb(); + } + + volatile object _objLock = new object(); + + delegate void GenericCallback(); + event GenericCallback _cb; + + public static void ReadArgs(string[] args) + { + for (int i = 0; i < args.Length; i++) + { + switch (args[i]) + { + case "/contention": + s_contention = true; + goto case "/lock"; + case "/lock": + s_takeLock = true; + break; + default: + break; + } + } + } + + static bool s_takeLock = false; + static bool s_contention = false; + + public static int Main(string[] args) + { + ReadArgs(args); + + Test t = new Test(); + + // subscribe methods to the event + t._cb += t.A; + t._cb += t.B; + // C will take a Monitor on t._objLock, if we are holding it when + // C tries to take the lock it should spin, and in the failure case + // D will not get called. + t._cb += t.C; + t._cb += t.D; + + if (s_contention) + { + Console.WriteLine("Main: Entering -- Monitor on _objLock"); + Monitor.Enter(t._objLock); + Console.WriteLine("Main: Entered -- Monitor on _objLock"); + } + + // Start a new thread with t.Send() as the ThreadStart delegate + Thread newThread = new Thread(new ThreadStart(t.Send)); + newThread.Start(); + + if (s_contention) + { + while (!t._cRun) + { + Thread.Sleep(100); + } + + // We know C has started running, wait a little bit to let + // it get into the Monitor.Enter code. This has a possible race. + Thread.Sleep(5000); + + // Once we're here we know that C has started running and + // is presumably in the Monitor.Enter code, now we release + // the lock to let C have it + Console.WriteLine("Main: Exiting -- Monitor on _objLock"); + Monitor.Exit(t._objLock); + Console.WriteLine("Main: Exited -- Monitor on _objLock"); + } + + // Wait for the eventing on the other thread to finish + newThread.Join(); + + // Check whether or not all callbacks were called + if (t.Pass()) + { + Console.WriteLine("Test passed!"); + return 100; + } + else + { + Console.WriteLine("Test failed!"); + Console.WriteLine("If some delegegates did not run, this failure is most likely due to the loopcount register not being properly tracked during assembly for monitor."); + return 50; + } + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/576463/576463.csproj b/tests/src/baseservices/threading/regressions/576463/576463.csproj new file mode 100644 index 0000000000..7c8c8c834c --- /dev/null +++ b/tests/src/baseservices/threading/regressions/576463/576463.csproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="576463.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/6906/6906.csproj b/tests/src/baseservices/threading/regressions/6906/6906.csproj new file mode 100644 index 0000000000..3cace5d67e --- /dev/null +++ b/tests/src/baseservices/threading/regressions/6906/6906.csproj @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="repro.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/6906/repro.cs b/tests/src/baseservices/threading/regressions/6906/repro.cs new file mode 100644 index 0000000000..cb6e3ca347 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/6906/repro.cs @@ -0,0 +1,41 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; + + +public class Beta +{ + public static int Main(string[] args) + { + int rValue = 100; + Console.WriteLine("Setup an Infinite Wait with negative value other than -1"); + Console.WriteLine("This can't be done on WaitAny and WaitAll"); + WaitHandle Waiter; + Waiter = (WaitHandle) new AutoResetEvent(false); + + try{ + Waiter.WaitOne(-2); + Console.WriteLine("ERROR -- Enabled a wait with -2"); + rValue = 10; + }catch(ArgumentOutOfRangeException){} + + try{ + Waiter.WaitOne(Int32.MinValue); + Console.WriteLine("ERROR -- Enabled a wait with {0}",Int32.MinValue); + + rValue = 20; + }catch(ArgumentOutOfRangeException){} + + try{ + Waiter.WaitOne(-1000000); + Console.WriteLine("ERROR -- Enabled a wait with -1000000"); + rValue = 20; + }catch(ArgumentOutOfRangeException){} + + Console.WriteLine("Test {0}",rValue == 100 ? "Passed":"Failed"); + return rValue; + + } +} diff --git a/tests/src/baseservices/threading/regressions/beta1/347011.cs b/tests/src/baseservices/threading/regressions/beta1/347011.cs new file mode 100644 index 0000000000..fa0377b6aa --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta1/347011.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +public class TimerTest +{ + public static void Target(Object foo){} + + public static int Main() + { + int retVal = 0; + Timer timer = new Timer(new TimerCallback(Target),new Object(), 1000,1000); + timer.Dispose(); + try + { + timer.Change(5000,5000); + retVal = -5; + } + catch(ObjectDisposedException) + { + Console.WriteLine("Caught Expected exception"); + retVal = 100; + } + catch(Exception ex) + { + Console.WriteLine("Unexpected exception: " + ex.ToString()); + retVal = -1; + } + Console.WriteLine(100 == retVal ? "Test Passed":"Test Failed"); + return retVal; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/beta1/347011.csproj b/tests/src/baseservices/threading/regressions/beta1/347011.csproj new file mode 100644 index 0000000000..1b9d480da2 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta1/347011.csproj @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + <CLRTestExecutionArguments>240</CLRTestExecutionArguments> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="347011.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/beta2/437017.cs b/tests/src/baseservices/threading/regressions/beta2/437017.cs new file mode 100644 index 0000000000..284a5ae8df --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta2/437017.cs @@ -0,0 +1,125 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class Test +{ + static bool _fTestFailed = false; + static bool _fTestDone = false; + static ManualResetEvent _mre; + static AutoResetEvent _are = new AutoResetEvent(false); + + public static int Main(string[] args) + { + Thread th = new Thread(new ThreadStart(Thread2)); + th.Start(); + Thread th2 = new Thread(new ThreadStart(Thread3)); + th2.Start(); + System.Diagnostics.Stopwatch myTimer = new System.Diagnostics.Stopwatch(); + myTimer.Start(); + + int i = 0; + while (!_fTestFailed && myTimer.Elapsed.Minutes < 5 && i < 25000) + { + i++; + ManualResetEvent mre = new ManualResetEvent(false); + _mre = new ManualResetEvent(false); + RegisteredWaitHandle rwh = ThreadPool.RegisterWaitForSingleObject(mre, new WaitOrTimerCallback(callback), null, -1, false); + _are.Set(); + + bool bUnregisterSucceeded = false; //Used to improve speed of the test when Unregister has failed + try + { + rwh.Unregister(_mre); + bUnregisterSucceeded = true; + } + catch (ObjectDisposedException) + { + } + + if (bUnregisterSucceeded) + { + try + { + if (_mre.WaitOne(0)) + { + Console.Write("@"); + } + } + catch (ObjectDisposedException) + { + } + } + + if (i % 100 == 0) Console.WriteLine(i); + } + _fTestDone = true; + _are.Set(); + th.Join(); + th2.Join(); + + if (!_fTestFailed) + { + Console.WriteLine("Test Passed"); + return 100; + } + + Console.WriteLine("Test Failed"); + return 101; + + } + + static void callback(object state, bool fTimedOut) + { + Console.Write("!"); + _fTestFailed = true; + } + + public static void Thread3() + { + while (true & !_fTestDone) + { + _are.WaitOne(); + _mre.Dispose(); + } + } + + public static void Thread2() + { + while (true & !_fTestDone) + { + Console.Write("#"); + AutoResetEvent are; + using (are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + + using (are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + + using(are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + } + } +} + diff --git a/tests/src/baseservices/threading/regressions/beta2/437017.csproj b/tests/src/baseservices/threading/regressions/beta2/437017.csproj new file mode 100644 index 0000000000..cdb2952666 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta2/437017.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="437017.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/beta2/437044.cs b/tests/src/baseservices/threading/regressions/beta2/437044.cs new file mode 100644 index 0000000000..9da799fc90 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta2/437044.cs @@ -0,0 +1,119 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class Test +{ + static bool _fTestFailed = false; + static bool _fTestDone = false; + static ManualResetEvent _mre; + static AutoResetEvent _are = new AutoResetEvent(false); + + public static int Main(string[] args) + { + Thread th = new Thread(new ThreadStart(Thread2)); + th.Start(); + Thread th2 = new Thread(new ThreadStart(Thread3)); + th2.Start(); + + for (int i = 0; i < 20000 && !_fTestFailed; i++) + { + _mre = new ManualResetEvent(false); + Timer t = new Timer(new TimerCallback(callback), null, 1000000, Timeout.Infinite); + _are.Set(); + + bool bDisposeSucceeded = false; //Used to improve speed of the test when Dispose has failed + try + { + t.Dispose(); + bDisposeSucceeded = true; + } + catch (ObjectDisposedException) + { + } + + if (bDisposeSucceeded) + { + try + { + if (_mre.WaitOne(0)) + { + Console.Write("@"); + } + } + catch (ObjectDisposedException) + { + } + } + } + _fTestDone = true; + _are.Set(); + th.Join(); + th2.Join(); + + if (!_fTestFailed) + { + Console.WriteLine("Test Passed"); + return 100; + } + + Console.WriteLine("Test Failed"); + return 101; + + } + + static void callback(object state) + { + Console.Write("!"); + _fTestFailed = true; + } + + public static void Thread3() + { + while (true & !_fTestDone) + { + _are.WaitOne(); + _mre.Dispose(); + } + } + + public static void Thread2() + { + while (true & !_fTestDone) + { + Console.Write("#"); + AutoResetEvent are; + + using(are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + + using(are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + + using(are = new AutoResetEvent(false)) + { + if (are.WaitOne(0)) + { + Console.WriteLine("ARE Signaled!"); + _fTestFailed = true; + } + } + } + } +} + diff --git a/tests/src/baseservices/threading/regressions/beta2/437044.csproj b/tests/src/baseservices/threading/regressions/beta2/437044.csproj new file mode 100644 index 0000000000..794e32fcf1 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/beta2/437044.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="437044.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs new file mode 100644 index 0000000000..8b3754f704 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.cs @@ -0,0 +1,52 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; +using System.Threading.Tasks; + +/* + * Issue description: + If a SemaphoreSlim.WaitAsync call is cancelled just after Release has + caused it to start to complete, we end up decrementing the semaphore's + count *and* cancelling the task. The caller does not know the count has + been decremented, because the call appears to fail. This leads to + deadlock later, because the caller has no reason to believe it should + release the erroneously-acquired count. + +Change description: + If the operation has already begun completing successfully, do not + cancel the associated Task. +*/ + +class Test +{ + static int Main(string[] args) + { + SemaphoreSlim s = new SemaphoreSlim(initialCount: 1); + + var cts = new CancellationTokenSource(); + s.Wait(); + var t = s.WaitAsync(cts.Token); + s.Release(); + cts.Cancel(); + + + if (t.Status != TaskStatus.Canceled && s.CurrentCount == 0) + { + Console.WriteLine("PASS"); + return 100; + } + else + { + Console.WriteLine("FAIL"); + Console.WriteLine("Expected task status to not be Canceled and s.CurrentCount == 0"); + Console.WriteLine("Actual: Task: " + t.Status + "; CurrentCount: " + s.CurrentCount); + return 101; + } + + + } +} + diff --git a/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj new file mode 100644 index 0000000000..4406829a69 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/devdiv489437/test489437.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="test489437.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/threadex.cs b/tests/src/baseservices/threading/regressions/threadex.cs new file mode 100644 index 0000000000..f57a094be7 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/threadex.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading; +using System.Reflection; + +public class ThreadEx +{ + public static void Abort(Thread thread) + { + MethodInfo abort = null; + foreach(MethodInfo m in thread.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) + { + if (m.Name.Equals("AbortInternal") && m.GetParameters().Length == 0) abort = m; + } + if (abort == null) + { + throw new Exception("Failed to get Thread.Abort method"); + } + abort.Invoke(thread, new object[0]); + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs new file mode 100644 index 0000000000..6a053a1301 --- /dev/null +++ b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +public class Stop { + + public static int Main(String[] args) { + + Stop tm = new Stop(); + try + { + + ThreadPool.QueueUserWorkItem(new WaitCallback(tm.RunTest)); + Thread.Sleep(3000); + } + catch + { + return -1; + } + return 100; + } + public void RunTest(object foo) + { + try{ + throw new Exception(); + } + catch + {} + } +} diff --git a/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj new file mode 100644 index 0000000000..bef3dcaa2e --- /dev/null +++ b/tests/src/baseservices/threading/regressions/whidbey_m3/200176.csproj @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="200176.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file |