Hello everyone. For some reason when i run the following code i get a access memory violation error.
[\code]
void indexing(list<string> passwordList, char ** pwdAry, int * cudaIndexAry) {
for (int y = 0; y < gridSize; y++) {
//Loop through blocks(x)
for (int x = 0; x < gridSize; x++) {
//Loop through each thread within each block
threadID = 0;
for (int l = 0; l < (blockSize*blockSize); l++) {
//Give each thread a password index
for (int j = 0; j < numPerThread; j++) {
//only runs once
if (runFlag == 1) {
while (temp.size() != 0) {
string tmp = temp.front();
char * val;
val = new char[1024];
These are normally to do with something not being initialised, or access outside of an array boundary. If one uses the STL these problems can be avoided. On the other hand you may have a reason for doing a C program.
Can we also ask what the purpose of the program is?
And please provide a minimal program that we can compile & run with cpp.sh (the gear icon at the top right of a code snippet)
With tags, I just use the <> button on the format menu, but here is the full article on tags:
The other omnipresent advice to is use a debugger. One can quickly solve problems like this.
Also, try not to mix C and C++ coding. With C++ it is easier to use the STL containers std::string and std::vector etc, rather than char arrays and pointers.
val[currItr] = '\0';
Where does currItr get set? This function increments it but never sets it or decrements it. Maybe it just keeps growing and growing until it 1024 or larger, at which time this will be an out-of-bounds array access.
It's hard to say what else might be wrong. If possible, provide a working program that shows the error