[GD-Windows] Strange prolog function issue
Brought to you by:
vexxed72
From: Emmanuel A. <e_a...@ya...> - 2006-07-25 10:09:06
|
Hi all, I have here a very strange issue. We have a function using a local std::string, exceptions, and a alloca. When the exception is thrown, the unwind mecanism tries to delete the std::string, but it deletes it at a wrong address( there is a 0x590 offset ). We debugged this problem for two days, and it only happens when the alloca is present. In this case, the prolog of the function is of this type : 00F60F00 push ebp 00F60F01 lea ebp,[esp-590h] ***** NOTICE THE STRANGE EBP VALUE HERE 00F60F08 push 0FFFFFFFFh 00F60F0A push offset __ehhandler$?CompileOneVariableDeclaration@AIE_cl_Compiler@@AAEXXZ (139B888h) 00F60F0F mov eax,dword ptr fs:[00000000h] 00F60F15 push eax 00F60F16 mov dword ptr fs:[0],esp 00F60F1D sub esp,5ECh 00F60F23 mov eax,dword ptr [___security_cookie (16A1EECh)] 00F60F28 push ebx 00F60F29 push esi 00F60F2A mov dword ptr [ebp+580h],eax 00F60F30 push edi 00F60F31 mov ebx,ecx As without the alloca, the prolog is like : 00402580 push ebp 00402581 mov ebp,esp *********** HERE, AS ALWAYS, EBP IS SET TO ESP 00402583 push 0FFFFFFFFh 00402585 push offset __ehhandler$?MyFunc@@YAXXZ (420738h) 0040258A mov eax,dword ptr fs:[00000000h] 00402590 push eax 00402591 mov dword ptr fs:[0],esp 00402598 sub esp,34h 0040259B mov eax,dword ptr [___security_cookie (429608h)] 004025A0 push ebx 004025A1 push esi 004025A2 mov dword ptr [ebp-10h],eax 004025A5 push edi Note that in our crashing case, ebp is set to esp - 590 ( the offset value ), and that in the other case, it is just set to esp. I could not reproduce this ebp offset that makes the exception handler fail in a small sample. So do you know in which case the compiler does not put esp in ebp, but put an offset in it ? And do you know how to fix it ( other than what we're doing : stopping using alloca with exceptions ), if it is a kind a known issue ? Thanks for any help, Emmanuel |