Skip to content

[DXIL] Null pointer exception due to double floating-point literals in fmod intrinsic #6410

@LukasBanana

Description

@LukasBanana

Description
There is a null pointer exception during the translation of FMod (TranslateFMod) when the arguments are floating-point literals, because the latest DXC version does not reduce them to float during compilation. The null pointer occurs inside TrivialDxilUnaryOperation(OP::OpCode::Frc, absDiv, hlslOP, Builder) because Frc won't find the respective function for double-precision floats. Previous versions had this assertion in OP::GetOpFunc:

DXASSERT(IsOverloadLegal(opCode, pOverloadType), "otherwise the caller requested illegal operation overload (eg HLSL function with unsupported types for mapped intrinsic function)");

But the latest version only returns a null pointer that is not handled correctly:

if (!IsOverloadLegal(opCode, pOverloadType))
  return nullptr;

Steps to Reproduce
This issue can be reproduced with the latest version of the main branch and compiling with dxc -E PSMain -T ps_6_0 (or by following https://godbolt.org/z/beK7oPsx6):

float4 PSMain() : SV_Target {
    return (float4)fmod(1.0, 2.0);
}

Making the floating-point literals explicitly single-precision with the f suffix compiles fine:

float4 PSMain() : SV_Target {
    return (float4)fmod(1.0f, 2.0f);
}

This does not reproduce with other intrinsics such as sin.

Metadata

Metadata

Assignees

Labels

bugBug, regression, crashcrashDXC crashing or hitting an assertrcaCandidate for a root cause analysis discussionsm6.8Shader Model 6.8validationRelated to validation or signing

Type

No type

Projects

Status

Done

Status

Triaged

Relationships

None yet

Development

No branches or pull requests

Issue actions