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

SIGSEGV on template override mismatch #7154

Open
antaalt opened this issue Feb 20, 2025 · 3 comments
Open

SIGSEGV on template override mismatch #7154

antaalt opened this issue Feb 20, 2025 · 3 comments
Labels
bug Bug, regression, crash needs-triage Awaiting triage

Comments

@antaalt
Copy link

antaalt commented Feb 20, 2025

Description
I am encountering a SIGSEGV when setting a type template parameter with a default value: By passing it in a function with overriden template parameters as inout, it produces a crash.

Steps to Reproduce
Here is a small repro sample code

template <typename T, typename A = uint> // 1. Here we set default template parameter value
struct TemplatedType {
    T value;
};
template<typename T>
void increment(inout TemplatedType<T, float> value) { // 2. Here we require a second parameter different from the default one. The inout is important there
  value.value += 1.0;
}
void main() {
  TemplatedType<float> oui; // 3. Here we define with second template parameter as default
  increment<float>(oui); // 4. Here we should have an error, but instead we have a SIGSEGV
}

Here is a link on godbolt

Actual Behavior
This should not crash and simply return an error, such as C++ with visual studio.

Environment

  • DXC version 1.8.2407
  • Host Operating System Windows 11 & Godbolt
@antaalt antaalt added bug Bug, regression, crash needs-triage Awaiting triage labels Feb 20, 2025
@devshgraphicsprogramming

We might be suffering from a similar bug, we're crashing with SIGSEGV here too
https://godbolt.org/z/87To9xrTd

If you comment out the OrenNayar alias on line 12903 it stops crashing.

@devshgraphicsprogramming

I cut down the repro, in our case it may be caused by __decltype abuse
https://godbolt.org/z/oe8zKEfs1

@devshgraphicsprogramming

Ok __decltype SIGSEGVs the compiler when two overrides of a static method exist which both take a template

    template<class ObserverRayDirInfo>
    static this_t create(const vector3_type L, const surface_interactions::SIsotropic<ObserverRayDirInfo> interaction)
    {
        const vector3_type V = interaction.V.getDirection();
        const scalar_type VdotL = nbl::hlsl::dot<vector3_type>(V,L);
        return create(L, VdotL, interaction.N);
    }
    template<class ObserverRayDirInfo>
    static this_t create(const vector3_type L, const surface_interactions::SAnisotropic<ObserverRayDirInfo> interaction)
    {
        const vector3_type V = interaction.V.getDirection();
        const scalar_type VdotL = nbl::hlsl::dot<vector3_type>(V,L);
        return create(L,VdotL,interaction.T,interaction.B,interaction.N);
    }

and then

template<typename T>
using impl0 = __decltype(T::template create<typename T::ray_dir_info_type>(::nbl::hlsl::experimental::declval< typename T::vector3_type >(),::nbl::hlsl::experimental::declval< typename T::isotropic_type >()));
using crash0 = impl0<sample_t>;

Compiles: https://godbolt.org/z/17sfqxjr5
Crashes: https://godbolt.org/z/dqEoMcajv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash needs-triage Awaiting triage
Projects
Status: No status
Development

No branches or pull requests

2 participants