[Mono-bugs] [Bug 688008] New: Mono fails to run F# code involving native pointers that works on .NET
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Sat Apr 16 13:55:38 EDT 2011
https://bugzilla.novell.com/show_bug.cgi?id=688008
https://bugzilla.novell.com/show_bug.cgi?id=688008#c0
Summary: Mono fails to run F# code involving native pointers
that works on .NET
Classification: Mono
Product: Mono: Runtime
Version: SVN
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: JIT
AssignedTo: lupus at novell.com
ReportedBy: st at quanttec.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Created an attachment (id=425276)
--> (http://bugzilla.novell.com/attachment.cgi?id=425276)
A compiled version of the test program
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.16)
Gecko/20110319 Firefox/3.6.16
Mono rejects IL generated by the F# compiler for the following code involving a
native pointer:
let test (chars: char[]) =
let handle = System.Runtime.InteropServices.GCHandle.Alloc(chars,
System.Runtime.InteropServices.GCHandleType.Pinned)
let cp = &&chars.[0]
System.Console.WriteLine(new string(cp, 0, chars.Length))
handle.Free()
test("test".ToCharArray())
The generated IL for the test functions is:
method public static void test(char[] chars) cil managed
{
.maxstack 5
.locals init (
[0] valuetype [mscorlib]System.Runtime.InteropServices.GCHandle handle,
[1] native int cp)
L_0000: nop
L_0001: ldarg.0
L_0002: ldc.i4.3
L_0003: call valuetype [mscorlib]System.Runtime.InteropServices.GCHandle
[mscorlib]System.Runtime.InteropServices.GCHandle::Alloc(object, valuetype
[mscorlib]System.Runtime.InteropServices.GCHandleType)
L_0008: stloc.0
L_0009: ldarg.0
L_000a: ldc.i4.0
L_000b: ldelema char
L_0010: stloc.1
L_0011: ldloc.1
L_0012: ldc.i4.0
L_0013: ldarg.0
L_0014: ldlen
L_0015: conv.i4
L_0016: newobj instance void [mscorlib]System.String::.ctor(char*, int32,
int32)
L_001b: call void [mscorlib]System.Console::WriteLine(string)
L_0020: ldloca.s handle
L_0022: call instance void
[mscorlib]System.Runtime.InteropServices.GCHandle::Free()
L_0027: ret
}
Mono fails with:
Unhandled Exception: System.InvalidProgramException: Invalid IL code in
Test.Test:test (char[]): IL_0010: stloc.1
This code works fine on .NET. Using a signed native int for storing a pointer
value is certainly an odd choice, but I'm not sure that the ECMA standard
prohibits this.
Reproducible: Always
Steps to Reproduce:
See details.
Actual Results:
See details.
Expected Results:
See details.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list