| Summary: | _allmul implementation in SDL_stdlib.c doesn't clean up the stack | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Colin Barrett <barrettcolin+libsdl> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
| See Also: |
http://bugzilla.libsdl.org/show_bug.cgi?id=1619 http://bugzilla.libsdl.org/show_bug.cgi?id=1307 |
||
| Attachments: | CMakeLists.txt and SDL_config.h from my VS2012 build | ||
Created attachment 1138 [details]
CMakeLists.txt and SDL_config.h from my VS2012 build
Nice catch, thanks! http://hg.libsdl.org/SDL/rev/3733e68edbc3 |
I see this manifest itself (VS2012 x86) as: "Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention." in the first call to SDL_GetTicks in my application. The disassembly at the problem line is: hires_now.QuadPart *= 1000; 00AD0792 push 0 00AD0794 push 3E8h 00AD0799 mov eax,dword ptr [ebp-10h] 00AD079C push eax 00AD079D mov ecx,dword ptr [hires_now] 00AD07A0 push ecx 00AD07A1 call _allmul (0AE7D40h) 00AD07A6 mov dword ptr [hires_now],eax 00AD07A9 mov dword ptr [ebp-10h],edx Apparently _allmul should be popping the stack but isn't (other similar functions in SDL_stdlib.c - _alldiv and whatnot - DO pop the stack). A 'ret 10h' at the end of _allmul appears to do the trick: diff -r f7fc1f0c3a08 src/stdlib/SDL_stdlib.c --- a/src/stdlib/SDL_stdlib.c Fri May 10 21:19:40 2013 +0200 +++ b/src/stdlib/SDL_stdlib.c Sat May 11 22:18:40 2013 +0100 @@ -191,7 +191,7 @@ pop esi pop edi pop ebp - ret + ret 10h } /* *INDENT-ON* */ }