KarypisLab / METIS

METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering
Other
665 stars 134 forks source link

valgrind error detected in kwayfm.c #48

Closed ajmay81 closed 1 year ago

ajmay81 commented 1 year ago

Some jobs report the following error when run through Valgrind

==12272== Invalid read of size 8
==12272==    at 0x6B7ABF3: libmetis__Greedy_KWayCutOptimize (kwayfm.c:497)
==12272==    by 0x6B76A9E: libmetis__Greedy_KWayOptimize (kwayfm.c:26)
==12272==    by 0x6B73D39: libmetis__RefineKWay (kwayrefine.c:102)
==12272==    by 0x6B514BC: libmetis__MlevelKWayPartitioning (kmetis.c:135)
==12272==    by 0x6B512A6: METIS_PartGraphKway (kmetis.c:74)
==12272==    by 0x6B5C37D: metis_partgraphkway_ (frename.c:38)
...

This refers to

        if (pwgts[i] > maxpwgts[i] || pwgts[i] < minpwgts[i])

Looking at the preceding code it seems that maxpwgts and minpwgts are defined for the whole range 0:nparts+1, which leads me to suspect that pwgts is the problem. I can't see that pwgts, aka graph->pwgts is allocated the correct size of nparts+2 and also whether pwgts[nparts] and pwgts[nparts+1] are defined, but someone who is familiar with the code needs to look.

karypis commented 1 year ago

This was due to some experimental code that should have been removed a long time ago. It is removed. Please check.

ajmay81 commented 1 year ago

Thanks, I can confirm the errors are no longer seen after the removal.