AntlrParserAdapter and large graphs => StackOverflowException


Antlr generates recursive code of parsing stmt_list. It is not good for large graphs (with long stmt_list).

Parse call causes StackOverflowException :(

I am not sure it is possible to fix it without throwing away ANTLR.


file attachments


stevesindelar wrote Jun 28, 2012 at 11:15 AM

Thanks for pointing this out, i'll have a look at it as soon as i can.

bobbyc wrote Jul 25, 2013 at 10:52 PM

I can reproduce this problem too. The attached DOT file contains 1000 vertices and about 50,000 edges. It blows-up the parser for sure.

Graphviz4Net is pretty awesome (thanks guys!) but this might be a show-stopper for my project.

stevesindelar wrote Jul 27, 2013 at 9:18 PM

It appears to me that it is rather problem of ANTLR. You certainly can try updating ANTRL, don't know if there were any updates to the C# generator, though. Throwing ANTRL away would mean writing the parser by hand, which would be considerable amount of work. What you can also try is making the call stack of your thread bigger http://stackoverflow.com/questions/1042345/how-do-you-change-default-stack-size-for-managed-executable-net

mwherman2000 wrote Nov 27, 2016 at 1:35 PM

What if someone changed the code to use: dot.exe -Tplain format?

Reference: http://www.graphviz.org/doc/info/output.html#d:plain

The complex parsing requirement goes away.

Best regards,
Michael Herman (Toronto)

mwherman2000 wrote Nov 27, 2016 at 1:44 PM

Reading the rest of the documentation: https://graphviz4net.codeplex.com/wikipage?title=Overview%20of%20the%20whole%20Graphviz4Net&referringTitle=Documentation

...there's a paragraph that mentions:

"Graphviz provides also the plain-text output format, which is line oriented language suitable for parsing. However, we found out that this format does not support some features of Graphviz that we wanted to support in our library (e.g., node clusters)."

So I take back my suggestion about using -Tplain format.

Best regards,
Michael Herman (Toronto)