-
Notifications
You must be signed in to change notification settings - Fork 722
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
Assert in template
+ out
functions when it has local variables
#5293
Comments
So, I think this issue is more of an argument about why we shouldn’t enable assertions by default than an argument that we should. The assert is revealing a bug, but it isn’t a bug that prevents correct code generation. With asserts disabled the shader compiles to correct output. The problem with blanket enabling asserts in the DXC (or LLVM) codebase is that it enables a bunch of really expensive verification steps that are extremely useful for testing, but not for end users. My anecdotal test on DXC is that costs us about 15% on compile time. |
@llvm-beanz I've not validated that for larger HLSL source the output is indeed a valid shader. It is not my code but who knows if this is the source of vague/obscure bugs. In my mind all bets are off when we ignore useful asserts, otherwise the assert shouldn't have been there. |
The location of the assert you reported here is during diagnostic construction, and the code still does something correct even if the
This is okay if that's how you use asserts in your codebase. That is not how asserts are used in LLVM, and applying that assumption to LLVM is not necessarily helpful. LLVM generally uses asserts to verify assumptions but still expects the code to behave correctly if the assert is removed. Cases that are irrecoverable use |
That constraint seems to have been loosened as LLVM transformed into DXC then :) (Not necessarily speaking about this specific assert) |
DXC's use of asserts is inconsistent at best, but since most of DXC's code is inherited from LLVM & Clang, I don't think you can safely dismiss how that code was written. |
Sure, let's settle that discussion there then, and I'll just have to be mindful of our rather uncommon use of many threads poking Let's instead leave this issue to clear out the diagnostic |
We (Frostbite) just hit this issue as well. I wanted to clear a few things up since I think from reading the above there's a bit of a misunderstanding about the nature of this issue. This is the code that is asserting:
So, if the assert fires, then Now, it appears that in very simple situations you "get away with it", but this is not true in general -- in our case it just crashes 🙂. We are compiling multiple shaders in parallel, and it sounds like this is what @MarijnS95 is doing too, so it sounds like that's one way to be unlucky 🙂. So, based on this:
This is definitely not true in this particular instance -- accessing unitialised data is not behaving correctly 🙂.
IMO this is also not true in this instance -- at best the diagnostic analysis is wrong, attributing the assignment to the wrong variable. At worst it crashes, as we have seen 🙂. Anyway, that's a very long winded way to say that this is a pretty bad bug, and prevents our use of |
After trying very hard to parse your reply, I couldn't find anything that is different in your report/reply/findings about the nature of this issue (maybe out the way it was written off as a diagnostics bug that still produces "correct" code?). Can you elaborate what this misunderstanding is? I think we both found
Yes, that's exactly what we're doing. On the same library and I think even compiler COM instance. |
Yes, exactly, I believe we both hit the exact same issue. We weren't "lucky" though -- the compiler crashes for us 🙂. My reference to a misunderstanding is the implication that this is an unimportant issue, because it "works" in Release. For us it very much does not, and is unlikely for most people (given that the code will index into an array with uninitialised memory, some that is very likely to cause a crash). |
Confirmed that the example in the description still hits this assert. |
Unlike #5273 this seems much stranger in origin. The following sample fails to compile with the error below:
And this assert is "solved" by either:
R
withuint
);uint repro = 0;
variable. Note that using it in e.g.result = 10 + repro;
does not get rid of the assert!;out
withinout
.Keep in mind that I did hack in a:
bit of code to get the compiler to tell me where in our massive shader +
#include
chain I had to start looking to provide you with a repro (similar to the request foremitError()
in #5273). Is there anything I/we can do to streamline this process?Likewise I wouldn't have found this error without creating a release build of the compiler with
-DLLVM_ENABLE_ASSERTIONS=ON
, and would like to discuss enabling assertions by default. I have no clue what kind of valid/invalid shader the compiler might have emitted otherwise (or is already emitting, since I am updating our shader compiler and enabling this as a safety guard, but our current older compiler without assertions is accepting this shader just fine: more details in the first paragraph of #5271).The text was updated successfully, but these errors were encountered: