author Sam Lantinga <>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 6674 45a21e50ba5e
permissions -rw-r--r--
Fixed bug 1846 - _allmul implementation in SDL_stdlib.c doesn't clean up the stack

Colin Barrett

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
     1 ================================================================================
     2 CMake build system for SDL (
     3 ================================================================================
     5 SDL's build system was traditionally based on autotools. Over time, this
     6 approach has suffered from several issues across the different supported 
     7 platforms.
     8 To solve these problems, a new build system based on CMake is under development.
     9 It works in parallel to the legacy system, so users can experiment with it
    10 without complication.
    11 While still experimental, the build system should be usable on the following
    12 platforms:
    14     * FreeBSD
    15     * Linux
    16     * VS.NET 2010
    17     * MinGW and Msys
    18     * OS X with support for XCode
    20 ================================================================================
    21 Usage
    22 ================================================================================
    24 Assuming the source for SDL is located at ~/sdl
    26 cd ~
    27 mkdir build
    28 cd build
    29 cmake ../sdl
    31 This will build the static and dynamic versions of SDL in the ~/build directory.