assert failure with nslimit1=0
Steps to reproduce
dot -v -T[testcase.dot](/uploads/c924123004d606d2b4b31c1a1502aa17/testcase.dot)testcase.dot
dot - graphviz version 2.43.0 (0)
libdir = "/usr/lib/x86_64-linux-gnu/graphviz"
Activated plugin library: libgvplugin_dot_layout.so.6
Using layout: dot:dot_layout
Activated plugin library: libgvplugin_core.so.6
Using render: dot:core
Using device: dot:dot:core
The plugin configuration file:
/usr/lib/x86_64-linux-gnu/graphviz/config6a
was successfully loaded.
render : cairo dot dot_json fig gd json json0 map mp pic pov ps svg tk visio vml vrml xdot xdot_json
layout : circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout : textlayout
device : canon cmap cmapx cmapx_np dot dot_json eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 mp pdf pic plain plain-ext png pov ps ps2 svg svgz tk vdx vml vmlz vrml wbmp webp x11 xdot xdot1.2 xdot1.4 xdot_json xlib
loadimage : (lib) eps gd gd2 gif jpe jpeg jpg png ps svg webp xbm
pack info:
mode undefined
size 0
flags 0
margin 8
pack info:
mode node
size 0
flags 0
fontname: "Times-Roman" resolved to: (ps:pango Times New Roman, REGULAR) (PangoCairoFcFont) "Times New Roman, Regular" /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf
network simplex: 3 nodes 3 edges maxiter=0 balance=1
network simplex: 6 nodes 6 edges maxiter=0 balance=0
dot: rank.c:238: cluster_leader: Assertion `leader != NULL' failed.
Aborted
Expected Behaviour
Either a successful render or a meaningful error message.
Actual Behaviour
dot: rank.c:238: cluster_leader: Assertion `leader != NULL' failed.
Aborted
OS Version
Debian
Graphviz Version
Tested on Graphviz 2.44.1
Additional info
This dot file in this issue came from a fuzzer, but has been manually simplified. I don't fully understand what the expected behaviour is with nslimit1 = 0 as there's not much documentation on it, but anything that asserts causes problems when used as a library, batch job, or rpc server.
Here's the backtrace
#7 0x560418ca8c0c in cluster_leader graphviz/v2_44_1/lib/dotgen/rank.c:281:5
#8 0x560418ca7754 in collapse_cluster graphviz/v2_44_1/lib/dotgen/rank.c:311:2
#9 0x560418ca524f in collapse_sets graphviz/v2_44_1/lib/dotgen/rank.c:330:3
#10 0x560418ca4ac7 in dot1_rank graphviz/v2_44_1/lib/dotgen/rank.c:589:5
#11 0x560418ca44db in dot_rank graphviz/v2_44_1/lib/dotgen/rank.c:623:2
#12 0x560418c38be5 in dotLayout graphviz/v2_44_1/lib/dotgen/dotinit.c:311:9
#13 0x560418c384c1 in doDot graphviz/v2_44_1/lib/dotgen/dotinit.c:463:2
#14 0x560418c37eb8 in dot_layout graphviz/v2_44_1/lib/dotgen/dotinit.c:509:22
#15 0x560418bec06d in gvLayoutJobs graphviz/v2_44_1/lib/gvc/gvlayout.c:85:2
#16 0x560418be19fc in gvLayout graphviz/v2_44_1/lib/gvc/gvc.c:65:9
The assert failure can be trivially avoided by changing nslimit1 to any value greater than 0 in the testfile.
If nslimit1 <= 0 then rank2
is called with maxiter=0
causing it to bail early, meaning that there are no suitable nodes for cluster_leader
to assign as leader.
Ideas:
- modify
cluster_leader
to pick lowest rank node rather than rank 0. - modify
dot2_rank
to force maxiter = 1 if nslimit1 <=0. - somehow propagate an error up from
cluster_leader
- silently do nothing in
cluster_leader
etc.