Bug 29039

Summary: CultureInfo.GetCultures(CultureTypes.SpecificCultures) returns broken ar-SA culture
Product: [Mono] Class Libraries Reporter: Malcolm Rowe <malcolm.rowe+xamarin-bugzilla>
Component: mscorlibAssignee: Marek Safar <masafa>
Severity: normal CC: artyom.szasa, masafa, mono-bugs+mono, shrutis
Priority: ---    
Version: master   
Target Milestone: Untriaged   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Reproduction

Description Malcolm Rowe 2015-04-13 10:02:35 UTC
Created attachment 10734 [details]

In mono-4.0.0-branch/9236ac4 and master/4fc75b3, CultureInfo.DateTimeFormat will throw a NullReferenceException for the ar-SA culture (only, it seems), if obtained via CultureInfo.GetCultures(CultureTypes.SpecificCultures).  This is a regression from 3.12.0.

I don't know if it's relevant that ar-SA is the first culture returned by CultureInfo.GetCultures(CultureTypes.SpecificCultures), probably not.  (That's also true in 3.12.0.)

This does not happen with any other culture, including ar-SA returned via CultureInfo.GetCultures(CultureTypes.AllCultures) or CultureInfo.GetCultureInfo("ar-SA").

A simple reproduction is attached. In 4.0.0/master, this prints:

Failed for culture ar-SA
System.NullReferenceException: Object reference not set to an instance of an object
  at System.Globalization.DateTimeFormatInfo.get_OptionalCalendars () [0x0000b] in /home/malcolm/mono/mono-git/external/referencesource/mscorlib/system/globalization/datetimeformatinfo.cs:715 
  at System.Globalization.DateTimeFormatInfo.set_Calendar (System.Globalization.Calendar value) [0x00140] in /home/malcolm/mono/mono-git/external/referencesource/mscorlib/system/globalization/datetimeformatinfo.cs:632 
  at System.Globalization.DateTimeFormatInfo..ctor (System.Globalization.CultureData cultureData, System.Globalization.Calendar cal) [0x00022] in /home/malcolm/mono/mono-git/external/referencesource/mscorlib/system/globalization/datetimeformatinfo.cs:355 
  at System.Globalization.CultureInfo.get_DateTimeFormat () [0x0002d] in /home/malcolm/mono/mono-git/mcs/class/corlib/System.Globalization/CultureInfo.cs:542 
  at Program.Test (System.Globalization.CultureInfo ci) [0x0000a] in /home/malcolm/mono/repro2/Program.cs:27 
Comment 1 Marek Safar 2015-04-13 14:26:00 UTC
Fixed in master
Comment 2 Shruti 2015-04-24 05:44:27 UTC
I am able to reproduce this issue with latest Mono but this is C5 latest build as we don't have mono in Master dropbox. Here is the screencast to reproduce the issue :  http://www.screencast.com/t/EHkkWIvmokZq\

Please provide the Master Mono where we can verify this issue.
Comment 3 Shruti 2015-04-28 02:10:22 UTC
I have verified this issue on Master branch Mono and observed that now I am not getting any exception for CultureInfo.GetCultures(CultureTypes.SpecificCultures). Screencast for the same :  http://www.screencast.com/t/NOFpmGQpz

Environment Info :  https://gist.github.com/Shruti360/4ce6bce69c785afab959

I also checked this issue on C5 Mono and did not face any exception with Mono also. Screencast regarding same : http://www.screencast.com/t/sx6tWgGKZz

Environment Info : https://gist.github.com/Shruti360/3fce96c3932f6faefb56