Skip to content

Fix startup crash when a texture file fails to load on an async worker thread - #3

Open
scottsheppeard wants to merge 1 commit into
stevschmid:macos-portfrom
scottsheppeard:fix-async-texture-upload-fallback
Open

Fix startup crash when a texture file fails to load on an async worker thread#3
scottsheppeard wants to merge 1 commit into
stevschmid:macos-portfrom
scottsheppeard:fix-async-texture-upload-fallback

Conversation

@scottsheppeard

Copy link
Copy Markdown

Problem

Running a current PathOfBuilding dev checkout through the dev-mode launcher segfaults during startup on Apple Silicon:

EXC_BAD_ACCESS (SIGSEGV), KERN_INVALID_ADDRESS at 0x0
libGLESv2.dylib   GL_GenTextures
libSimpleGraphic  r_tex_c::Upload(image_c&, int)
libSimpleGraphic  r_tex_c::LoadFile()
libSimpleGraphic  t_manager_c::ThreadProc()

Trigger: PoB's passive tree sprite loading references TreeData/PassiveMasteryConnectedButton.png, which doesn't exist in the repo. r_tex_c::LoadFile()'s failed-load fallback uploads the placeholder texture by calling Upload() directly on the texture manager worker thread. The GL context is only current on the main thread, so ANGLE's GL_GenTextures null-derefs.

The successful async load path a few lines above already handles this correctly by enqueueing via manager->EnqueueTextureUpload() so the main thread performs the GL work in ProcessPendingTextureUploads() — the fallback path just predates/bypasses that mechanism.

Fix

When TF_ASYNC is set, route the placeholder through the same pending-upload queue; the synchronous path is unchanged. flags is reset to TF_NOMIPMAP before enqueueing to preserve the previous Upload(*raw, TF_NOMIPMAP) GL behaviour.

Verified on an M-series MacBook Pro: previously crashed deterministically at startup with both the PoE1 and PoE2 dev trees; with this patch both start and run normally (missing file degrades to the default placeholder texture, as on Windows).

Note: the same code exists in upstream PathOfBuildingCommunity/PathOfBuilding-SimpleGraphic master — I'm submitting the same fix there; if it merges upstream first, feel free to close this one in favour of a sync.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant