Bug 100601 - subpass_needs_clear segfaults if attachment is VK_ATTACHMENT_UNUSED
Summary: subpass_needs_clear segfaults if attachment is VK_ATTACHMENT_UNUSED
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Vulkan/intel (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-06 07:30 UTC by maister
Modified: 2017-04-18 15:24 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Patch to try (4.10 KB, patch)
2017-04-06 21:21 UTC, Jason Ekstrand
Details | Splinter Review
Workaround (3.59 KB, patch)
2017-04-07 08:29 UTC, maister
Details | Splinter Review

Description maister 2017-04-06 07:30:03 UTC
subpass_needs_clear loops over all color attachments in a subpass, but it doesn't check if the attachment is unused (-1) before it dereferences the attachment array.
Comment 1 maister 2017-04-06 07:51:03 UTC
There are lots of places where VK_ATTACHMENT_UNUSED is not checked as well.
The crashes happen in vkCmdBeginRenderPass.

The scenario is where there is one color attachment which is VK_ATTACHMENT_UNUSED (in order to allow a shader to use location = 0 dummy fragment output for depth-only shaders).
Comment 2 Jason Ekstrand 2017-04-06 21:21:34 UTC
Created attachment 130736 [details] [review]
Patch to try

Thanks for the bug report!  Do you have a test-case?  If so, could you please try the attached patch.  I fixed all of the cases I could find.
Comment 3 maister 2017-04-07 08:27:10 UTC
The test is just creating a subpass where
pColorAttachments = { VK_ATTACHMENT_UNUSED }
colorAttachmentCount = 1

That patch helped a bit, it now crashes in
genX_cmd_buffer.c:1168 where it tries to emit SET_COLOR_ATTACHMENTS.
Comment 4 maister 2017-04-07 08:29:28 UTC
Created attachment 130740 [details] [review]
Workaround

This is the patch I applied locally to make it work for me at least.
Comment 5 Jason Ekstrand 2017-04-07 17:36:52 UTC
Thanks!  I've reworked things a bit into this branch:

https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/anv-attachment-unused

Mind giving it a go?
Comment 6 maister 2017-04-10 14:23:40 UTC
On holiday, so won't be able to test until next week.
Comment 7 maister 2017-04-18 09:02:00 UTC
Tested your branch. Works fine for me.
Comment 8 Jason Ekstrand 2017-04-18 15:24:12 UTC
Cool.  The patches have already been merged.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.