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

Fix some random crashes when using metal argument buffers #2340

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

WDog367
Copy link
Contributor

@WDog367 WDog367 commented Sep 18, 2024

Commit should fix a bug with the loop iteration in enumerateEnabledBits(). It would jump to the first set bit, then iterate over EVERY subsequent bit, instead of only iterating over bits that were set

Discovered this after a lot of time debugging random crashes in MoltenVK 1.2.11, that would only happen with MVK_CONFIG_USE_METAL_ARGUMENT_BUFFERS enabled

What seemed to be happening was:MVKDescriptorPool::allocateDescriptorSet() would iterate over _descriptorSetAvailablility to find an empty set, but it would check sets that weren't freed yet.
If one of those got picked, the new set is initialized on top of an existing one, essentially corrupting it. Odd behavior would happen after that, and the app would eventually crash trying to use the corrupted set

These crashes could only happen when using Metal Argument buffers, and using a pool with VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT

This is a pretty simple change, so hopefully it doesn't break anything 😃

Fixes an issue with BitArray enumeration, where it
could iterate over bit indices that weren't set

This would cause issues in descriptor set allocation,
when argument buffers are enabled, where it could
select a set index from the pool that isn't freed,
and try to create a new set on top of the exiting one
@CLAassistant
Copy link

CLAassistant commented Sep 18, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@cdavis5e cdavis5e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should've caught this earlier... Good catch.

Copy link
Contributor

@billhollings billhollings left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holy moly! Good catch! Thanks for submitting this!

Hard to believe that I typed that broken code 3 years ago, and that it has not been caught earlier. This kind of mistake should have been failing fast, but nothing in the millions of CTS tests have triggered it.

@billhollings billhollings merged commit b3721a4 into KhronosGroup:main Sep 18, 2024
6 checks passed
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.

4 participants