-
Notifications
You must be signed in to change notification settings - Fork 542
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
Vulkan conformance test gets access violation in spvValidate #270
Comments
Looping in @umar456 since he has better understanding of the validator. |
Looking into it now |
I haven't looked into this carefully, but I can reproduce a segfault using SDK 1.0.21 with Test case |
And this is a #version 310 es
float func (float a)
{
while (a < 100.0)
return -a;
return 1.0;
}
void main()
{
float t = func(50.0);
} |
Thanks. I have reproduced the error. I should have a fix shortly |
It seems to me that glslang is generating SPIR-V violating structured control flow rules. Here is the disassembly of the above program:
Loop header: There is no continue block since there is no block "containing a branch to an OpLoopMerge instruction’s Continue Target." So, one SPIR-V structured control flow rules---all CFG back edges must branch to a loop header, with each loop header having exactly one back edge branching to it---is violated because of no back edge branching to the loop header. With that said, the validator should still print an error instead of segfault. But I feel I'm quite clumsy and dumb regarding interpreting the SPIR-V structured control flow spec. So it would be very nice if @johnkslang could shed some light on this issue. |
Well There doesn't seem to be a back-edge or a back-edge block as defined by the spec.
The back-edge block should be I don't know how else this function would be implemented in SPIR-V(unless we create an unconditionally false branch to the continue target which seems like a messy solution). |
Hmm, my interpretation of "Continue Block: A block containing a branch to an OpLoopMerge instruction’s Continue Target" in the spec is, continuing block is the block jumping to the continue target, not the continue target block itself. For this case, |
Ahh sorry. You are right. I was confusing the continue construct with the continue block. |
Fixed with 6c61bf2 |
I see the last instruction in the loop
I don't immediately see where it says that branch must be reachable. Does it say that? Or, is the problem truly solved, with no remaining questions? |
The back-edge is defined in a way that implies that it needs to be reachable. Here is the text:
The branch up to the loop header is not reachable from the first block of the function so it is not part of the back-edge set. Open Question: |
+1 to what @umar456 said. That's my interpretation of the spec too. |
Okay, so this is a side effect of adding a definition that was not originally there, and having the definition be too restrictive (it wasn't part of the core rule set for making all this work). I don't yet see the real reason the back edge must be reachable. |
The validator crash is resolved (software issue). My opinion is +1 to what @umar456 said. The spec's definition for back-edge is non-standard. (My reference is https://en.wikipedia.org/wiki/Depth-first_search) But I think glslang's code generation is sensible, and if anything the spec should be amended to clearly allow unreachable continue-constructs. |
For B-> C to be a back edge the "previously visited" phrasing to me means "I am currently visiting B, and the edge makes me want to visit C, but I have previously visited C". It's the "I am currently visiting B" part that is not satisfied if doing a DFS starting a the entry block of the function. |
@dneto0 sounds right; I'm transferring this to the headers project, at: KhronosGroup/SPIRV-Headers#16. |
+1 to moving the spec issue elsewhere. While I still have this in my head:
|
Add a SourceLanguage for SYCL
Specifics
Windows 7, Nvidia GTX 660 Ti, Driver 368.39
Have Vulkan SDK 1.0.21 installed for validation layers and set environment variable VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_standard_validation
To reproduce I run all of the dEQP-VK.glsl.functions.control_flow.* tests from the Vulkan Conformance Test Suite
Message:
Exception thrown: read access violation.
this was nullptr. (debugger confirms that variable "this" is NULL)
Location:
BasicBlock.h:
Call Stack:
Bisected to spirv-tools commit: f61db0b
Validator structured flow checks: back-edge, constructs
Originally posted by @Tony-LunarG in google/shaderc#234:
The text was updated successfully, but these errors were encountered: