ml4ai / automates

AutoMATES: Automated Model Assembly from Text, Equations, and Software
https://ml4ai.github.io/automates
Other
25 stars 9 forks source link

[PA]: Issue with GrFN generation while accessing in conditional block #277

Closed rsulli55 closed 2 years ago

rsulli55 commented 2 years ago

This was found while writing the if_statement unit test in #275. In the C file for that test, notice that variable a is accessed in the second if block. In the GrFN, we would expect an arrow from a at the top to in the interface node in the second conditional block. Furthermore, the GrFN which is generated cannot be executed and results in the following error:

Executing GrFN...
Traceback (most recent call last):
  File "/home/ryan/projects/automates/scripts/program_analysis/run_gcc_to_grfn.py", line 213, in <module>
    run_gcc_pipeline()
  File "/home/ryan/projects/automates/scripts/program_analysis/run_gcc_to_grfn.py", line 205, in run_gcc_pipeline
    result = grfn(inputs)
  File "/home/ryan/projects/automates/automates/model_assembly/networks.py", line 1197, in __call__
    self.root_subgraph(self, subgraph_to_hyper_edges, node_to_subgraph, set())
  File "/home/ryan/projects/automates/automates/model_assembly/networks.py", line 621, in __call__
    sugraph_execution_result = subgraph(
  File "/home/ryan/projects/automates/automates/model_assembly/networks.py", line 646, in __call__
    to_execute()
  File "/home/ryan/projects/automates/automates/model_assembly/networks.py", line 390, in __call__
    variable = self.outputs[i]
IndexError: list index out of range

Excerpt of relevant code:

    if (a > b) {
        x = b;
        b = a;
    }

    if (x == 3) {
        a = x;
        b = a;
        x = 10;
    }

Here are the CAST and GrFN pdfs created from the C file: if_statement--CAST.pdf if_statement--GrFN.pdf

rsulli55 commented 2 years ago

This issue does not appear using the AnnCAST to GrFN pipeline.