Crash in SDL_Init when SDL_VIDEODRIVER set

Running SDL 2.38.2 in Windows 11, with SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); everything works fine, but if I also define the environment variable SDL_VIDEODRIVER=opengl it crashes inside SDL_Init():

ntdll!RtlpFreeHeap+0x3d2:
776a00a2 324602          xor     al,byte ptr [esi+2]        ds:002b:00dc331a=??

I can’t figure out why setting the environment variable should cause SDL_Init() to crash. What am I missing?

The video driver isn’t the same thing as the renderer driver (the “video” driver is what backend SDL uses to create the window etc). On Windows, the only available video driver is “windows”.

However, it being set to something else should cause SDL_Init() to fail and return an error instead of crashing outright. You should file a bug report.

OK, but it seems ‘unhelpful’ to have an environment variable which cannot be used to change anything (in Windows at least) but no environment variable to control something that can be changed, i.e. the render driver!

Environment variable for SDL_HINT_RENDER_DRIVER is SDL_RENDER_DRIVER. SDL_VIDEODRIVER is a variable for other hint.

From https://wiki.libsdl.org/SDL2/CategoryHints

The convention for naming hints is SDL_HINT_X, where “SDL_X” is the environment variable that can be used to override the default.

Thanks, that information is quite well hidden! I tried SDL_RENDERDRIVER without success, I wouldn’t have guessed that it needed an extra underscore when SDL_VIDEODRIVER doesn’t. :confused: