Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono runtime crashes when running Vagabond #2

Open
eiriktsarpalis opened this issue Sep 9, 2014 · 5 comments
Open

Mono runtime crashes when running Vagabond #2

eiriktsarpalis opened this issue Sep 9, 2014 · 5 comments

Comments

@eiriktsarpalis
Copy link
Member

The MethodInfo.GetInstructions() extension found in Mono.Reflection can result in crashes when parsing dynamic assembly IL. This makes Vagrant practically unusable in mono. The following F# script reproduces the issue

#r "Mono.Reflection.dll" // the standard Mono.Reflection library found on nuget

open System
open System.Reflection
open Mono.Reflection

type Foo<'T> = Foo of 'T

type Mapper =
    static member map (f : 'a -> 'b, Foo x) = Foo (f x)


let m = typeof<Mapper>.GetMethod("map")

let instructions = m.GetInstructions()

let field = 
    instructions 
    |> Seq.pick(fun i -> match i.Operand with :? FieldInfo as f -> Some f | _ -> None)


field.ToString() // "a item"

field.MetadataToken // crashes with '* Assertion at reflection.c:7764, condition `field_index >= 0 && field_index < dgclass->count_fields' not met'
@eiriktsarpalis
Copy link
Member Author

A somewhat related issue occurs when attempting to call .GetRawConstantValue() on dynamic assembly fields.

See also https://github.com/mono/mono/blob/master/mono/metadata/icall.c#L1900

@eiriktsarpalis
Copy link
Member Author

Also related is the fact that mono does not support the .GetCustomAttributes() method for generic dynamic types. For instance

Nessos.FsPickler.PicklerGenerationException: Error generating pickler for type 'FSI_0049+runAsync@6[FSI_0049+Bar`1[System.Int32][]]'. ---> System.NotSupportedException: Operation is not supported.
  at System.Reflection.MonoGenericClass.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.tryFindCompilationMappingAttributeFromType (System.Type typ) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.tryFindSourceConstructFlagsOfType (System.Type typ) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.isUnionType (System.Type typ, BindingFlags bindingFlags) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.get@470-1 (BindingFlags bindingFlags, System.Type typ) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.isConstructorRepr (System.Type typ, BindingFlags bindingFlags) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.Impl.getTypeOfReprType (System.Type typ, BindingFlags bindingFlags) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Reflection.FSharpType.IsUnion (System.Type typ, Microsoft.FSharp.Core.FSharpOption`1 bindingFlags) [0x00000] in <filename unknown>:0 

See also https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Reflection/MonoGenericClass.cs#L503

@eiriktsarpalis
Copy link
Member Author

Filed a related bug report https://bugzilla.xamarin.com/show_bug.cgi?id=23769

@eiriktsarpalis
Copy link
Member Author

Filed related bug report https://bugzilla.xamarin.com/show_bug.cgi?id=33208

@eiriktsarpalis eiriktsarpalis changed the title Mono runtime crashes when running Vagrant Mono runtime crashes when running Vagabond Aug 18, 2015
@dsyme
Copy link
Contributor

dsyme commented Jun 8, 2017

I'm glad to say this is now the one-and-only open issue with vagabond :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants