shader-slang / slang

Making it easier to work with shaders
MIT License
2.06k stars 177 forks source link

tests/cpu-program/gfx-smoke.slang fails on local test #4489

Closed jkwak-work closed 3 months ago

jkwak-work commented 3 months ago

Problem description One of the slang-test tests started failing as a regression.

tests/cpu-program/gfx-smoke.slang

This test is disabled on CI but when you run it on a local machine, it fails. The regression started happening from the following commit,

b7e82434 Wed Jun 12 12:46:24 2024 -0400 Add slangc flag to `-zero-initialize` all variables (#3987) 

Note that there was a build break that causes the specific commit to have a compile error. You will need to cherry-pick the right next commit.

Repro step Checkout the commit that caused the regression and cherry-pick to fix the compile error,

git checkout b7e82434
git cherry-pick 8bf7d11
build slang-test.exe
slang-test.exe tests/cpu-program/gfx-smoke.slang

When the issue is reproduced, the error looks like following,

tests/cpu-program/gfx-smoke.slang(7): note 99999: an internal error threw an exception while working on code near this location
    gfx.DeviceDesc deviceDesc = {};
                   ^~~~~~~~~~
(0): error 99999: Slang compilation aborted due to an exception of class Slang::InternalError: unexpected: InitializerListType
ArielG-NV commented 3 months ago

update to what causes the problem:

    void SemanticsDeclBodyVisitor::visitAggTypeDecl(AggTypeDecl* aggTypeDecl)

    //...
        ensureDecl(m->getDefaultDeclRef(), DeclCheckState::DefaultConstructorReadyForUse); // crash is introduced indirectly from this line
    //...

This is due to nested = {}; initializers

struct innerStruct{
 int a;
}
struct myStruct{
 innerStruct s = {};
}

void main()
{
myStruct val = {};
}
ArielG-NV commented 3 months ago

detailed explanation of the problem: https://github.com/shader-slang/slang/pull/4491#issuecomment-2194872824