GraphViz C library crash in gvFreeLayout related to dot_cleanup


I have recently begun using the GraphViz C library in my software. Unfortunately, when I repeatedly remove edges using agdelete, the program crashes with the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffdbde31fc in zapinlist () from /usr/lib/graphviz/
(gdb) bt
#0 0x00007fffdbde31fc in zapinlist () from /usr/lib/graphviz/
#1 0x00007fffdbde4a47 in dot_cleanup () from /usr/lib/graphviz/
#2 0x00007ffff4cd9b35 in gvFreeLayout () from /usr/lib/

The code that I use to delete edges is as follows:

agdelete(graph_, name);

The code that I use to regenerate the graph, in which the program appears to be crashing, is the following:

gvFreeLayout(context_, graph_);
gvLayout(context_, graph_, "dot");

Any help with this issue would be greatly appreciated!

Thank you!

Without seeing more of the

Without seeing more of the program, I can only hazard a guess. Are you deleting edges before the call to gvFreeLayout? I think you should avoid significant graph changes until after you have called gvFreeLayout. If this isn't the case, please post a small version of your code that we can test. Or better, submit a bug report.

Thank you for your quick

Thank you for your quick reply; I think you're right. Last night I tried calling gvFreeLayout before removing nodes/edges, and that has appeared to fix the problem. I wasn't sure that was the issue, but after your response I'm more confident that it's fixed. Thanks again!