Bug 317954 (MONO74909) - C# - C Interop callbacks crash - but works with dotgnu
Summary: C# - C Interop callbacks crash - but works with dotgnu
Status: RESOLVED INVALID
Alias: MONO74909
Product: Mono: Runtime
Classification: Mono
Component: interop (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: interop
Depends on:
Blocks:
 
Reported: 2005-05-11 17:23 UTC by Kirk Abbott
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:16:35 UTC


---- Reported by abbottkirk@yahoo.com 2005-05-11 10:23:18 MST ----

Please fill in this template when reporting a bug, unless you know what you
are doing.
Description of Problem:
I have some C# - C interop callbacks using both PInvoke and unsafe
pointers. I can crashes which don't happen under Visual.net or
under Dotgnu. I have a small example and Makefile that i can submit.
The callbacks are implemented in C# and 'registered' with some unmanaged
C-code.

Steps to reproduce the problem:
1. Compile & run
2. 
3. 

Actual Results:
Starting...
N = 5
M = 2
NNZ = 10
NLB = 5
N = 4
Iterating in IpoptLink.c.iterate()

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
   at IpOptClient.Model.OnEvalG(Int32 n, Double* pX, Double* pG, Double*
pDat, I
nt32* pIdat)
   at IpOptClient.IpoptDriver.OPTIMIZE(Int32& N, Int32& M, Int32& NNZ,
Int32& NL
B, Int32& NUB, Double* X, Int32* ILB, Double* BNDS_L, Int32* IUB, Double*
BNDS_U
, EvalFDelegate EV_F, EvalGDelegate EV_G, Double& fObj)
   at IpOptClient.Model.doit()
   at IpOptClient.IpoptDriver.Main(String[] args)


Expected Results:
Starting...
N = 5
M = 2
NNZ = 10
NLB = 5
N = 4
Iterating in IpoptLink.c.iterate()
g[0] = 12
g[1] = 1
g[2] = 3.3
g[3] = 11
g[4] = 0


How often does this happen? 
Every run

Additional Information:
I have a small zip file that is configured to run either
under MONO and DOTGNU that can be used to replicate the problem.



---- Additional Comments From vargaz@gmail.com 2005-05-11 10:33:03 MST ----

Please attach your testcase to the bug report.




---- Additional Comments From vargaz@gmail.com 2005-05-12 07:08:13 MST ----

delegates called from unmanaged code use the stdcall calling convention,
so the unmanaged function pointers must use them too, i.e.

void (JNICALL * evalF)(int n, double* pX, double* f, double* pDat,
int* pIdat);

void (JNICALL * evalG)(int n, double* pX, double* pG, double* pDat,
int* pIdat);



---- Additional Comments From jonpryor@vt.edu 2005-05-12 08:14:44 MST ----

Is the stdcall calling convention required on Linux now as well?  Or
is it Win32-only?

If stdcall is required on Linux, this change breaks
Mono.Unix.Stdlib.signal, which needs a cdecl calling convention for
signal(3).


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Windows Cygwin</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".