What’s New in Polyspace R2019b?

By Puneet Lal and Anirban Gangopadhyay

Release 2019b of the Polyspace® products contains more checkers, supports more compilers, shows fewer false positives, and reduces setup activities further compared to previous releases. Key new features include a shared variables mode in Polyspace Code Prover™, the ability to verify custom C code in Simulink®, and greater support for coding standards such as AUTOSAR C++14 and CERT® C++ with new post-C++11 checkers.

Shared Variables Mode

Polyspace Code Prover can determine if variables are shared between threads and verify if the shared variables are protected against concurrent access (with locks, temporal exclusion, and so on). In R2019b, you can check your complete application with Polyspace Code Prover for only this global variable sharing and usage.

The analysis reports a list of global variables that are shared and protected, shared and potentially unprotected, and so on. The analysis also shows read and write operations on the variables and other details.

With this capability, you can create a workflow in Polyspace Code Prover where you:

  • Check for run-time errors component by component.
  • Check for global variable sharing and usage on the entire application during integration.

Learn more about shared variables mode and the checks in the Polyspace Code Prover documentation.

Verifying Custom Code in Simulink

You can call C functions in Simulink models from a C Caller block or a Stateflow® chart. In R2019b, you can check these functions for bugs, run-time errors, or coding standard violations with Polyspace, directly from the Simulink model.

You can now check whether handwritten code called from your model has issues even before running your model. You typically use model verification software, such as Simulink Design Verifier™, to check for bugs and run-time errors in a model. When it comes to handwritten code called from models, the model verification software simply ensures that code does not contain errors that render the analysis of the model invalid. With Polyspace, you can perform a complete check on the handwritten code for bugs, run-time errors, and coding standard violations, and supplement the checks at the model level.

The analysis uses function inputs and other call context information from design ranges in the model. In other words, in the model below, the analysis can distinguish between the unbounded inputs to the first C Caller block and the bounded inputs to the second block even when the same function is called from both blocks.

C++11 Checkers (About Lambda Expressions, Scoped Enums, and So On)

In R2019b, Polyspace Bug Finder™ can check for some of the more intricate issues that can happen with C++11 and later.

For instance, in the example below, Polyspace Bug Finder can detect that the lambda expression adder allows a local variable addThis to be accessed outside its scope.

auto createAdder(int amountToAdd) {
int addThis = amountToAdd;
auto adder = [&] (int initialAmount) {
return (initialAmount + addThis);
};
return adder;
}

void func() {
auto AddByTwo = createAdder(2);
int res = AddByTwo(10);
}

With the new checkers, it becomes easier to automate checking of coding standards such as AUTOSAR C++14 and CERT C++. A significant portion of these standards can now be automatically checked with Polyspace Bug Finder.

Learn more about Polyspace Bug Finder checkers.

Checkers Related to Thread APIs

In R2019b, Polyspace Bug Finder can detect issues with thread creation and joining or detaching of POSIX® or C11 threads.

For instance, the C11 standard states that detaching a previously joined thread leads to undefined behavior. Polyspace Bug Finder can detect a possible erroneous sequence of thread operations, for instance, in this example:

#include <stddef.h>
#include <threads.h>
#include <stdlib.h>

extern int thread_func(void *arg);

int main (void)
{
thrd_t t;

if (thrd_success != thrd_create (&t, thread_func, NULL)) {
/* Handle error */
return 0;
}

if (thrd_success != thrd_join (t, 0)) {  
/* Handle error */
return 0;
}

if (thrd_success != thrd_detach (t)) {  
/* Handle error */
return 0;
}

return 0;
}

With the new checkers, almost all CERT C rules can be now be checked automatically with Polyspace Bug Finder.

Learn more about Polyspace Bug Finder checkers.

Other Features

In addition to these major features, R2019b offers other improvements such as:

  • A toolstrip for Polyspace analysis in Simulink
  • The ability to autodetectcompiler versions for GNU and Visual C++ compilers from makefiles
  • Support for Cosmic compilers

For details, see:

Ask the Expert


Puneet Lal, Polyspace Static Analysis Notes Contact Expert

Static Analysis with Polyspace Products