Bug 29039 - CultureInfo.GetCultures(CultureTypes.SpecificCultures) returns broken ar-SA culture
Summary: CultureInfo.GetCultures(CultureTypes.SpecificCultures) returns broken ar-SA c...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-04-13 10:02 UTC by Malcolm Rowe
Modified: 2015-10-26 17:07 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Reproduction (866 bytes, text/x-csharp)
2015-04-13 10:02 UTC, Malcolm Rowe
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

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

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:

GetCultureInfo()
GetCultures(AllCultures)
GetCultures(SpecificCultures)
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 4.0.0.145 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 4.1.0.1183 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 4.0.1.8 also. Screencast regarding same : http://www.screencast.com/t/sx6tWgGKZz

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