-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
The following code hangs in SDL_QuitSubSystem
for around ~12 seconds on my machine:
#include <stdio.h>
#include <SDL.h>
int main(int, char **)
{
SDL_InitSubSystem(SDL_INIT_SENSOR);
SDL_version ver;
SDL_GetVersion(&ver);
printf("SDL Version %d.%d.%d\n", ver.major, ver.minor, ver.patch);
printf("%d sensors\n", SDL_NumSensors());
SDL_QuitSubSystem(SDL_INIT_SENSOR);
printf("OK\n");
return 0;
}
- Code prints
SDL Version 2.0.20
and2 sensors
on my machine. - Machine is a HP ProBook x360 435 G8 with 2 Sensors (Gyro+Accel), so the sensor number is correct in SDL_NumSensors()
- I'm running this unter Windows 10 using a SDL2 build from https://github.com/microsoft/vcpkg HEAD.
git rev-parse HEAD
says
ec79067966d563cc75c251db04586ead3479c99b
- Happens for x64-Debug, x64-Debug-Static and x64-Release builds.
- Code is built with Visual Studio 2022
- Apparently, the freeze happens in NtWaitForSingleObject(). Here's the call stack when I break during the freeze:
ntdll.dll!NtWaitForSingleObject()
KernelBase.dll!WaitForSingleObjectEx()
SensorsNativeApi.V2.dll!SensorStopV2_Internal(void *,unsigned char,unsigned char)
SensorsApi.dll!CSensorV2::SetEventSink(struct ISensorEvents *)
SDL2d.dll!DisconnectSensor(ISensor * sensor) Line 329
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\sensor\windows\SDL_windowssensor.c(329)
SDL2d.dll!SDL_WINDOWS_SensorQuit() Line 457
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\sensor\windows\SDL_windowssensor.c(457)
SDL2d.dll!SDL_SensorQuit() Line 463
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\sensor\SDL_sensor.c(463)
SDL2d.dll!SDL_QuitSubSystem_REAL(unsigned int flags) Line 349
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\SDL.c(349)
SDL2d.dll!SDL_QuitSubSystem(unsigned int a) Line 87
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\dynapi\SDL_dynapi_procs.h(87)
sdl2main.exe!SDL_main(int __formal, char * * __formal) Line 401
at C:\Users\nordi\source\repos\phoyd\sdl2info\sdl2mon\sdl2maintest.cc(401)
sdl2main.exe!main_getcmdline() Line 82
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\main\windows\SDL_windows_main.c(82)
sdl2main.exe!main(int argc, char * * argv) Line 98
at C:\Users\nordi\source\repos\phoyd\sdl2info\extern\vcpkg\buildtrees\sdl2\src\ase-2.0.20-4d7f28b96f.clean\src\main\windows\SDL_windows_main.c(98)
sdl2main.exe!invoke_main() Line 79
at d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79)
sdl2main.exe!__scrt_common_main_seh() Line 288
at d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
sdl2main.exe!__scrt_common_main() Line 331
at d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
sdl2main.exe!mainCRTStartup(void * __formal) Line 17
at d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
DisconnectSensor
is where SDL2 calls into Sensors.Api.dll
. That's here:
SDL_LockSensors();
for (i = 0; i < SDL_num_sensors; ++i) {
old_sensor = &SDL_sensors[i];
if (sensor == old_sensor->sensor) {
ISensor_SetEventSink(sensor, NULL); <-- hangs here.
ISensor_Release(sensor);
SDL_free(old_sensor->name);
--SDL_num_sensors;
if (i < SDL_num_sensors) {
- If I remove the
SDL_NumSensors()
call, then the code runs normally. - I did not check yet, if you actually need a machine with sensors to reproduce the problem.
Metadata
Metadata
Assignees
Labels
No labels