[Mono-bugs] [Bug 75847][Nor] New - [PATCH] Invalid IL generated for PtrToStructure internal call

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Aug 19 08:14:10 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jankit at novell.com.

http://bugzilla.ximian.com/show_bug.cgi?id=75847

--- shadow/75847	2005-08-19 08:14:10.000000000 -0400
+++ shadow/75847.tmp.9564	2005-08-19 08:14:10.000000000 -0400
@@ -0,0 +1,39 @@
+Bug#: 75847
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: interop
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: jankit at novell.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [PATCH] Invalid IL generated for PtrToStructure internal call
+
+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.


More information about the mono-bugs mailing list