Skip to content

Commit 5ceaf84

Browse files
authored
[ExecutionTests] Fix shader source to prevent OOB access for ExecutionTests::AtomicsShared64Test (microsoft#7641)
Fixes microsoft#5198. ExecutionTests::AtomicsShared64Test could sporadically fail. g_sint64Share is indexed with ix%3 + 1, which could lead to an out of bounds access. Increase the size of g_sint64Share to 4 and ensure all values are initialized.
1 parent 020fbdf commit 5ceaf84

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/clang/unittests/HLSLExec/ShaderOpArith.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,7 @@
19761976
RWStructuredBuffer<uint64_t> g_shareXchg64Buf : register(u5);
19771977
19781978
groupshared uint64_t g_uint64Share[6];
1979-
groupshared int64_t g_sint64Share[3];
1979+
groupshared int64_t g_sint64Share[4];
19801980
groupshared uint64_t g_xchg64Share[64];
19811981
19821982
#define VEC_CALL(op, uav, ix, val) op(uav[ix*stride], val);
@@ -2046,7 +2046,7 @@
20462046
// Zero-init shared memory, with special cases
20472047
if (ix < 6)
20482048
g_uint64Share[ix] = ix == 1 ? 99999999ULL | (99999999ULL << 32) : ix == 3 ? ~0ULL : 0;
2049-
if (ix < 3)
2049+
if (ix < 4)
20502050
g_sint64Share[ix] = ix == 1 ? 99999999ULL | (99999999ULL << 32) : 0;
20512051
if (ix < 64)
20522052
g_xchg64Share[ix] = 0;
@@ -2552,11 +2552,11 @@
25522552
25532553
void InitSharedMem(uint ix) {
25542554
// Zero-init shared memory, with special cases
2555-
if (ix < 6)
2555+
if (ix < 7)
25562556
g_uintShare[ix] = ix == 1 ? 99999999 : ix == 3 ? -1 : 0;
2557-
if (ix < 3)
2557+
if (ix < 4)
25582558
g_sintShare[ix] = ix == 1 ? 99999999 : 0;
2559-
if (ix < 64)
2559+
if (ix < 65)
25602560
g_xchgShare[ix] = 0;
25612561
25622562
GroupMemoryBarrierWithGroupSync();

0 commit comments

Comments
 (0)