Skip to content

Segfault when calling sizeof() on templated typeΒ #7510

Closed

Description

Description

We just upgraded to the latest May 2025 release, from a previous self-compiled build at 47e11af. One of our shaders triggers a SIGSEGV right inside DXC. This seems to be caused by calling sizeof() on a templated type, regardless of what the struct contains. It doesn't seem to need to use T in any capacity for this to trigger.

Steps to Reproduce

https://godbolt.org/z/hnfd5EEGY (DXC on trunk, this doesn't have an explicit tagged 1.8.2505 release just yet)

template<typename T> struct Encoded{
    // uint x;
    // T y;
};

[numthreads(8, 8, 1)]
void main(uint2 tid : SV_DispatchThreadID) {
    uint s = sizeof(Encoded<int>);
}

It doesn't matter if we compile to DXIL or SPIR-V.

Environment

  • DXC version: v1.8.2505 (using the library)
  • Host Operating System: Windows, MacOS (Linux untested, but likely to fail as well)

Given that we have a known-working commit, bisection should only contain these 51 commits:

47e11af...v1.8.2505

Activity

  1. added
    bug
    needs-triage
    on Jun 4, 2025
  2. MarijnS95 commented on Jun 4, 2025

    @MarijnS95
    ContributorAuthor

    In fact we can reduce the bisection range to just 18 commits. We were previously on 556fc5b for SM6.9, which is also directly reachable by https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.8.2505:

    556fc5b...v1.8.2505

  3. llvm-beanz commented on Jun 4, 2025

    @llvm-beanz
    Collaborator

    This is a regression introduced in #7452.

    Tagging Tex Riddell (@tex3d) for visibility.

  4. llvm-beanz commented on Jun 4, 2025

    @llvm-beanz
    Collaborator

    The problem here is that the template isn't instantiated before we do some HLSL-specific testing. Here's a workaround while we try to resolve the issue:

    https://godbolt.org/z/zEzjj1Peb

  5. added a commit that references this issue on Jun 4, 2025
    33835fa
  6. added a commit that references this issue on Jun 5, 2025
    77dcbb6
  7. added 2 commits that reference this issue on Jun 6, 2025
    40582ce
    4a98867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions