Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCommon: prevent a potential custom texture crash #12374

Merged

Conversation

iwubcode
Copy link
Contributor

Custom asset data is loaded on a separate thread and stored in a shared_ptr. When something wants some of that asset data, a copy of the shared_ptr will be provided. At any time the separate thread can destroy the original shared_ptr copy, meaning something that wants to use that data must keep that shared_ptr around as long as it wants that copy of the data.

In TextureCache, I was loading a shared_ptr, getting a pointer to one of its member variables, then letting that shared_ptr copy die. So it was undefined how long that member pointer would be valid.

A user on discord had a crash that looked eerily like it could be caused by this. This PR fixes that issue by holding onto the shared_ptr instead of the member pointer.

…when a shared_ptr gets released while a pointer to its member data is still being used
@lioncash lioncash merged commit d84ed05 into dolphin-emu:master Dec 11, 2023
11 checks passed
@iwubcode iwubcode deleted the custom_texture_potential_crash_fix branch December 11, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants