Bug 40568

Summary: Runtime crashing on System.Enum.GetValues on char enums with F#
Product: [Mono] Runtime Reporter: Eirik Tsarpalis <eirik>
Component: ReflectionAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+runtime, vargaz
Priority: ---    
Version: 4.2.0 (C6)   
Target Milestone: ---   
Hardware: PC   
OS: All   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Reproducing F# console app

Description Eirik Tsarpalis 2016-04-20 19:56:06 UTC
Created attachment 15791 [details]
Reproducing F# console app

Here's a small reproduction of the crash using a simple F# console app:

module Test

type Enum = A = 'A' | B = 'B'

[<EntryPoint>]
let main _ =
    let values = System.Enum.GetValues(typeof<Enum>)
    printfn "%A" values
    0

Which when run crashes with the following error message:

* Assertion: should not be reached at icall.c:2963

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Enum.InternalBoxEnum (System.RuntimeType,long) <0xffffffff>
  at System.Enum.ToObject (System.Type,ulong) <0x00096>
  at System.RuntimeType.GetEnumValues () <0x00062>
  at System.Enum.GetValues (System.Type) <0x0002d>
  at Test.main (string[]) <0x0001a>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	mono() [0x49d5fc]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x10d10) [0x7f1338d3cd10]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x37) [0x7f1338997267]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7f1338998eca]
	mono() [0x62ac69]
	mono() [0x62ae77]
	mono() [0x62afc6]
	mono() [0x536e21]
	[0x413118b8]


Reproducing consistently in mono 4.2 in both mac and linux. 
Strangely enough, I could not get the equivalent C# code to crash.
Comment 1 Zoltan Varga 2016-04-21 21:27:38 UTC
Fixed in mono master 92bcc1db28f6e1341b54ba7287814fcf16cfbb30.