Bug 36370 - AOT: Can't insert into Dictionary<UInt32Enum, object>
Summary: AOT: Can't insert into Dictionary<UInt32Enum, object>
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Zoltan Varga
URL:
Depends on:
Blocks: 36259
  Show dependency tree
 
Reported: 2015-11-30 12:22 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2015-12-01 21:10 UTC (History)
2 users (show)

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


Attachments
test project (5.28 KB, application/zip)
2015-11-30 12:43 UTC, Rolf Bjarne Kvinge [MSFT]
Details

Description Rolf Bjarne Kvinge [MSFT] 2015-11-30 12:22:10 UTC
Repro:
  * Run attached program on device (the problem occurs on both armv7 or arm64)
  * Screen turns green on success, red on failure.

Failure:

> 2015-11-30 13:21:14.014 unifiedtestapp[259:12761] System.InvalidCastException: Specified cast is not valid.
>   at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_object_castclass_unbox (object,intptr)
>   at System.Array.UnsafeMov[S,R] (System.S instance) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/Array.cs:3206 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast[T] (T val) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/ReferenceSources/JitHelpers.cs:14 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Collections.Generic.EnumEqualityComparer`1[T].GetHashCode (T obj) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/equalitycomparer.cs:434 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value, Boolean add) [0x00023] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:326 
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:187 
>   at AppDelegate.TickOnce () [0x0000f] in /Users/rolf/Projects/unified-test-app/AppDelegate.cs:64
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-11-30 12:43:07 UTC
Created attachment 14030 [details]
test project
Comment 2 Zoltan Varga 2015-12-01 17:54:53 UTC
Fixed in mono master a7a0f54d3af48c076939d9a99867c9dd6eb0e626, maccore master bumped in 7a8aa6cdc42bfca3e94fa45260eb475eae06009e.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-12-01 19:26:24 UTC
@Zoltan, it's fixed for uint32, but not for int8 and int16.

Code (replace AppDelegate.cs with this in the test project): https://gist.github.com/rolfbjarne/a439c2853a9b8f7907df

results in

> 2015-12-01 20:23:40.725 unifiedtestapp[4434:3668521] Success: UInt8Enum
> 2015-12-01 20:23:40.729 unifiedtestapp[4434:3668521] Success: UInt16Enum
> 2015-12-01 20:23:40.732 unifiedtestapp[4434:3668521] Success: UInt32Enum
> 2015-12-01 20:23:40.733 unifiedtestapp[4434:3668521] Success: UInt64Enum
> 2015-12-01 20:23:40.740 unifiedtestapp[4434:3668521] Failed: Int8Enum: System.InvalidCastException: Specified cast is not valid.
>   at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_object_castclass_unbox (object,intptr)
>   at System.Array.UnsafeMov[S,R] (System.S instance) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/Array.cs:3206 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast[T] (T val) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/ReferenceSources/JitHelpers.cs:14 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Collections.Generic.SByteEnumEqualityComparer`1[T].GetHashCode (T obj) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/equalitycomparer.cs:472 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value, Boolean add) [0x00023] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:326 
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:187 
>   at AppDelegate.Test[T] () [0x00029] in /Users/rolf/Projects/unified-test-app/AppDelegate.cs:100 
> 2015-12-01 20:23:40.746 unifiedtestapp[4434:3668521] Failed: Int16Enum: System.InvalidCastException: Specified cast is not valid.
>   at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_object_castclass_unbox (object,intptr)
>   at System.Array.UnsafeMov[S,R] (System.S instance) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/System/Array.cs:3206 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Runtime.CompilerServices.JitHelpers.UnsafeEnumCast[T] (T val) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/corlib/ReferenceSources/JitHelpers.cs:14 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at (wrapper unknown) System.Object:gsharedvt_out ()
>   at System.Collections.Generic.ShortEnumEqualityComparer`1[T].GetHashCode (T obj) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/equalitycomparer.cs:487 
>   at (wrapper unknown) System.Object:gsharedvt_in ()
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value, Boolean add) [0x00023] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:326 
>   at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) [0x00000] in /work/maccore/master/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/generic/dictionary.cs:187 
>   at AppDelegate.Test[T] () [0x00029] in /Users/rolf/Projects/unified-test-app/AppDelegate.cs:100 
> 2015-12-01 20:23:40.751 unifiedtestapp[4434:3668521] Success: Int32Enum
> 2015-12-01 20:23:40.754 unifiedtestapp[4434:3668521] Success: Int64Enum>
Comment 4 Zoltan Varga 2015-12-01 21:10:09 UTC
Fixed by the mono bump in 51cb78b8a087d1a98a4913460a7e45293f04cf42.

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.


Create a new report for Bug 36370 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments


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.

Related Links: