masabahmad / CRONO

A Shared Memory Multithreaded Graph Benchmark Suite for Multicores

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Out of bounds errors in apsp

mewais opened this issue · comments

Hi, as the title suggests, I think there's an out of bound error in apsp (although possibly on other benchmarks too, I haven't actually looked there yet).

Here's the details:

  • In do_work there's a posix_memalign((void**) &D, 64, N * sizeof(int)) and a similar one for Q. This clearly allocates an N sized array.
  • In initialize_single_source there's a for (int i = 0; i < N + 1; i++) which obviously works on an N+1 sized array.
  • In initialize_single_source there's also a D[source] = 0; where in the last iteration source is N rather than N-1. So also an N+1 sized array.
  • In do_work, the way next_source is defined and incremented also makes the while loop go from 0 to N+1, which is what actually causes the previous issue to arise.

Now, there's only one thing I am not clear on, basically what is the proper fix? Is the allocation supposed to allocate an N+1 sized array? Or are the indices wrong and should only go from 0 to N?

PS: for help debugging this, compile with -fsanitize=address and these errors will be detected as you run.

Thanks

Hi, an easy fix that comes to mind is to allocate N+1 elements using posix_memalign(), or limit the iterations to N in the initialize function. Let me know if that fixes it (you can pull/fix/push and then I can merge the request).

Yeah both are easy fixes, I am just trying to find out which is more "correct" as I no graph processing expert. Based on your answer, it seems that N + 1 is incorrect, so I should limit the loops to N. I will go with that solution.

I will submit a PR later with this fix for apsp and any other benchmakrs that may have the same issue.

I just submitted a pull request for this. It is also worth noting, some benchmarks leak memory by not freeing their allocations, I did not fix this in the PR.

Any updates?

Hey, sorry I didn't see the replies. I ran tests with the sample.txt as long as the full roadNet-CA. But only for the benchmarks that give an output. So, I couldn't test apsp or bc for example.