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 5190

Summary: [REGRESSION] SDL_EGL_LoadLibrary() leaks GL library reference
Product: SDL Reporter: Cameron Gutman <cameron.gutman>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 Keywords: target-2.0.14
Version: 2.0.12   
Hardware: x86_64   
OS: Linux   

Description Cameron Gutman 2020-06-14 21:02:20 UTC
The modifications in https://hg.libsdl.org/SDL/rev/9692ad570003 changed SDL_EGL_LoadLibraryOnly() to set '_this->gl_config.driver_loaded = 1'. The problem is that the caller, SDL_GL_LoadLibrary(), is already going to increment '_this->gl_config.driver_loaded' after SDL_EGL_LoadLibrary() returns. This leads to an extra reference being put on the GL library, and as a result, it is never unloaded in SDL_GL_UnloadLibrary() when SDL_DestroyWindow() is called.

See the double-referencing callstack below:
#1  SDL_EGL_LoadLibraryOnly (_this=0xd49a60, egl_path=0x0)
#2  SDL_EGL_LoadLibrary (_this=0xd49a60, egl_path=<optimized out>, native_display=0xd657e0, platform=0)
#3  SDL_GL_LoadLibrary_REAL (path=path@entry=0x0)
#4  SDL_RecreateWindow (window=window@entry=0xd4d980, flags=flags@entry=10)
#5  GLES2_CreateRenderer (window=0xd4d980, flags=2)
#6  SDL_CreateRenderer_REAL (window=0xd4d980, index=1, flags=2)

The driver_loaded count is referenced at both SDL_EGL_LoadLibraryOnly() and SDL_GL_LoadLibrary_REAL() frames.
Comment 1 Ryan C. Gordon 2020-07-16 17:20:00 UTC
This is now fixed in https://hg.libsdl.org/SDL/rev/aa751acb2966, thanks!

--ryan.