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

Prevent null pointer access for GetSwapchainImages out-of-order calls #1975

Merged
merged 1 commit into from
Jun 29, 2020

Conversation

mark-lunarg
Copy link
Contributor

Validation could croak if this two-part query was only called by the application to retrieve the count but not the images.

i.e., though it seems weird, it's legal to do this:

GetSwapchainImages(count, null);
AcquireNextImage(index);
GetSwapchainImages(count, pointer_to_image_array);

Wrote a positive test for this case, but it dies on Android consistently and so left it out. Highlighted this in BP tracking issue #24 (it was already there) to spit out a warning when this happens.

Fixes #1955.

uint32_t acquired_images = 0;
for (auto item : swapchain_data->images) {
auto image_state = GetImageState(item.image);
if ((image_state) && image_state->acquired) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not modify the lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ignorance! Pushed a redo.

Copy link
Contributor

@TonyBarbour TonyBarbour left a comment

Choose a reason for hiding this comment

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

LGTM

Validation could croak if this two-part query was only called by
the application to retreive the count but not the images.

Change-Id: Iee9ad53bfbd59c6f34054c8ab48161037b1db5ef
@mark-lunarg mark-lunarg force-pushed the markl_swapchain_crash branch from 74bcf20 to ed01d8a Compare June 25, 2020 20:07
@mark-lunarg mark-lunarg merged commit 444b820 into master Jun 29, 2020
@mark-lunarg mark-lunarg deleted the markl_swapchain_crash branch June 29, 2020 13:12
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.

Segmentation Fault During vkAcquireNextImageKHR while using VK_LAYER_KHRONOS_validation
3 participants