Conversation
…s not initialized Add NULL guards for ri.GLimp_Shutdown and ri.VKimp_Shutdown calls in RE_Shutdown() across all three renderers (opengl, opengl2, vulkan). When the client binary is built without USE_OPENGL_API (e.g. RENDERER_DEFAULT=vulkan with USE_RENDERER_DLOPEN=0) but later loads the OpenGL renderer .so at runtime, ri.GLimp_Init is NULL. The renderer correctly detects this and calls ri.Error(ERR_FATAL), but the resulting shutdown path in RE_Shutdown calls ri.GLimp_Shutdown without checking for NULL, causing a SIGSEGV at address 0x0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ri.GLimp_Shutdownandri.VKimp_Shutdowncalls inRE_Shutdown()across all three renderers (opengl, opengl2, vulkan)Problem
When the client binary is built without
USE_OPENGL_API(e.g.RENDERER_DEFAULT=vulkanwithUSE_RENDERER_DLOPEN=0) but later loads the OpenGL renderer.soat runtime,ri.GLimp_Initis NULL. The renderer correctly detects this atInitOpenGL()and callsri.Error(ERR_FATAL, "OpenGL interface is not initialized"), but the resulting shutdown path inRE_Shutdown()callsri.GLimp_Shutdown()without checking for NULL, causing a SIGSEGV at address 0x0.The same issue applies to
ri.VKimp_Shutdownin the vulkan renderer's#ifdef USE_VULKANpath and tori.GLimp_Shutdownin its#elsefallback path.Crash backtrace
GDB confirms the function pointers are NULL:
Fix
Simple NULL guards before the function pointer calls in
RE_Shutdown():code/renderer/tr_init.c— guardri.GLimp_Shutdowncode/renderer2/tr_init.c— guardri.GLimp_Shutdowncode/renderervk/tr_init.c— guard bothri.VKimp_Shutdownandri.GLimp_ShutdownTesting
Tested on ppc64le (Power9, AMD RX 6600 XT, Fedora 43):
USE_OPENGL_API=0, loaded OpenGL renderer: previously crashed with SIGSEGV, now exits cleanly withSys_Error: OpenGL interface is not initialized