[Mono-bugs] [Bug 487758] New: Marshaling a native function pointer to native function call throws assertion
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Mar 23 09:54:14 EDT 2009
https://bugzilla.novell.com/show_bug.cgi?id=487758
Summary: Marshaling a native function pointer to native
function call throws assertion
Classification: Mono
Product: Mono: Runtime
Version: 2.2.x
Platform: 32bit
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: interop
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: bhenderson at ipswitch.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Created an attachment (id=281198)
--> (https://bugzilla.novell.com/attachment.cgi?id=281198)
VS2008 project that builds testdll.dll and FunctionPointerInterop.exe
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4)
Gecko/2008112016 Firefox/3.0.4 Flock/2.0.2
When trying to marshal a native function pointer to a native function call, the
following assertion is thrown:
**
ERROR:marshal.c:9235:mono_marshal_get_managed_wrapper: assertion failed:
(!mono_
method_signature (method)->pinvoke)
I have been able to work around the issue by providing a Managed delegate as
the parameter, and then calling the un-managed code from the managed delegate.
But, it would be nice to have support for passing the native pointer rather
than forcing the native to un-managed callback.
I have only tested this on Windows XP, Ubuntu 8.10, and OpenSuse 11 (32-bit),
as these are the only platforms I have up and running at the moment.
Reproducible: Always
Steps to Reproduce:
1. Create a shared library that exports 2 functions.
#include <stdio.h>
extern "C" void TESTDLL_EXPORT foo()
{
printf("foo!\n");
}
extern "C" void TESTDLL_EXPORT bar(void (*fn)(void))
{
if (fn)
{
fn();
}
}
2. Implement C# code to import the methods via DllImport, create a delegate
that wraps the native "foo" method, and call the "bar" method with the
delegate.
[DllImport("testdll.dll")]
public extern static void foo();
[DllImport("testdll.dll")]
public extern static void bar(foo_delegate foo);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void foo_delegate();
static foo_delegate my_foo_delegate;
public static void Start()
{
// Create delegate with native pointer
my_foo_delegate = new foo_delegate(foo);
bar(my_foo_delegate);
}
Actual Results:
**
ERROR:marshal.c:9235:mono_marshal_get_managed_wrapper: assertion failed:
(!mono_
method_signature (method)->pinvoke)
Expected Results:
Expected the native function pointer to be passed, and the output of "foo!" to
the console from the native method.
The attached project is a VS2008 project that builds the native dll
(testdll.dll) and the C# sample application (FunctionPointerInterop.exe) in the
FunctionPointerInterop/bin/debug directory.
The sample contains a Workaround class (the workaround mentioned above), and a
Bug class that demonstrates the defect.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list