fesch / Structorizer.Desktop

Structorizer is a little tool which you can use to create Nassi-Schneiderman Diagrams (NSD).
https://structorizer.fisch.lu
GNU General Public License v3.0
65 stars 20 forks source link

Import of large Java files (with either long blocks or classes with hundreds of members) may cause stack overflow #1141

Closed codemanyak closed 8 months ago

codemanyak commented 8 months ago

Attempting to import file "lu.fisch.structorizer.gui.Menu.java" reveals the severe risk of a stack overflow during the diagram building phase. It is due to the awkwardness of recursively processing left-recursive reduction rules. Particularly class bodies and statements blocks are prone to calamity. Though most these sequences hardly exceed some 20 elements, some may have dangerous sizes as the followong example snippets from a test log corroborate:

The solution is to convert the reduction tree into a reduction stack first and then to process its element reductions sequentially in a loop.

codemanyak commented 8 months ago

Fixed for Java, and also precauciously for C99 and Pascal parsers, to be delivered with version 3.32-18