[Networkit] SegmentationFault in CoarseningBenchmark

Henning Meyerhenke henning.meyerhenke at kit.edu
Wed Dec 21 15:41:03 CET 2016


Dear Johannes,

Thank you for your note. Sorry for taking so long to answer.

Am 05.12.16 um 19:12 schrieb Johannes Ernst:
> Hello everbody,
> 
> when i compile the C++ part of NetworKit with "scons --optimize=Dbg
> --target=Tests" and call the tests with "./NetworKit-Tests-Dbg
> --gtest_filter=*CoarseningBenchmark* --loglevel=DEBUG" i am asked to
> enter the number of nodes. When i enter a number smaller than 100 the
> program crashes with a segmentation fault. The reason for that is: if
> the number of nodes is smaller than 100,
> ClusteringGenerator::makeRandomClustering is called with 0 as second
> parameter in coarsening/test/CoarseningBenchmark.cpp:34. This leads to
> Aux::Random::integer being called with -1 as parameter which results in
> a very large random number. This number is used as a node index and
> added to a cluster (so the cluster contains a nonexisting node). Then
> Partition::numberOfSubsets is called and the huge random number is used
> as an array index, which leads to the segmentation fault.
> 
> In my opinion the easiest way to fix that, would be to use a fixed
> number larger than 100 instead of asking the user for a number. This
> would be better for automated testing anyway.

It seems that this issue has been already fixed in the meantime.


> A similar question concerns the usage of the assert function. In many
> places statements like "assert(n<maxIndex)" are used to ensure that the
> array-index is not too large. But the asserts are only enabled when
> compiling with --level=Dbg. For example if i create a Graph G with 5
> nodes and then call G.addEdge(4,6) i get a segmentation fault when
> NetworKit is compiled with --level=Opt. So is the range-check for arrays
> intentionally disabled (e.g. for performance reasons)?

Yes, asserts are for debugging purposes and excluded from production
runs due to performance. I would suggest to use explicit tests and not
asserts where it is likely that production runs break the requirements
and performance is (for once) no issue.

Best regards,
Henning

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5399 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.ira.uni-karlsruhe.de/pipermail/networkit/attachments/20161221/0d06e052/attachment.p7s>


More information about the NetworKit mailing list