avishek-sen-gupta / cobol-rekt

An evolving toolkit of capabilities helpful for reverse engineering legacy Cobol code
MIT License
89 stars 9 forks source link

Issue: NoSuchElementException #59

Open acurat opened 1 day ago

acurat commented 1 day ago

Ran into this error trying to summarize a program. Please let me know if you need any other info.


[2024-11-06 14:17:23] [FINER] Setting value for 01WS-END-LITERALPICX(29)VALUE'END WORKING STORAGE - OLWS810'. 
[2024-11-06 14:17:23] [FINER] Setting value for 01DFHCOMMAREAPICX(99999). 
java.util.NoSuchElementException
    at java.base/java.util.List.getFirst(List.java:825)
    at org.smojol.common.vm.structure.Format1DataStructure.typeSpecForSingle(Format1DataStructure.java:207)
    at org.smojol.common.vm.structure.Format1DataStructure.calculateMemoryRequirements(Format1DataStructure.java:200)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.smojol.common.vm.structure.Format1DataStructure.typeSpecForSingle(Format1DataStructure.java:209)
    at org.smojol.common.vm.structure.Format1DataStructure.calculateMemoryRequirements(Format1DataStructure.java:200)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.smojol.common.vm.structure.Format1DataStructure.typeSpecForSingle(Format1DataStructure.java:209)
    at org.smojol.common.vm.structure.Format1DataStructure.calculateMemoryRequirements(Format1DataStructure.java:200)
    at org.smojol.common.structure.CobolDataStructureBuilder.build(CobolDataStructureBuilder.java:41)
    at org.smojol.toolkit.analysis.validation.DataStructureValidation$1.run(DataStructureValidation.java:31)
    at org.smojol.toolkit.analysis.pipeline.ParsePipeline.parse(ParsePipeline.java:155)
    at org.smojol.toolkit.analysis.pipeline.ParsePipeline.parse(ParsePipeline.java:81)
    at org.smojol.toolkit.analysis.task.analysis.BuildSeedModelTask.run(BuildSeedModelTask.java:30)
    at org.smojol.toolkit.task.SmojolTasks$15.run(SmojolTasks.java:169)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.AbstractList$RandomAccessSpliterator.forEachRemaining(AbstractList.java:722)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
    at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
    at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
    at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
    at org.smojol.toolkit.task.SmojolTasks.run(SmojolTasks.java:64)
    at org.smojol.toolkit.analysis.task.analysis.CodeTaskRunner.runForProgram(CodeTaskRunner.java:154)
    at org.smojol.toolkit.analysis.task.analysis.CodeTaskRunner.runForPrograms(CodeTaskRunner.java:95)
    at org.smojol.cli.MultiCommand.processPrograms(MultiCommand.java:105)
    at org.smojol.cli.MultiCommand.call(MultiCommand.java:92)
    at org.smojol.cli.MultiCommand.call(MultiCommand.java:30)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at org.smojol.cli.MultiCommandCLI.main(MultiCommandCLI.java:10)
[2024-11-06 14:17:23] [FINE] Runtime.exit() called with status: 1 ```
avishek-sen-gupta commented 1 day ago

could you paste the space-separated version of the line 01DFHCOMMAREAPICX(99999) here?

acurat commented 1 day ago

Pasting that part of the code...

       LINKAGE SECTION.

       01  DFHCOMMAREA              PIC X(99999).

       PROCEDURE DIVISION USING DFHCOMMAREA.

       0000-MAINLINE.

           STRING WS-THIS-PROGRAM
                   '0000-MAINLINE'
           DELIMITED BY SIZE INTO TDQMSG
           PERFORM 9988-CSMT-LOG
avishek-sen-gupta commented 1 day ago

I'm unable to reproduce this issue from this code fragment. Could I ask you to do two things?