[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 Walter Bright bugzi...@digitalmars.com changed: What|Removed |Added Status|NEW |RESOLVED CC||bugzi...@digitalmars.com Resolution||INVALID --- Comment #4 from Walter Bright bugzi...@digitalmars.com 2011-02-17 13:23:59 PST --- This is a misunderstanding of the calling conventions. Examination of the asm produced by the compiler shows that, indeed, EBX is preserved across all three functions. However, the compiler is not obliged to preserve the contents of EBX from statement to statement within a function, which is what your code is expecting. This is not a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 --- Comment #5 from hypothermia.fr...@gmail.com 2011-02-17 13:53:00 PST --- Ok, but as I said earlier this bug happened to me when the pointer call happened in a member function call. The EBX register contained a 'this' pointer and the compiler used it to load the function pointer. But after calling this function pointer the compiler still thought EBX contained 'this' and I got an Access Violation exception thrown when I tried to access a field from 'this'. I saw this all using debugger and I traced the EBX change to the call of the function pointer. And then how is this not a bug If the compiler thinks that after using the EBX register, It has a value from previous use? Maybe Its hard for you to understand what I'm trying to explain, but I will try to make an example code to prove my point. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 --- Comment #6 from Walter Bright bugzi...@digitalmars.com 2011-02-17 14:08:30 PST --- If you can post a complete code snippet, and the obj2asm output of the asm produced, that shows that EBX is not preserved across function calls, I can fix it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 hypothermia.fr...@gmail.com changed: What|Removed |Added Severity|major |critical --- Comment #2 from hypothermia.fr...@gmail.com 2011-02-16 12:10:39 PST --- After disassembly I found out that this code was generated(no -O switch): //asm { mov EBX,3; } bar(4); mov ebx, 3 push4 mov ebx, large fs:2Ch mov esi, [ebx] calldword ptr [esi+4F4h] mov [ebp+var_20], ebx //the next round ecx is used... //asm { mov EBX,5; } bar(6); mov ebx, 5 push6 mov ecx, large fs:2Ch mov edx, [ecx] calldword ptr [edx+4F4h] mov [ebp+var_20], ebx Why is DMD not preserving the EBX register in the first call? The worst thing is that the compiler doesn't even know tha there's something in EBX... This problem happened to me with when EBX had a this pointer and then DMD didn't save it and after the function pointer call I got an exception! I think this is a serious issue and should be looked at ASAP. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 Don clugd...@yahoo.com.au changed: What|Removed |Added Keywords||wrong-code CC||clugd...@yahoo.com.au --- Comment #3 from Don clugd...@yahoo.com.au 2011-02-16 12:22:07 PST --- Top priority for this one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 5591] EBX register not preserved when calling stdcall function pointer
http://d.puremagic.com/issues/show_bug.cgi?id=5591 --- Comment #1 from hypothermia.fr...@gmail.com 2011-02-15 09:23:06 PST --- After doing some more tests I found out that if you compile with -O switch, the code behaves as expected and output is: foo (EBX = 1,2) EBX(after foo) = 1 foo (EBX = 3,4) EBX(after bar) = 3 ... Looks like it's a bug in DMD code gen without the -O switch. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---