We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2833 - Access Violation on SDL_PollEvent after init, delay and quit of joystick subsystem
Summary: Access Violation on SDL_PollEvent after init, delay and quit of joystick subs...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: 2.0.3
Hardware: x86_64 Windows 7
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-05 22:59 UTC by Jan Klass
Modified: 2016-10-07 23:33 UTC (History)
1 user (show)

See Also:


Attachments
Minimal program for reproducability - leads to access violation (746 bytes, text/plain)
2015-01-05 22:59 UTC, Jan Klass
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Klass 2015-01-05 22:59:20 UTC
Created attachment 1983 [details]
Minimal program for reproducability - leads to access violation

Not sure if this is limited to the joystick subsystem,
but I created a minimal program for reproducibility,
which is attached.

The issue occurs with my gamepad Razer Onza (an xbox-style gamepad) plugged in.
On initialization, the gamepad is being recognized.
After quitting the subsystem, the poll will receive the joystick added event,
which it instantly handles itself, calling SDL_SYS_JoystickDetect again,
which this time calls IDirectInput8_EnumDevices with dinput = NULL (after it was released on quit).
This seems to lead to an access violation within said function, which I have no source for.

The issue was originally noticed on ET:Legacy, after its switch from SDL1 to SDL2 (2.71 RC4 to 2.71a).
The issue I reported is available at
http://dev.etlegacy.com/issues/757
and also includes stack traces of the issue there.

However, for reproducibility and program flow,
the attached example is probably easier to work with.
The issue only occurs with the delay before the subsystem quit call.
Comment 1 Jan Klass 2015-01-05 23:02:13 UTC
I tested this with ET:Ls lib repository 2.0.3 version of SDL
(binaries)
https://github.com/etlegacy/etlegacy-libs/tree/master/sdl2-windows
a self-compiled debug version of 2.0.3 also from their source
https://github.com/etlegacy/etlegacy-libs/tree/master/sdl2

and then downloaded and compiled from HG 817656bd36ec from http://hg.libsdl.org/SDL

The issue occurred in all three occasions.
Comment 2 Sam Lantinga 2016-10-07 23:33:19 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/aa816d06ed78