Fix segfault in WaterRenderObjClass when skybox asset fails to load#188
Merged
Conversation
WaterRenderObjClass::Render() dereferences m_skyBox whenever
TheGlobalData->m_drawSkyBox is set, but Create_Render_Obj("new_skybox")
can return null when the skybox asset is unavailable (e.g. the base
Generals archives are not found at init). On macOS this segfaults
(SIGSEGV in WaterRenderObjClass::Render via
Render_And_Clear_Static_Sort_Lists) as soon as the shell map or any
water-bearing map renders.
- Guard the m_skyBox use in Render()
- Early-return in replaceSkyboxTexture(), since
replaceAssetTexture() dereferences the render object unconditionally
- Add [TEX_MISSING] stderr logging in Apply_Missing_Texture()
(non-Windows only), as proposed in Session 44 notes - this is what
made the missing-asset root cause diagnosable
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
On macOS (Apple Silicon,
macos-vulkanpreset, Beta 12), the game segfaults as soon as the shell map — or any map with water — renders:Root cause
WaterRenderObjClass::Render()dereferencesm_skyBoxwheneverTheGlobalData->m_drawSkyBoxis set, butCreate_Render_Obj("new_skybox")returns null when the skybox asset is unavailable — e.g. when the base Generals archives aren't found at init (Steam layout withoutZH_Generals/, or any partial-asset setup). Disassembly of the crash site confirms the null deref is them_skyBox->Set_Position()/m_skyBox->Render()pair after the water-type switch.replaceSkyboxTexture()has the same hazard: it passesm_skyBoxintoreplacePrototypeTexture()→replaceAssetTexture(), which callsrobj->Class_ID()unconditionally, so any map that swaps skybox textures crashes the same way.Fix
m_skyBoxuse inRender()(null check alongside the existingTheGlobalDatacheck)replaceSkyboxTexture()whenm_skyBoxis null[TEX_MISSING]stderr logging inApply_Missing_Texture()(guarded#ifndef _WIN32), as proposed in the Session 44 notes — this is what made the missing-asset root cause diagnosable hereTesting
[TEX_MISSING]output confirmed: 247 missing textures with base archives absent → 1 (trstrtholecvr.tga, absent from retail archives) onceZH_Generals/is in place🤖 Generated with Claude Code