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 potential data issue when reloading Asset data #11880

Merged
merged 1 commit into from Jun 3, 2023

Conversation

iwubcode
Copy link
Contributor

@iwubcode iwubcode commented Jun 3, 2023

I was looking back over the asset logic and wondered if there might be a problem.

If in the middle of an asset being reloaded, imagine that a callee has called GetData(). This would give them a pointer to that data. If they are still operating on that data when the asset is reloaded, then the data would be modified on the asset reload thread. This could be potentially dangreous at worst or lead to incorrect data at best. To avoid this, I return a shared_ptr ensuring that the callee will have access to the original data for the lifetime of the smart ptr.

…hat could happen due to the asset loading thread reloading data while another thread is working with it
@AdmiralCurtiss
Copy link
Contributor

Yes, you're right, this can definitely happen.

@AdmiralCurtiss AdmiralCurtiss merged commit 3245786 into dolphin-emu:master Jun 3, 2023
14 checks passed
@iwubcode iwubcode deleted the race_condition_asset branch June 3, 2023 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants