Skip to content

Fix GameInputInitialize crash on 32bit builds - #16582

Merged
slouken merged 2 commits into
libsdl-org:mainfrom
SquareMan:gameinputfix
Oct 24, 2026
Merged

slouken merged 2 commits into
libsdl-org:mainfrom
SquareMan:gameinputfix

Conversation

@SquareMan

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

I'm working on a PC port project that currently still has to be built for 32-bit.

I recently started getting a crash on initialization during gamepad initialization which I tracked to the GAMEINPUT joystick driver. (I had no issues for a while so my best explanation for now is that the feature must have recently started becoming enabled after a windows update or something 🤷) The crash was crashing with an "Access Violation executing location ..." error, pointing to stack corruption. After stepping through the code I found the issue occured after calling into GameInputInitialize.

GameInputIntiailize is an STDAPI function (source) which uses a __stdcall convention. It seems that on 64 bit __stdcall is ignored but on 32 bit the default calling convention is __cdecl, which might explain why this went unoticed this long. This results in the stack getting corrupted and GameInputCreateWithVersion returns to a garbage address.

Existing Issue(s)

N/A

GameInputIntiailize is an STDAPI function, which uses a __stdcall
convention. On 64 bit __stdcall is ignored but on 32 bit the
default calling convention is __cdecl. This results in the stack getting
corrupted and GameInputCreateWithVersion returns to a garbage address.
Comment thread src/core/windows/gameinput/gameinput.cpp Outdated
@slouken
slouken merged commit 8b6d969 into libsdl-org:main Oct 24, 2026
@slouken slouken added this to the 3.6.0 milestone Oct 24, 2026
@slouken

slouken commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants