Bugzilla – Bug 318770
[PATCH] Invalid IL generated for PtrToStructure internal call
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by jankit@novell.com 2005-08-19 08:14:10 MST ---- System.Runtime.InteropServices.PtrToStructure has two overloads (icalls) : void PtrToStructure (IntPtr ptr, object structure); object PtrToStructure (IntPtr ptr, Type structureType); mono_marshal_get_ptr_to_struct (called from the ves_icall_*) generates IL code for PtrToStructure (IntPtr src, object structure) by looking up the signature for PtrToStructure using 'mono_class_get_method_from_name' which basically finds the first entry with that name and two params. It needs the overload with 'void' return type, which by ordering in Marshal.cs is defined first, so it is able to get the right one. But if the ordering is reversed, then it finds the other overload and thus crashes at runtime with : ** ERROR **: Invalid IL code at IL000b in (wrapper unknown) CertificateContext:PtrToStructure (intptr,System.Type): IL_000b: ret The attached patch avoids the call to mono_class_get_method_from_name which (here) is being called purely to get the signature for the method (PtrToStructure) by building the MonoMethodSignature explicitly. ---- Additional Comments From jankit@novell.com 2005-08-19 08:14:57 MST ---- Created an attachment (id=168381) ptrtostruct3.patch ---- Additional Comments From vargaz@gmail.com 2005-08-19 09:01:31 MST ---- This is ok to check in. ---- Additional Comments From jankit@novell.com 2005-08-19 11:00:39 MST ---- Checked-in, rev 48558. Imported an attachment (id=168381) Unknown operating system unknown. Setting to default OS "Other".