microsoft / microsoft/DirectXShaderCompiler

Compiler infinite loop issue

Open
#3,906 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I seem to have found an infinite loop during shader compilation and I was only able to reproduce this infinite loop when the following three conditions were met:

  • When the handle to index in the ByteAddressBufferArray was returned from a struct
  • When the ByteAddressBuffer is accessed in the function (it doesn't need to be used)
  • When the function returns an array of values, I tested it with float2,float3 and int2.

When any of these steps are missing it will not result in an infinite loop. I have attached the source code of the shader below.

struct RenderResourceHandle {
    uint handle;

    uint readIndex() { return this.handle; }
};

ByteAddressBuffer g_byteAddressBuffer[] : register(t0, space3);

struct Test{
    RenderResourceHandle h;

    float3 infLoop()[2] {
        ByteAddressBuffer b = g_byteAddressBuffer[this.h.readIndex()];
        float3 v[2] = {
            0.xxx,0.xxx,
        };
        return v;
    }
};

[numthreads(8, 8, 1)] void main(uint2 dispatchIdx
                                : SV_DispatchThreadID, uint3 pxInTile
                                : SV_GroupThreadID) {

    RenderResourceHandle resourceHandle;
    resourceHandle.handle = 0;

     Test t;
     t.h = resourceHandle;
     float3 w[2] = t.infLoop();
}

I have tried to compile this shader with the latest version from master.
shader playground link: http://shader-playground.timjones.io/8db5b73aef2c0f7eb76810f4afcdb49a

As workaround I wrapped the data in a struct and returned the struct instead.

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 attached HLSL shader from the issue, using the linked Shader Playground reproduction and the latest master described there. Compare it with the workaround that returns a struct; done means the original reproducer no longer hangs during shader compilation while the stated conditions remain covered.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.