author Sam Lantinga <>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 5409 30205e106bba
child 7222 2435b221d77d
permissions -rwxr-xr-x
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 #!/bin/sh
     2 #
     3 echo "Generating build information using autoconf"
     4 echo "This may take a while ..."
     6 # Regenerate configuration files
     7 cat acinclude/* >aclocal.m4
     8 found=false
     9 for autoconf in autoconf autoconf259 autoconf-2.59
    10 do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi
    11 done
    12 if test x$found = xfalse; then
    13     echo "Couldn't find autoconf, aborting"
    14     exit 1
    15 fi
    16 (cd test; sh
    18 # Run configure for this platform
    19 echo "Now you are ready to run ./configure"