https://github.com/shader-slang/slang
Revision 87c50cf1644454cdc9e7f6d1262bee29bfc86e80 authored by Tim Foley on 29 March 2018, 22:47:58 UTC, committed by GitHub on 29 March 2018, 22:47:58 UTC
Fixes #463

Some of the attributes were failing to check for a `null` result from `checkConstantIntVal`, and so they crashed when a bad expression was used in an attribute. The particular way this had been triggered was that a user put an HLSL geometry shader in the same file with other code, using an entry point like:

```hlsl
[instance(COUNT)]
void myGeometryShader(...) {...}
```

They then defined `COUNT` as a preprocessor macro when compiling using the GS, but left it undefined otherwise. The result was that the argument to the `instance` attribute would fail to type check, and thus wouldn't count as a constant integer value, so that `checkConstantIntVal` returns `null` and results in the crash.

The workaround for the user is to always define `COUNT`, even when not compiling the GS.

The fix in the compiler is to guard against `null` in these cases and bail out of attribute checking. I also implemented logic so that `CheckIntegerConstantExpression` (which is invoked by `checkConstantIntVal`) will not produce an additional error message if the underlying expression failed to type check. In this casem the user will get an `undefined identifier: COUNT` error message, and we don't need to waste their time by also telling them that this isn't a compile-time constant expression.
1 parent b61371d
History
Tip revision: 87c50cf1644454cdc9e7f6d1262bee29bfc86e80 authored by Tim Foley on 29 March 2018, 22:47:58 UTC
Avoid crash when bad argument given to [instance(...)] attribute (#464)
Tip revision: 87c50cf
File Mode Size
build
docs
examples
external
source
tests
tools
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 398 bytes
.gitmodules -rw-r--r-- 107 bytes
.travis.yml -rw-r--r-- 1.6 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
Makefile -rw-r--r-- 6.3 KB
README.md -rw-r--r-- 4.9 KB
appveyor.yml -rw-r--r-- 3.5 KB
slang.h -rw-r--r-- 42.9 KB
slang.sln -rw-r--r-- 9.1 KB
test.bat -rw-r--r-- 1.4 KB

README.md

back to top