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

Out-of-bounds read in reduction_kernel.cu variant reduce6 for array size 1 #21

Closed
emjotde opened this issue Nov 20, 2019 · 4 comments
Closed

Comments

@emjotde
Copy link

emjotde commented Nov 20, 2019

Hi,
your kernel reduce6 from the reduction example does an out-of-bounds read for trivial input size 1 here:

if (nIsPow2 || i + blockSize < n) mySum += g_idata[i + blockSize];

This is caused by determining that size 1 is also a power of 2 here:

extern "C" bool isPow2(unsigned int x) { return ((x & (x - 1)) == 0); }

but incorrectly assuming that we can increase by blockSize (==1).

Best,
Marcin

@mdoijade
Copy link
Collaborator

@emjotde samples sources are expected to be used as is, modified source bugs are expected. closing this issue.

@emjotde
Copy link
Author

emjotde commented Nov 26, 2019

It's not really a modified source bug. The bug is there regardless whether I modify it or not. In the very least the algorithm isn't working as advertised in this snippet. Considering that these samples have an encyclopedic role leaving it in there seems borderline irresponsible.

This call


will read out of bounds for size 1.

@mdoijade
Copy link
Collaborator

@emjotde yes this needs to be investigated reopening. thanks for providing details.
just on a side note, size==1 is not good input for GPU.

@mdoijade mdoijade reopened this Nov 26, 2019
@mdoijade
Copy link
Collaborator

mdoijade commented Jun 7, 2020

This is fixed now on the tot, closing the issue.

@mdoijade mdoijade closed this as completed Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants