microsoft / microsoft/DirectXShaderCompiler

Validator needs to prevent invalid handle in AnnotateHandle

Open
#4,415 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug validation
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

// RUN: %dxc -T vs_6_6 -E main %s

// Using CBV.u before defining CBV to a specific resource should result in error.
// It does result in a warning:
// warning: variable 'CBV' is uninitialized when used within its own initialization [-Wuninitialized]
// Should we make this warning an error by default?

// It also looks up the index with an invalid zeroinitializer handle in DXIL, which should cause a validation failure in any case:
// %1 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle zeroinitializer, %dx.types.ResourceProperties { i32 13, i32 4 })  ; AnnotateHandle(res,props)  resource: CBuffer

struct MyCB {
  uint u;
};
static ConstantBuffer<MyCB> CBV = ResourceDescriptorHeap[CBV.u];

uint main() : OUT {
  return CBV.u;
}

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

Use the embedded HLSL reproducer with %dxc -T vs_6_6 -E main %s and inspect the validation path for the AnnotateHandle call. Done means the invalid zeroinitializer handle causes a validation failure, rather than only producing the reported uninitialized-variable warning.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.