Out of bounds in ParMETIS_V3_PartGeomKway

ParMETIS_V3_PartGeomKway crashes with version 4.0.2, while it ran OK with ParMETIS 3. After some investigation, I have determined that it is overstepping the bounds on the array emarkers at line 114 of xyzpart.c. Changing the line to

if (cand[i].key <= emarkers[j+1]) {

fixes the problem. This catches the case where cand[i].key = emarkers[nbins]. Please let me know if you need more information, or if my fix is incorrect.

RE: I believe you are right about

I believe you are right about lines 231 and 280. There is also a bug on lines 107, 155, 221, and 275.

emarkers[nbins] = gmax*(1.0+2.0*REAL_EPSILON);

should be

emarkers[nbins] = gmax*(1.0+copysign(1.0,gmax)*2.0*REAL_EPSILON);

to account for the fact that gmax can be negative.

RE: Lines to change?

Hi Folks,

Just checking to be sure the emarkers bug is constrained to lines 114 and 161. It looks like there is a similar construct on line 231 and 280 of xyzpart.c.

- Mark

RE: I think this also needs to be

I think this also needs to be done on line 161.