Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No _chkstk implementation #1067

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

No _chkstk implementation #1067

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.0
Reported for operating system, platform: Windows (All), x86

Comments on the original bug report:

On 2013-09-05 10:25:56 +0000, wrote:

On Windows, if SDL is compiled targeting x86 and without a C runtime library the SDL_stlib.c defines a _chkstk symbol, but there are no actual instructions for this function.

This is not a problem if SDL is compiled as a dynamic library as it doesn't seem to generate any _chkstk calls. However, people want to link it statically now and their code might generate those calls which will cause the application to terminate pretty fast.

I would recommend everyone to compile SDL 2.0.0 with HAVE_LIBC defined and the Visual C++ runtime library when using MSVC and linking SDL statically on Windows x86.

Writing an actual implementation probably requires some knowledge about the Microsoft implementation. Copying theirs obviously has licensing issues.

Here's the disassembly that shows the issue in code form.

--- src\stdlib\sdl_stdlib.c -----------------------
SDL_toupper:
mov eax,dword ptr [esp+4]
lea ecx,[eax-61h]
cmp ecx,19h
ja SDL_toupper+0Fh (0CC15DFh)
add eax,0FFFFFFE0h
ret
SDL_tolower:
mov eax,dword ptr [esp+4]
lea ecx,[eax-41h]
cmp ecx,19h
ja SDL_tolower+0Fh (0CC15EFh)
add eax,20h
ret
_chkstk:
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
int 3
_ftol:
push ebp
mov ebp,esp
sub esp,20h
and esp,0FFFFFFF0h
fld st(0)
fst dword ptr [esp+18h]
fistp qword ptr [esp+10h]

On 2013-09-23 18:30:53 +0000, CD-i Fan wrote:

If you define HAVE_LIBC, SDL_stdlib.c will not define a _chkstk symbol.

On 2013-09-28 06:12:38 +0000, Sam Lantinga wrote:

Yes, if you compile it as a static library, you should compile with HAVE_LIBC defined.

Thanks!

On 2013-09-28 07:34:07 +0000, wrote:

And for the case where SDL is a DLL and has no VC++ runtime library? Are the SDL developers just going to be very careful to write code that never emits _chkstk calls? I guess it works with the current version. I'm just worried that this is going to be really annoying for someone in the future.

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant