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

Access violation (silent, no error messages generated) when trying to build pixel shader #3377

Open
Dwedit opened this issue Jan 21, 2021 · 5 comments
Labels
bug Bug, regression, crash crash DXC crashing or hitting an assert incorrect-code Issues relating to handling of incorrect code
Milestone

Comments

@Dwedit
Copy link

Dwedit commented Jan 21, 2021

This is a port of a D3D9 trivial shader that just samples a texture. It successfully compiles on FXC as Pixel Shader 5.0, but fails to build on DXC as Pixel Shader 6.0.

No compile errors are displayed at all. echo %ERRORLEVEL% returns -1073741819 (0xC0000005, Access Violation)

There are probably mistakes in this code, but I have no clue what they are, as no compiler errors are being displayed.

SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; };

void main_vertex
(
	float4 position	: POSITION,
	float4 color	: COLOR,
	float2 texCoord : TEXCOORD0,

	uniform float4x4 modelViewProj,

	out float4 oPosition : POSITION,
	out float4 oColor    : COLOR,
	out float2 otexCoord : TEXCOORD
)
{
	oPosition = mul(modelViewProj, position);
	oColor = color;
	otexCoord = texCoord;
}

float4 main_fragment(float2 texCoord : TEXCOORD0, uniform Texture2D<float4> decal : TEXUNIT0) : SV_Target
{
	return decal.Sample(PointSampler, texCoord);
}
@Dwedit Dwedit changed the title No compiler errors displayed when pixel shader fails to build Access violation (silent, no error messages generated) when trying to build pixel shader Jan 21, 2021
@Dwedit
Copy link
Author

Dwedit commented Jan 21, 2021

Additional information:

Crashes in a memory copy, Source address = FEEEFEEEABABABAB

Stack trace from a debugger:

dxcompiler.std::vector<unsigned int,std::allocator<unsigned int> >::_Emplace_reallocate<unsigned int &>+CA from dxcompiler.memmove                                                                                                                                                                                                User
dxcompiler.operator new+1B from ???                                                                                                                                                                                                                                                                                               User
dxcompiler.hlsl::DxilParameterAnnotation::AppendSemanticIndex+2E from dxcompiler.public: unsigned int * __ptr64 __cdecl std::vector<unsigned int,class std::allocator<unsigned int> >::_Emplace_reallocate<unsigned int & __ptr64>(unsigned int * __ptr64 const,unsigned int & __ptr64) __ptr64                                   User
dxcompiler.AllocateSemanticIndex+16D from dxcompiler.public: void __cdecl hlsl::DxilParameterAnnotation::AppendSemanticIndex(unsigned int) __ptr64                                                                                                                                                                                User
dxcompiler.hlsl::HLMatrixType::isa+39 from dxcompiler.memcmp                                                                                                                                                                                                                                                                      User
dxcompiler.hlsl::DxilParameterAnnotation::AppendSemanticIndex+2E from dxcompiler.public: unsigned int * __ptr64 __cdecl std::vector<unsigned int,class std::allocator<unsigned int> >::_Emplace_reallocate<unsigned int & __ptr64>(unsigned int * __ptr64 const,unsigned int & __ptr64) __ptr64                                   User
dxcompiler.AllocateSemanticIndex+F3 from dxcompiler.AllocateSemanticIndex                                                                                                                                                                                                                                                         User
dxcompiler.hlsl::HLMatrixType::isa+39 from dxcompiler.memcmp                                                                                                                                                                                                                                                                      User
dxcompiler.AllocateSemanticIndex+F3 from dxcompiler.AllocateSemanticIndex                                                                                                                                                                                                                                                         User
dxcompiler.`anonymous namespace'::SROA_Parameter_HLSL::allocateSemanticIndex+39A from dxcompiler.AllocateSemanticIndex                                                                                                                                                                                                            User
dxcompiler.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign+3C from dxcompiler.memmove                                                                                                                                                                                                                User
dxcompiler.`anonymous namespace'::SROA_Parameter_HLSL::flattenArgument+28BC from dxcompiler.`anonymous namespace'::SROA_Parameter_HLSL::allocateSemanticIndex                                                                                                                                                                     User
ntdll.00007FF886E4B24F from ntdll.00007FF886E3BFB0                                                                                                                                                                                                                                                                                System

@tex3d
Copy link
Contributor

tex3d commented Mar 15, 2021

While the compiler should not crash here, dxc does not support uniform function arguments this way. The uniform float4x4 modelViewProj and uniform Texture2D<float4> decal arguments should be specified outside the function arguments. The semantic won't be preserved on the Texture2D argument either, unless TEXUNIT0 actually is a macro defined to something like register(t0).

The SamplerState details { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; } is legacy deprecated effect syntax, and dxc does not compile effects, so it will be ignored, and likely disallowed in a future language version.

But as I said, dxc shouldn't crash here, so thanks for that report.

@llvm-beanz
Copy link
Collaborator

Crash still reproduces see godbolt

@damyanp
Copy link
Member

damyanp commented Jul 9, 2024

Still repros.

@damyanp damyanp added the matrix-bug Bugs relating to matrix types label Jul 9, 2024
@damyanp damyanp moved this to Triaged in HLSL Triage Jul 9, 2024
@damyanp damyanp added this to the Dormant milestone Jul 9, 2024
@damyanp damyanp added incorrect-code Issues relating to handling of incorrect code and removed matrix-bug Bugs relating to matrix types labels Jul 9, 2024
@damyanp
Copy link
Member

damyanp commented Jul 9, 2024

Although the call stack above looks like it is going through matrix code, when looking at more minimal repros of this matrices aren't involved. Main issue seems to be around having a semantic set on a texture parameter to the entry point - and these shouldn't be allowed anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash crash DXC crashing or hitting an assert incorrect-code Issues relating to handling of incorrect code
Projects
Status: Triaged
Development

No branches or pull requests

4 participants