Bug 34494 - Crash in dictionary
Summary: Crash in dictionary
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 8.9.x (iOS 8.3)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-10-01 12:58 UTC by Grigory (Playtika)
Modified: 2017-07-26 14:33 UTC (History)
5 users (show)

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

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 Developer Community or GitHub 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:

Description Grigory (Playtika) 2015-10-01 12:58:32 UTC
System.RankException: Arrays must be of same size.
  at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00000] in <filename unknown>:0  (code.cs:1)
  at System.Collections.Generic.Dictionary`2[System.Int32,Monosyne.Graphics.Glyph].Resize () [0x00000] in <filename unknown>:0  (code.cs:1)
  at System.Collections.Generic.Dictionary`2[System.Int32,Monosyne.Graphics.Glyph].set_Item (Int32 key, Monosyne.Graphics.Glyph value) [0x00000] in <filename unknown>:0  (code.cs:1)
Comment 1 Rodrigo Kumpera 2015-10-01 13:40:25 UTC
Please provide a test case that demonstrates the issue so we can fix it.
Comment 2 Grigory (Playtika) 2015-10-01 13:49:20 UTC
i believe my company pays enough to Xamarin (>50 enterprise licenses), so we can focus on writing our app, and not reproducing your bugs.
Comment 3 Rodrigo Kumpera 2015-10-01 15:04:25 UTC
Hi Grigory,

Unfortunately, with as little information as you provided here, there isn't anything we can do.

Can you share at least the full stacktrace? Or the code that uses that dictionary?
Comment 4 Zoltan Varga 2016-03-23 19:02:21 UTC
Is this a random problem ? Is that dictionary being used by multiple threads without locking ?
Comment 5 Grigory (Playtika) 2016-03-23 19:31:35 UTC
Shouldn't it throw InvalidOperationException if collection is modified from wrong thread ?
Comment 6 Zoltan Varga 2016-03-23 20:34:00 UTC
Dictionary-es are not thread safe so they don't detect such accesses.
Comment 7 Kevin Mullins 2017-07-26 14:33:38 UTC
As stated by Zoltan Varga, the C# Dictionary class is not thread safe and is unable to detect the type of access attempted here. However, the .NET Framework 4 introduces the System.Collections.Concurrent namespace, which includes several collection classes that are both thread-safe and scalable. 

ConcurrentDictionary<TKey,TValue> is a thread-safe implementation of a dictionary of key-value pairs that should so the problem seen here. For more information, please see https://docs.microsoft.com/en-us/dotnet/standard/collections/thread-safe/

We are marking this issue as RESOLVED→ANSWERED. If you are still encountering this issue on the latest Xamarin.iOS, please don’t hesitate to reopen the ticket with the requested information. Thanks!