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