[Mono-bugs] [Bug 43074][Nor] Changed - unmanaged function returns wrong value

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Sun, 18 May 2003 13:13:22 -0400 (EDT)


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 pigolkine@gmx.de.

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

--- shadow/43074	Thu May 15 10:39:04 2003
+++ shadow/43074.tmp.5471	Sun May 18 13:13:22 2003
@@ -1,14 +1,14 @@
 Bug#: 43074
 Product: Mono/Runtime
 Version: unspecified
-OS: 
+OS: unknown
 OS Details: Window 2000
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Normal
 Component: misc
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: ryabchuk@yahoo.com               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
@@ -78,6 +78,77 @@
 output, which is correct:
 
 res = 0
 
 How often does this happen? 
 always
+
+------- Additional Comments From pigolkine@gmx.de  2003-05-18 13:13 -------
+I tried to investigate this problem a little.
+May be this can help to resolve it.
+
+IMHO, the problem is connected to calling convention.
+Method in native DLL uses StdCall, but calling code was
+generated with cdecl:
+
+(gdb) where
+#0  0x01561007 in dlltest!_createWindow@20 ()
+#1  0x0109235f in ?? ()
+#2  0x0109243c in ?? ()
+#3  0x010922be in ?? ()
+#4  0x0041ba9b in mono_jit_runtime_invoke (method=0x105f2d0, 
+obj=0x0, params=0x155fee4, exc=0x0) at mini.c:6113
+#5  0x004255a3 in mono_runtime_invoke (method=0x105f2d0, obj=0x0, 
+params=0x155fee4, exc=0x0) at object.c:659
+#6  0x0042629f in mono_runtime_exec_main (method=0x105f2d0, 
+args=0xdf6fa8, exc=0x0) at object.c:1015
+#7  0x00425e27 in mono_runtime_run_main (method=0x105f2d0, argc=1, 
+argv=0xda4110, exc=0x0) at object.c:885
+#8  0x00402658 in mono_jit_exec (domain=0xdf2f78, 
+assembly=0x105f410, argc=1, argv=0xda410c) at driver.c:436
+#9  0x0040273e in main_thread_handler (user_data=0x22ff30) at 
+driver.c:463
+#10 0x00485c9d in start_wrapper (data=0x10a0fe8) at threads.c:197
+#11 0x77e5d33b in RegisterWaitForInputIdle () 
+from /cygdrive/d/WINDOWS/system32/kernel32.dll
+
+
+0x01561000 <dlltest!_createWindow@20+0>:        push   %ebp
+0x01561001 <dlltest!_createWindow@20+1>:        mov    %esp,%ebp
+0x01561003 <dlltest!_createWindow@20+3>:        push   %ebx
+0x01561004 <dlltest!_createWindow@20+4>:        push   %esi
+0x01561005 <dlltest!_createWindow@20+5>:        push   %edi
+0x01561006 <dlltest!_createWindow@20+6>:        int3
+0x01561007 <dlltest!_createWindow@20+7>:        xor    %eax,%eax
+0x01561009 <dlltest!_createWindow@20+9>:        pop    %edi
+0x0156100a <dlltest!_createWindow@20+10>:       pop    %esi
+0x0156100b <dlltest!_createWindow@20+11>:       pop    %ebx
+0x0156100c <dlltest!_createWindow@20+12>:       pop    %ebp
+0x0156100d <dlltest!_createWindow@20+13>:       ret    $0x14
+
+0x0109232e		call   0xda88f8
+0x01092333		add    $0x4,%esp
+0x01092336		mov    %eax,%esi
+0x01092338		mov    %eax,0xffffffc8(%ebp)
+0x0109233b		pushl  0x10(%ebp)
+0x0109233e		call   0xda88f8
+0x01092343		add    $0x4,%esp
+0x01092346		mov    %eax,0xffffffc4(%ebp)
+0x01092349		mov    %eax,%esi
+0x0109234b		pushl  0x18(%ebp)
+0x0109234e		pushl  0x14(%ebp)
+0x01092351		push   %esi
+0x01092352		pushl  0xffffffc8(%ebp)
+0x01092355		pushl  0x8(%ebp)
+0x01092358		mov    $0x1561000,%eax
+0x0109235d		call   *%eax
+0x0109235f		add    $0x14,%esp
+
+calling code cleans stack one more time here
+
+0x01092362		mov    %eax,0xffffffc0(%ebp)
+0x01092365		mov    %eax,0xffffffcc(%ebp)
+0x01092368		pushl  0xffffffc8(%ebp)
+0x0109236b		call   0x103c4a0
+
+
+Alexandre Pigolkine