diff options
author | Aleksey Kliger (λgeek) <alklig@microsoft.com> | 2020-10-08 19:15:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 19:15:30 +0300 |
commit | 11136ad55767485063226be08cfbd32ed574ca43 (patch) | |
tree | fbf2cbfb23c00137e09262652c741f4653a84932 /src/System.Private.CoreLib/shared | |
parent | ffcd7990d87e560c63413293c8efe1d1fc4e3584 (diff) | |
parent | 8d5604960b66287d391d5ff2aa093b2118466bd1 (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 mono/mono#15418
Diffstat (limited to 'src/System.Private.CoreLib/shared')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs | 29 |
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); |