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

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kliger <alklig@microsoft.com>2020-10-05 22:06:01 +0300
committerAleksey Kliger <alklig@microsoft.com>2020-10-08 19:12:57 +0300
commit8d5604960b66287d391d5ff2aa093b2118466bd1 (patch)
treefbf2cbfb23c00137e09262652c741f4653a84932
parentffcd7990d87e560c63413293c8efe1d1fc4e3584 (diff)
[corlib] ThreadAbortException protection for ArraySortHelper
The ArraySortHelper catches all exceptions in the comparer. If the sorting thread is aborted while it is running the comparer, the ArraySortHelper will catch the TAE and propagate an InvalidOperationException instead. As a workaround, catch and rethrow TAEs separately. Related to https://github.com/mono/mono/issues/15418
-rw-r--r--src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs
index 03b986504..e1c232e84 100644
--- a/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs
+++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs
@@ -14,6 +14,7 @@
===========================================================*/
using System.Diagnostics;
+using System.Threading;
using System.Runtime.CompilerServices;
namespace System.Collections.Generic
@@ -68,6 +69,10 @@ namespace System.Collections.Generic
{
IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -85,6 +90,10 @@ namespace System.Collections.Generic
return InternalBinarySearch(array, index, length, value, comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -108,6 +117,10 @@ namespace System.Collections.Generic
{
IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -355,6 +368,10 @@ namespace System.Collections.Generic
{
IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -377,6 +394,10 @@ namespace System.Collections.Generic
return ArraySortHelper<T>.InternalBinarySearch(array, index, length, value, comparer);
}
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -645,6 +666,10 @@ namespace System.Collections.Generic
{
IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);
@@ -893,6 +918,10 @@ namespace System.Collections.Generic
{
IntrospectiveSortUtilities.ThrowOrIgnoreBadComparer(comparer);
}
+ catch (ThreadAbortException)
+ {
+ throw;
+ }
catch (Exception e)
{
throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e);