Skip to content
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

Divide by zero in GetPartReflection when constant buffers have zero-sized arrays. #6961

Open
johnhable opened this issue Oct 13, 2024 · 0 comments
Labels
bug Bug, regression, crash incorrect-code Issues relating to handling of incorrect code
Milestone

Comments

@johnhable
Copy link

Description
There is an issue with a divide by zero when gathering reflection data. In particular, GetPartReflection() is causing a divide by zero exception.

When looking at the shader code, it looks like there was a bug in the raw shader data, with a zero sized array. The compilation was succeeding, but crashing with divide by zero when getting reflection. There was a struct that looked like this:

struct MaterialData
{
float3 diffuseColor;
...
uint4 srv_info[0];
};

ConstantBuffer s_MaterialCb : register(b0,space2);

Removing the srv_info struct fixed it. After discussion, it appears that this line was causing the divide by zero:

https://github.com/microsoft/DirectXShaderCompiler/blob/main/lib/HLSL/DxilContainerReflection.cpp#L997

Steps to Reproduce
While I don't have a full repro case, I can share the specific shader privately if it would help.

Actual Behavior
The output is a divide by zero exception in GetPartReflection().

Environment

  • DXC version: July 2024
  • Host Operating System: Windows 10, Version 22H2, OS Build 19045.5011
@johnhable johnhable added bug Bug, regression, crash needs-triage Awaiting triage labels Oct 13, 2024
@damyanp damyanp added incorrect-code Issues relating to handling of incorrect code and removed needs-triage Awaiting triage labels Oct 15, 2024
@damyanp damyanp added this to the Dormant milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash incorrect-code Issues relating to handling of incorrect code
Projects
Status: Triaged
Development

No branches or pull requests

2 participants