README
author Sam Lantinga <slouken@libsdl.org>
Thu, 16 May 2013 00:43:22 -0700
changeset 7180 3733e68edbc3
parent 6987 7084af936d82
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                          Simple DirectMedia Layer
     3 
     4                                   (SDL)
     5 
     6                                 Version 2.0
     7 
     8 ---
     9 http://www.libsdl.org/
    10 
    11 This is the Simple DirectMedia Layer, a general API that provides low
    12 level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
    13 and 2D framebuffer across multiple platforms.
    14 
    15 The current version supports Windows, Mac OS X, Linux, FreeBSD,
    16 NetBSD, OpenBSD, BSD/OS, Solaris, iOS, and Android. The code contains
    17 support for other operating systems but those are not officially supported.
    18 
    19 SDL is written in C, but works with C++ natively, and has bindings to
    20 several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
    21 Go, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
    22 Pike, Pliant, Python, Ruby, and Smalltalk.
    23 
    24 This library is distributed under the zlib license, which can be found
    25 in the file "COPYING".
    26 
    27 The best way to learn how to use SDL is to check out the header files in
    28 the "include" subdirectory and the programs in the "test" subdirectory.
    29 The header files and test programs are well commented and always up to date.
    30 More documentation and FAQs are available online at:
    31 	http://wiki.libsdl.org/
    32 
    33 If you need help with the library, or just want to discuss SDL related
    34 issues, you can join the developers mailing list:
    35 	http://www.libsdl.org/mailing-list.php
    36 
    37 Enjoy!
    38 	Sam Lantinga				(slouken@libsdl.org)
    39