Skip to content

Conversation

@K0bin
Copy link
Collaborator

@K0bin K0bin commented Jan 26, 2025

Hopefully fixes #4613

There was a race that could lead to freeing a chunk and allocating memory from it at the same time. This was extremely rare because D3D9 games usually don't make use of multi threading for rendering and just have a single rendering.
On top of that nearly all calls into any methods related to this are protected by the device lock anyway.

To fix this we just always route all operations through the general allocator which acquires its own lock before
calling the equivalent function inside the chunk.

@K0bin K0bin added the d3d9 label Jan 26, 2025
@enginelesscc
Copy link

Tested it for my scenario in #4613
Seems fixed, haven't encountered any problems so far :)

@K0bin
Copy link
Collaborator Author

K0bin commented Jan 27, 2025

Great, thanks for testing.

@K0bin K0bin marked this pull request as ready for review February 1, 2025 00:55
Fixes an extremely race condition that can happen when freeing a chunk.
@doitsujin doitsujin merged commit 4282829 into doitsujin:master Feb 17, 2025
4 checks passed
@K0bin K0bin deleted the d3d9-unmap-race branch February 17, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3D9: Multithreaded Texture creation may crash

3 participants