[Mono-devel-list] IKVM show stopper

Paolo Molaro lupus at ximian.com
Thu Jun 10 14:24:11 EDT 2004


On 06/10/04 Jeroen Frijters wrote:
> To fix an IKVM bug, I had to make a change to how MethodBuilder
> instances are converted into their baked MethodInfo equivalents. This
> exposed a bug in Mono's (0.95) ModuleBuilder.GetMethodToken().
> 
> The attached program demonstrates that ModuleBuilder.GetMethodToken()
> allocates a new token, instead of returning the existing one, when it is
> called with a MethodInfo (instead of a MethodBuilder).
> 
> I think the bug is in mono_image_create_token (reflection.c), as that
> just blindly assigns a new token value when the passed in object is a
> MonoMethod.

I fixed this for methods and ctors in cvs. Do you need it for fields as
well as all the other tokens?

> Also, if you look at the generated test.dll, you'll see that the actual
> method token is also one off from the one reported by
> MethodBuilder.GetToken().

Yes. Do you rely on that behaviour? Since it's not possible to guarantee
it in the general case, I avoided the issue. Currently you get the
tokens to match on mono if you create first all the ctors and then all
the methods, because that is the order we emit them in the final binary
(it's easier since we keep separate arrays for ctors and normal methods).
In the general case the tokens won't match, because the methods of a
type need to be contiguous in the PE file, but with reflection you can
create a few mthods for a type, then for another, then for the old one
again and the tokesn are assigned sequentially.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list