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

Vector element index out-of-bounds not leading to compile error #3693

Open
mstrgram opened this issue Apr 19, 2021 · 0 comments
Open

Vector element index out-of-bounds not leading to compile error #3693

mstrgram opened this issue Apr 19, 2021 · 0 comments
Labels
bug Bug, regression, crash diagnostic Issues for diagnostics
Milestone

Comments

@mstrgram
Copy link

It is currently possible to index vector elements out-of-bounds without the compiler issuing and error:

// Load index buffer
uint indexOffset = PrimitiveIndex() * 3 /* indices per primitive */ * 4 /* 4 bytes per index*/;
const uint3 indices = g_indices.Load3(indexOffset);

// Retrieve corresponding vertex normals for the triangle vertices.
float3 vertexNormals[3] = { g_vertices[indices[0]].normal, g_vertices[indices[1]].normal, g_vertices[indices[3]].normal };

// Compute the triangle's interpolated normal
float3 triangleNormal = HitAttribute(vertexNormals, attr);

Notice the indices[3] above is out-of-bounds.

Above can be compiled with this command line (shader attached to bug)

dxc.exe /T lib_6_6 /Zpr /all_resources_bound /Zi /Od /Vn"g_DefaultRT_DXIL_Lib" /Fh"DefaultRT.dxil-lib.h" /nologo DefaultRT.hlsl

Shader repro attached: DefaultRT.zip

@llvm-beanz llvm-beanz added the needs-triage Awaiting triage label Jun 29, 2023
@damyanp damyanp added bug Bug, regression, crash diagnostic Issues for diagnostics and removed needs-triage Awaiting triage labels Apr 18, 2024
@damyanp damyanp added this to the Dormant milestone Apr 18, 2024
@damyanp damyanp moved this to Triaged in HLSL Triage Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash diagnostic Issues for diagnostics
Projects
Status: Triaged
Development

No branches or pull requests

3 participants