author Sam Lantinga <>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 7011 82bbfbbc720e
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
     2 Simple DirectMedia Layer CREDITS
     3 Thanks to everyone who made this possible, including:
     5 * Cliff Matthews, for giving me a reason to start this project. :)
     6  -- Executor rocks!  *grin*
     8 * The Linux Fund, C Magazine, Educational Technology Resources Inc.,
     9   Gareth Noyce, Jesse Pavel, Keith Kitchin, Jeremy Horvath, Thomas Nicholson,
    10   Hans-Peter Gygax, the Eternal Lands Development Team, Lars Brubaker,
    11   and Phoenix Kokido for financial contributions
    13 * Edgar "bobbens" Simo for his force feedback API development during the
    14   Google Summer of Code 2008
    16 * Aaron Wishnick for his work on audio resampling and pitch shifting during
    17   the Google Summer of Code 2008
    19 * Holmes Futrell for port of SDL to the iPhone and iPod Touch during the
    20   Google Summer of Code 2008
    22 * Szymon "Wilku" Wilczek for adding support for multiple mice and tablets
    23   during the Google Summer of Code 2008
    25 * Marty Leisner, Andrew, Will, Edgar Simo, Donny Viszneki, Andrea Mazzoleni,
    26   Dmytro Bogovych, and Couriersud for helping find SDL 1.3 bugs in the great
    27   SDL Bug Hunt of January 2009!
    29 * Donny Viszneki for helping fix SDL 1.3 bugs in the great SDL Bug Hunt of
    30   January 2009!
    32 * Luke Benstead for OpenGL 3.0 support
    34 * Gaëtan de Menten for writing the PHP and SQL behind the SDL website
    36 * Tim Jones for the new look of the SDL website
    38 * Ryan Gordon for helping everybody out and keeping the dream alive. :)
    40 * Mattias Engdegård, for help with the Solaris port and lots of other help
    42 * Eric Wing, Max Horn, and Darrell Walisser for unflagging work on the Mac OS X port
    44 * David Carré, for the Pandora port
    46 * Couriersud for the DirectFB driver
    48 * Jon Atkins for SDL_image, SDL_mixer and SDL_net documentation
    50 * Arne Claus, for the 2004 winning SDL logo,
    51   and Shandy Brown, Jac, Alex Lyman, Mikkel Gjoel, #Guy, Jonas Hartmann,
    52   Daniel Liljeberg,  Ronald Sowa, DocD, Pekka Jaervinen, Patrick Avella,
    53   Erkki Kontilla, Levon Gavalian, Hal Emerich, David Wiktorsson,
    54   S. Schury and F. Hufsky, Ciska de Ruyver, Shredweat, Tyler Montbriand,
    55   Martin Andersson, Merlyn Wysard, Fernando Ibanez, David Miller,
    56   Andre Bommele,, Francisco Camenforte Torres, and David Igreja
    57   for other logo entries.
    59 * Bob Pendleton and David Olofson for being long time contributors to
    60   the SDL mailing list.
    62 * Everybody at Loki Software, Inc. for their great contributions!
    64  And a big hand to everyone else who gave me appreciation, advice,
    65  and suggestions, especially the good folks on the SDL mailing list.
    67 THANKS! :)
    69   -- Sam Lantinga			<>