From eb4616377b720184ef2a639389647236821abd75 Mon Sep 17 00:00:00 2001 From: scott Date: Wed, 26 Aug 2026 16:36:37 +1000 Subject: [PATCH] Fix crash when a texture file fails to load on an async worker thread r_tex_c::LoadFile()'s failed-load fallback (missing or unreadable file) called Upload() directly from the texture manager's worker thread. The GL context belongs to the main thread, so this crashes in ANGLE's GL_GenTextures with a null-deref (observed as a startup SIGSEGV on macOS when the PoB passive tree references TreeData/PassiveMasteryConnectedButton.png, which does not exist). Route the placeholder upload through the pending-upload queue exactly like the successful async load path a few lines above, so the main thread performs the GL work in ProcessPendingTextureUploads(). Co-Authored-By: Claude Fable 5 --- engine/render/r_texture.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engine/render/r_texture.cpp b/engine/render/r_texture.cpp index 5c5e1e3..3326dc6 100644 --- a/engine/render/r_texture.cpp +++ b/engine/render/r_texture.cpp @@ -603,6 +603,16 @@ void r_tex_c::LoadFile() auto raw = std::make_unique(); raw->CopyRaw(IMGTYPE_GRAY, 8, 8, t_defaultTexture); + if (flags & TF_ASYNC) { + // Missing/failed file on an async worker thread: the GL context + // belongs to the main thread, so route the placeholder upload + // through the pending-upload queue like the success path above. + img = std::move(raw); + flags = TF_NOMIPMAP; + status = PENDING_UPLOAD; + manager->EnqueueTextureUpload(this); + return; + } Upload(*raw, TF_NOMIPMAP); status = DONE; }