Hi all, I started using SDL2 a few months for a game project and it was working great, but when I started working with a renderer, the SDL_CreateRenderer() kept hanging the code when I called it. After a few attempts, I managed to have it running by setting the driver index specifically to 4 (-1 also hung). Not ideal, but at least it went through.
Now, a month later of development, I plug a new drawing tablet on my computer, and once I finished playing with it, I come back to my code, and now the SDL_CreateWindow() hangs, and this time no way to recover it.
I’ve tried rebooting, unplugging everything, tried two different versions of SDL2 (2.30.6 and 2.0.18), and this issue does not seem to happen with the same code on my Linux machine.
What could cause this hanging and how can I prevent it?
What’s the call stack when it’s hanging?
Hi slouken, thanks a lot for answering me, sorry for answering so late myself as I was out of town without my gear this weekend.
I actually found the setup cause of my issue with SDL_CreateWindow() hanging, I did not realize I still had the USB port of the drawing tablet in, as there is also an HDMI cable connected to it. When I unplugged the USB cable, my application could start correctly without hanging. However, if the tablet is plugged, the application hangs again at boot. Here’s the model of the tablet: GAOMON PD1161 11.6 Inches Portable Drawing Tablet with Stylus Pen
Here is the call stack when plugged (and hanging):
0x0000000000000000
!ZwWaitForMultipleObjects+0x14
!WaitForMultipleObjectsEx+0xe9
!RegisterHandwritingInputRoutingCallback+0x1a690
!RegisterHandwritingInputRoutingCallback+0x1f6cc
!RegisterHandwritingInputRoutingCallback+0x1db9d
!RegisterHandwritingInputRoutingCallback+0x1116d
!RegisterHandwritingInputRoutingCallback+0xaef3
!CtfImeDestroyThreadMgr+0x231a
!CtfImeDestroyThreadMgr+0x1aa7
!WindowsStringHasEmbeddedNull+0x315d
!WindowsStringHasEmbeddedNull+0x167c
!WindowsStringHasEmbeddedNull+0x374c
!Ordinal140+0x2a8
!CoEnableCallCancellation+0x150c
!HSTRING_UserMarshal+0x572
!Ordinal140+0x4b4
!WindowsStringHasEmbeddedNull+0x167c
!CoWaitForMultipleHandles+0x36b8
!WindowsStringHasEmbeddedNull+0x167c
!CoCreateInstance+0xd51
!CoCreateInstance+0x33e
!CoCreateInstance+0x14c
!SDL_DYNAPI_entry+0xf4c6f
!SDL_DYNAPI_entry+0xf0cf8
!SDL_DYNAPI_entry+0xf14a3
!DispatchMessageW+0x741
!DispatchMessageW+0x3fc
!GetClassLongW+0x58d
!KiUserCallbackDispatcher+0x24
!NtUserShowWindow+0x14
!SDL_DYNAPI_entry+0xbf7fe
!SDL_DYNAPI_entry+0xc1ad0
!PyInit_media_engine+0x1fe8
0x0000000000000000
!initterm+0x2d
0x0000000000000000
!RtlActivateActivationContextUnsafeFast+0x12f
!RtlEnumerateEntryHashTable+0x3bd
!RtlEnumerateEntryHashTable+0x16e
!RtlCopyUnicodeString+0x50d
!RtlImageRvaToSection+0x250
!RtlUnicodeToCustomCPN+0x3fc
!LdrLoadDll+0xfa
!LoadLibraryExW+0x172
!Py_fopen_obj+0x88a
!Py_fopen_obj+0x414
!Py_fopen_obj+0x659
!Py_fopen_obj+0x5ad
!PyObject_GetBuffer+0x1076
!PyVectorcall_Call+0x5c
!PyObject_Call+0x4f
!PyObject_Call+0x187
!PyEval_EvalFrameDefault+0x5d75
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x1eb3
!PyEval_EvalFrameDefault+0xf64
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x70e
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x70e
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x70e
!PyFunction_Vectorcall+0x87
!PyObject_CallFunction+0x565
!PyObject_CallMethodIdObjArgs+0x137
!PyObject_CallMethodIdObjArgs+0x70
!PyThread_free_lock+0x36d
!PyImport_ImportModuleLevelObject+0x369
!PyMem_Strdup+0x35a
!PyEval_EvalFrameDefault+0x7cf2
!PyEval_EvalCode+0xf9
!PyDict_Keys+0x66b
!PyArg_CheckPositional+0x4d1
!PyEval_EvalFrameDefault+0x70e
!PyEval_EvalCode+0xf9
!PyEval_EvalCode+0x82
!PyArena_New+0x427
!PyArena_New+0x327
!PyObject_GetBuffer+0x1076
!PyVectorcall_Call+0x5c
!PyObject_Call+0x4f
!PyObject_Call+0x187
!PyEval_EvalFrameDefault+0x5d75
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x1eb3
!PyEval_EvalFrameDefault+0xf64
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x70e
!PyFunction_Vectorcall+0x87
!PyEval_EvalFrameDefault+0x70e
!PyFunction_Vectorcall+0x87
!PyObject_CallFunction+0x565
!PyObject_CallMethodIdObjArgs+0x137
!PyObject_CallMethodIdObjArgs+0x70
!PyThread_free_lock+0x36d
!PyImport_ImportModuleLevelObject+0x369
!PyMem_Strdup+0x35a
!PyEval_EvalFrameDefault+0x7cf2
!PyEval_EvalCode+0xf9
Here is the call stack when unplugged (and running):
0x0000000000000000
SDL2.dll!SDL_DYNAPI_entry+0x8b02c
SDL2.dll!SDL_DYNAPI_entry+0x7916d
SDL2.dll!SDL_DYNAPI_entry+0xb8241
SDL2.dll!SDL_DYNAPI_entry+0x5d12d
SDL2.dll!SDL_DYNAPI_entry+0x1e254
SDL2.dll!SDL_DYNAPI_entry+0x2931f
media_engine.cp310-win_amd64.pyd!PyInit_media_engine+0x3a2b
python310.dll!PyObject_GC_Malloc+0x2de
python310.dll!PyEval_EvalFrameDefault+0x1eb3
python310.dll!PyEval_EvalFrameDefault+0xf64
python310.dll!PyFunction_Vectorcall+0x87
python310.dll!PyVectorcall_Call+0x5c
python310.dll!PyObject_Call+0x143
python310.dll!PyEval_EvalFrameDefault+0x5d75
python310.dll!PyEval_EvalFrameDefault+0xf64
python310.dll!PyFunction_Vectorcall+0x87
python310.dll!PyEval_EvalFrameDefault+0x70e
python310.dll!PyEval_EvalCode+0xf9
python310.dll!PyEval_EvalCode+0x82
python310.dll!PyArena_New+0x18a
python310.dll!PyArena_New+0x10a
python310.dll!PyRun_SimpleFileObject+0x370
python310.dll!PyRun_SimpleFileObject+0x11d
python310.dll!PyRun_AnyFileObject+0x54
python310.dll!PyList_GetItem+0x1f7
python310.dll!PyList_GetItem+0xb3
python310.dll!Py_RunMain+0x184
python310.dll!Py_RunMain+0x15
python310.dll!Py_Main+0x25
python.exe+0x1230
KERNEL32.DLL!BaseThreadInitThunk+0x1d
ntdll.dll!RtlUserThreadStart+0x28
As you can see I’m also using SDL2 inside of a Python C++ extension, so maybe it’s messing with the threads. As for SDL_CreateRenderer(), after updating everything it seems to have stopped hanging when using anything else than 4 (which is software rendering), and sets a proper SDL_Error. For this one I’ll do my homeworks and try to find out what’s wrong with all of them.