Fix segfault in `igraphCommunityInfomap` call
Fixes #1 (closed).
@anoe The bug was a bit subtle and easy to miss: in the call to igraphCommunityInfomap
we were passing as the last argument for *codelen
the nullPtr
. However, by looking at the C implementation of this function, we can see how we need a valid pointer as the function would write at that address the result of the calculation (igraph_real_t) shortestCodeLength / log(2.0)
.
In terms of "how do I fix this next time", alas I don't have a silver bullet here. First of all, the first step is to make sure we are indeed getting a segfault. Unfortunately neither stack
nor cabal
would be very helpful in this regards when running the tests via stack test
or cabal test
. However, more informative logs could be acquired by running directly the test executable (essentially bypassing stack
or cabal
). I'm a cabal user (but for stack it should be equivalent), so I was able to run something like dist-newstyle/build/x86_64-osx/ghc-8.10.7/haskell-igraph-0.8.5/t/test/build/test
(the path would be slightly different on your machine) to be greeted with a segfault
message, whereas by running this via cabal v2-test
was simply giving me a FAIL
test without an indication of why that was (perhaps the segfault
is emitted to stderr
, albeit I didn't check that was the case).
In theory it should also be possible to throw gdb
at this, but at least on my Mac gdb
is a bit all over the place and not really working well, but luckily a code review was enough here to spot the problem