RSI Logo

Model-Based Testing and Validation with Reactis®

White Paper: Finding Bugs in C Code with Reactis for C
spacer
Download PDF: Letter  |  A4



 
Spacer

3  Reactis Simulator

Reactis for C Simulator provides an enivronment in which program execution can be carefully controlled and monitored. Simulator’s basic features are similar to traditional source-level debuggers: users can single-step through individual source statements, set breakpoints, and display data values.


Figure 5: Displaying coverage metrics and a C macro expansion during a Simulator session.

However, Simulator also has a number of unique features which make it much more powerful than a traditional debugger. These include reverse execution, the replay of tests generated by Reactis Tester, the graphical display of different coverage metrics, the display of C preprocessor macro-expansions and the capability to fine-tune automatically generated test suites. Figure 5 shows some of the display capabilities of Reactis for C simulator.


Figure 6: Memory error detected by Reactis simulator.

One particularly noteworthy feature of Reactis for C Simulator is the ability to automatically detect memory errors, as shown in Figure 6. A memory error occurs whenever a program reads-from or writes-to an invalid address. Memory errors are particularly common in C programs because the C programming language gives the programmer direct access to the program’s memory, which can boost performance but also allows software defects to access arbitrary memory locations. Typical memory errors include the use of out-of-bounds array indices, buffer overruns, dangling heap pointers (accessing a region of heap-allocated memory after the memory has been freed), dangling stack pointers (accessing a pointer to a local variable of a function after the function has returned) and the use of pointers cast from incorrect numeric values.

Memory errors can be very difficult to debug using a traditional debugger because there is often a long delay between the point where the memory error occurs and the point where the program crashes or produces an invalid output. With Reactis for C Simulator, memory errors are detected immediately as they occur, allowing the cause of the error to be quickly identified and fixed.