Bugzilla – Bug 317954
C# - C Interop callbacks crash - but works with dotgnu
Last modified: 2007-09-15 21:24:46 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".