Skip to content

[ExecutionTests] Fix shader source to prevent OOB access for ExecutionTests::AtomicsShared64Test #7641

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/clang/unittests/HLSLExec/ShaderOpArith.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@
RWStructuredBuffer<uint64_t> g_shareXchg64Buf : register(u5);

groupshared uint64_t g_uint64Share[6];
groupshared int64_t g_sint64Share[3];
groupshared int64_t g_sint64Share[4];
groupshared uint64_t g_xchg64Share[64];

#define VEC_CALL(op, uav, ix, val) op(uav[ix*stride], val);
Expand Down Expand Up @@ -2046,7 +2046,7 @@
// Zero-init shared memory, with special cases
if (ix < 6)
g_uint64Share[ix] = ix == 1 ? 99999999ULL | (99999999ULL << 32) : ix == 3 ? ~0ULL : 0;
if (ix < 3)
if (ix < 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could fix the same issue under AtomicsHeap as well? It has:

groupshared uint g_uintShare[12];
groupshared int g_sintShare[6];
groupshared uint g_xchgShare[128];

void InitSharedMem(uint ix) {
// Zero-init shared memory, with special cases
if (ix < 6)
g_uintShare[ix] = ix == 1 ? 99999999 : ix == 3 ? -1 : 0;
if (ix < 3)
g_sintShare[ix] = ix == 1 ? 99999999 : 0;
if (ix < 64)
g_xchgShare[ix] = 0;

I'm not even sure why the groupshared arrays were doubled in size there, since it doesn't initialize or use the second half of g_uintShare or g_xchgShare. For g_sintShare, it just uses one extra element (though it could have indexed differently for g_sintShare as there really are only 2 elements used).

g_sint64Share[ix] = ix == 1 ? 99999999ULL | (99999999ULL << 32) : 0;
if (ix < 64)
g_xchg64Share[ix] = 0;
Expand Down