Main Content

Review and Fix Non-Terminating Call Checks

This topic describes how to systematically review the results of a Non-terminating call check in Polyspace® Code Prover™.

Follow one or more of these steps until you determine a fix for the Non-terminating call check. There are multiple ways to fix the check. For a description of the check and code examples, see Non-terminating call.

For the general workflow on reviewing checks, see Interpret Code Prover Results in Polyspace Desktop User Interface or Interpret Code Prover Results in Polyspace Access Web Interface (Polyspace Access).

A red Non-terminating call check on a function call indicates one of the following:

  • An operation in the function body failed for that particular call. Because there are other calls to the same function that do not cause a failure, the operation failure typically appears as an orange check in the function body.

  • The function does not return to its calling context for other reasons. For example, a loop in the function body does not terminate.

Step 1: Determine Root Cause of Check

Determine the root cause of the check in the function body. You can perform the following steps in the Polyspace user interface only.

  1. Navigate to the function definition.

    Right-click the function call containing the red check. Select Go To Definition, if the option exists.

  2. In the function body, determine if there is a loop where the termination condition is never satisfied.

    Possible fix: Change your code or the function arguments so that the termination condition is satisfied.

  3. Otherwise, in the function body, identify which orange check caused the red Non-terminating call check on the function call.

    If you cannot find the orange check by inspection, rerun verification using the analysis option Sensitivity context. Provide the function name as option argument. The software marks the orange check causing the red Non-terminating call check as a dark orange check.

    For more information, see Sensitivity context (-context-sensitivity).

    For a tutorial on using the option, see Identify Function Call with Run-Time Error.

    Possible fix: Investigate the cause of the orange check. Change your code or the function arguments to avoid the orange check.

Step 2: Look for Common Causes of Check

To trace a Non-terminating call check on a function call to an orange check in the function body, try the following:

  • If the function call contains arguments, in the function body, search for all instances of the function parameters. See if you can find an orange check related to the parameters. Because other calls to the same function do not cause an operation failure, it is likely that the failure is related to the function parameter values in the red call.

    In the following example, in the body of func, search for all instances of arg1 and arg2. Right-click the variable name and select Search For All References.

    void func(int arg1, double arg2) {
      . 
      .
    }
     
    void main() {
      int valInt1,valInt2;
      double valDouble1, valDouble2;
      . 
      .
      func(valInt1, valDouble1);
      func(valInt2, valDouble2);
    }
    Because valInt1 and valDouble1 do not cause an operation failure in func, the failure might be due to valInt2 or valDouble2. Because valInt2 and valDouble2 are copied to arg1 and arg2, the orange check must occur in an operation related to arg1 or arg2.

  • If the function call does not contain arguments, identify what is different between various calls to the function. See if you can relate the source of this difference to an orange check in the function body.

    For instance, if the function reads a global variable, different calls to the function can operate on different values of the global variable. Determine if the function body contains an orange check related to the global variable.