Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Due to unbounded scoping in conditional control flow, during runtime certain variables might be non-existing. Consider the following example script
foo = function(Matrix[Double] A, Matrix[Double] B, Double d) return( Matrix[Double] C) { C = A; if( d>0 ) C = C + B; } X1 = rand(rows=1000,cols=1000); if(sum(X1) < 1) X2 = rand(rows=1000,cols=1000); X3 = foo(X1, X2, 7); print(sum(X3));
Depending on the data, X2 is not existing. We need to improve the error handling of these cases as the user currently gets the following unhelpful error message:
Caused by: org.apache.sysml.runtime.DMLRuntimeException: ERROR: Runtime error in program block generated from statement block between lines 14 and 14 -- Error evaluating instruction: CP°extfunct°.defaultNS°foo°3°1°X1·MATRIX·DOUBLE°X2·MATRIX·DOUBLE°7·SCALAR·INT·true°X3 at org.apache.sysml.runtime.controlprogram.ProgramBlock.executeSingleInstruction(ProgramBlock.java:335) at org.apache.sysml.runtime.controlprogram.ProgramBlock.executeInstructions(ProgramBlock.java:224) at org.apache.sysml.runtime.controlprogram.ProgramBlock.execute(ProgramBlock.java:168) at org.apache.sysml.runtime.controlprogram.Program.execute(Program.java:145) ... 8 more Caused by: org.apache.sysml.runtime.DMLRuntimeException: Unknown variable: null at org.apache.sysml.runtime.controlprogram.context.ExecutionContext.getScalarInput(ExecutionContext.java:395) at org.apache.sysml.runtime.instructions.cp.FunctionCallCPInstruction.processInstruction(FunctionCallCPInstruction.java:151) at org.apache.sysml.runtime.controlprogram.ProgramBlock.executeSingleInstruction(ProgramBlock.java:305)