microsoft / microsoft/DirectXShaderCompiler

Casting subclass to parent of three class heirarchy causes crashes

Open
#3,048 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug check-in-clang crash
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

The following shader which attempts to cast a variable of type C to its immediate parent, type B while passing an argument crashes DXC. If the only classes are B and C, this works fine. If there is a parent class to B, then it fails. Passing the argument as class C works fine as well.

struct A {
  float4 stuff;
};
struct B : A {
  float4 gimme() {return stuff;}
};
struct C : B {
  void dostuff() {stuff = 0;}
};
float4 f(B thing1) { // THIS IS THE PROBLEM
  return thing1.gimme();
}
float4 main() : SV_Target
{
  C thing2;
  thing2.stuff = float4(1,2,3,4);
  return f(thing2);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by compiling the provided shader with DXC and use main plus f(B thing1) as the reproduction entry points. Trace the C-to-B argument conversion through the A/B/C hierarchy; done means this case no longer crashes and returns the initialized value.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.