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:
authorTarek Mahmoud Sayed <tarekms@microsoft.com>2017-05-09 04:03:05 +0300
committerJan Kotas <jkotas@microsoft.com>2017-05-09 07:45:23 +0300
commit5499bb698d81e1160e911125d61a317256ea16e2 (patch)
treef3902de202c9107fee5302c935875aa94df2a8e6 /src/System.Private.CoreLib
parent1943aad9cd92af2b4d1f92bf6324a4adade941d7 (diff)
Avoid throwing in the globalization managed callbacks (#11454)
* Avoid throwing in the globalization managed callbacks * Add Assert Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src/System.Private.CoreLib')
-rw-r--r--src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs
index 319f66ae8..a2ceeb1e6 100644
--- a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs
+++ b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs
@@ -306,21 +306,30 @@ namespace System.Globalization
private static void EnumCalendarInfoCallback(string calendarString, IntPtr context)
{
- CallbackContext callbackContext = (CallbackContext)((GCHandle)context).Target;
-
- if (callbackContext.DisallowDuplicates)
+ try
{
- foreach (string existingResult in callbackContext.Results)
+ CallbackContext callbackContext = (CallbackContext)((GCHandle)context).Target;
+
+ if (callbackContext.DisallowDuplicates)
{
- if (string.Equals(calendarString, existingResult, StringComparison.Ordinal))
+ foreach (string existingResult in callbackContext.Results)
{
- // the value is already in the results, so don't add it again
- return;
+ if (string.Equals(calendarString, existingResult, StringComparison.Ordinal))
+ {
+ // the value is already in the results, so don't add it again
+ return;
+ }
}
}
- }
- callbackContext.Results.Add(calendarString);
+ callbackContext.Results.Add(calendarString);
+ }
+ catch (Exception e)
+ {
+ Debug.Assert(false, e.ToString());
+ // we ignore the managed exceptions here because EnumCalendarInfoCallback will get called from the native code.
+ // If we don't ignore the exception here that can cause the runtime to fail fast.
+ }
}
private class CallbackContext