.DISABLED-hgeol
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 5055 2936fc46b015
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 [patterns]
     2 .hgeol = native
     3 .hgignore = native
     4 BUGS = native
     5 CREDITS = native
     6 INSTALL = native
     7 NOTES = native
     8 TODO = native
     9 WhatsNew = native
    10 **COPYING = native
    11 **README = native
    12 **doxyfile = native
    13 **Doxyfile = native
    14 **install-sh = LF
    15 **mkinstalldirs = LF
    16 **Makefile = LF
    17 **Makefile.* = LF
    18 test/automated/rwops/read = LF
    19 **README.* = native
    20 **.S = native
    21 **.bmp = BIN
    22 **.c = native
    23 **.cc = native
    24 **.cpp = native
    25 **.csh = LF
    26 **.dat = BIN
    27 **.gdbinit = LF
    28 build-scripts/config.guess = LF
    29 **.h = native
    30 **.htm = native
    31 **.html = native
    32 **.icns = BIN
    33 **.in = LF
    34 **.java = native
    35 **.m = native
    36 **.m4 = native
    37 **.mk = LF
    38 **.nib = BIN
    39 **.pch = BIN
    40 **.pdf = BIN
    41 **.pl = native
    42 **.plist = native
    43 **.png = BIN
    44 .indent.pro = LF
    45 **.rc = native
    46 **.rtf = BIN
    47 **.sh = LF
    48 **.sln = native
    49 **.txt = native
    50 **.vcp = native
    51 **.vcproj = native
    52 **.vcw = native
    53 **.vcxproj = native
    54 **.wav = BIN
    55 **.xbm = BIN
    56 **.xml = native
    57 **.zip = BIN