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

Conversation

alsepkow
Copy link
Contributor

@alsepkow alsepkow commented Jul 12, 2025

Fixes #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.

@alsepkow alsepkow changed the title Fix shader source to prevent OOB access for ExecutionTests::AtomicsShared64Test [ExecutionTests] Fix shader source to prevent OOB access for ExecutionTests::AtomicsShared64Test Jul 12, 2025
@alsepkow
Copy link
Contributor Author

I lost access to a machine with a reliable repro. But I did validate that the test still passes with this change on another machine with the updated shader source.

@@ -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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

Out of bounds groupshared array index in ExecutionTest::AtomicsShared64Test
3 participants