[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] possible attributes bug
From: |
Marco Valerio Barbera |
Subject: |
[igraph] possible attributes bug |
Date: |
Fri, 22 Oct 2010 19:42:35 +0200 |
Hello,
I've encountered a strange behaviour using igraph nodes attributes on
a C toy-program.
test.cpp:
#include <stdlib.h>
#include <igraph/igraph.h>
int main(void) {
igraph_t G;
igraph_i_set_attribute_table(&igraph_cattribute_table);
if(igraph_empty(&G, 2, false) != 0)
abort();
if(igraph_cattribute_VAS_set(&G, "name", 0, "0") != 0)
abort();
if(igraph_cattribute_VAS_set(&G, "name", 1, "1") != 0)
abort();
if(igraph_delete_vertices(&G, igraph_vss_1(0)) != 0)
abort();
if(igraph_delete_vertices(&G, igraph_vss_1(0)) != 0)
abort();
igraph_destroy(&G);
return 0;
}
If I compile this program using a simple line like
g++ test.cpp -ligraph
and run it then everything goes fine.
However, if you compile with
g++ test.cpp -ligraph -lmcheck
when I run the program I get a "block freed twice" error message when
igraph_destroy() is called and the program aborts
For those who don't know what the -lmcheck does, it is a GNU extension
that does heap consistency check every time a malloc/free happens
(ref: http://www.gnu.org/s/libc/manual/html_node/Heap-Consistency-Checking.html)
After studying better the issue I noticed that this problem does NOT
happen if you do EITHER ONE of the following things:
1 - comment the igraph_cattribute_VAS_() calls (i.e. don't attach
attributes to nodes but still call the igraph_i_set_attridute_table()
function)
2 - don't delete both the nodes in the graph (i.e. the graph has at
least still one vertex before it is delted)
the memory error reported by the consistency check tool has to be
taken seriously since in a bigger program I'm writing, not compiling
with -lmcheck makes the program go past the igraph_destroy() call but
produces a segm. fault after a few malloc allocation calls.
by the way, running the program with valgrind produces an error too.
I don't know if this strange behaviour is caused by a bug in the
igraph library or if it's me doing something wrong handling the
attributes.
could you please help me?
thanks
mb.
p.s. I add some information that might be useful to understand the behaviour.
os: ubuntu server 64 bit
g++ version: g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
igraph version: both 0.5.3 and 0.5.4 (the first one is the package
that comes from the ubuntu server repository, while the second has
been manually downloaded and compiled. Both the versions show the same
behaviour)
thanks again
- [igraph] possible attributes bug,
Marco Valerio Barbera <=