Code Analysis-run time error prediction

33 %
67 %
Information about Code Analysis-run time error prediction
Technology

Published on July 11, 2009

Author: nik1246

Source: slideshare.net

Code Analysis

Overview • Introduction • Existing solutions • Run time errors • Design • Implementation • Future Work

Code Analysis Difference between project success & failure. • If there's going to be a program, there has to be construction. • Code is often the only accurate description of the software available. • Code must follow coding standards and code conventions.

Source code Conventions • 80% of the lifetime cost of a piece of software goes to maintenance. • Hardly any software is maintained for its whole life by the original author. • Code conventions improve the readability of the software. • Source code like any other product should be well packaged

Code optimization based analysis • Code Verification and Run-Time Error prediction at compile time using syntax directed translation. • Predict run time errors without program execution or test cases. • Uses Intermediate Code

Existing Solutions

Possible Run time Errors 1) Detecting uninitialized Variables Using variables before they have been initialized by the program can cause unpredictable results 2) Detecting Overflows, Underflows, and Divide by Zeros

Consider pseudo-code: X=X/(X-Y) Identifying all possible causes for error on the operation: o X and Y may not be initialized   X-Y may overflow or underflow  - X and Y may be equal and cause a division by zero  e X/(X–Y) may overflow or underflow  

All possible values of x & y in program p If the value of x & y both fall on the black line, there is a divide by zero error.

3) Detecting incorrect argument data types and incorrect number of arguments   • Checking of arguments for type and for the correct order of occurrence. • Requires both the calling program and the called program to be compiled with a special compiler option. • Checks can be made to determine if the number and types of arguments in function (and subroutine) calls are consistent with the actual function definitions.

4) Detecting errors with strings at run-time • A string must have a null terminator at the end of the meaningful data in the string. A common mistake is to not allocate room for this extra character. This can also be a problem with dynamic allocation. char * copy_str = malloc( strlen(orig_str) + 1); strcpy(copy_str, orig_str); • The strlen() function returns a count of the data characters which does not include the null terminator. • In the case of dynamic allocation, it might corrupt the heap

  a. Detecting Out-of-bounds indexing of statically and dynamically allocated arrays   A common run-time error is the reading and writing of arrays outside of their declared bounds. b. Detecting Out-of-Bounds Pointer References   A common run-time error for C and C++ programs occurs when a pointer points to memory outside its associated memory block.

Pseudo code for out of bound references for(i=0;i<5;i++) A[i]=i; p=A; for(i=0;i<=5;i++) p++; a=*p; /* out-of-bounds reading using pointers */

5) Detecting Memory Allocation and Deallocation Errors • A memory deallocation error occurs when a portion of memory is deallocated more than once. • Another common source of errors in C and C++ programs is an attempt to use a dangling pointer. A dangling pointer is a pointer to storage that is no longer allocated.

6) Detecting Memory Leaks • A program has a memory leak if during execution the program loses its ability to address a portion of memory because of a programming error; • A pointer points to a location in memory and then all the pointers pointing to this location are set to point somewhere else • A function/subroutine is called, memory is allocated during execution of the function/subroutine, and then the memory is not deallocated upon exit and all pointers to this memory are destroyed

Source code analyzer predicates Reliable: Proven free of run- time errors and under all operating conditions within the scope Faulty: Proven faulty each time the operation is executed. Dead: Proven unreachable (may indicate a functional issue) Unproven: Unproven code section or beyond the scope of the analyzer.

Specifications •Why Java for developing analyser?

Specifications •Why C/C++ as input language?

Design for Code Analyzer Input program (C File) S Lexical Analyzer y m b o l T a b l Parser e IC(SDT) Generation Run Time Error Predictions

Analysis of Code Input Program Lexical Analysis-Stream Tokenizer Parser- Condition = "(" Expression ("=="|"!="|">"|"<"|">="|"<=") Expression ")" Expression = Term {("+"|"-") Term} Term = Factor {("*"|"/") Factor} Factor = number | identifier | Intermediate code generation: Postfix Evaluation

3 address code generation Target Source File: argument operator operand operand result Test(n){ 1 2 int b,a,n,j; 0 < j n if(j<n) 1 if 0 gotol0 { 2 + a b a=a+b;} 3 = a 2 } l0:

Work Done: Intermediate Code

Further Work • Evaluation of intermediate code for performing data flow and control flow analysis. • Prediction of run time errors using intermediate code. • Using code optimization techniques such as constant folding to predict code behavior

REFERENCES • A V. Aho, R Sethi, J D. Ullman., Compilers: Principles, Techniques and Tools, 2nd ed. , Addison-Wesley Pub. Co. • G R. Luecke, J Coyle, J Hoekstra “A Survey of Systems for Detecting Serial Run-Time Errors”, The Iowa State University's High Performance Computing Group, Concurrency and Computation. : Practice and Experience. 18, 15(Dec. 2006), 1885-1907. • T Erkkinen, C Hote “Code Verification and Run-Time Error Detection Through Abstract Interpretation”, AIAA Modeling and Simulation Technologies Conference and Exhibit ,21 - 24 Aug 2006, Keystone, Colorado. • PolySpace Client for C/C++ 6 datasheet. Available HTTP: http://www.mathworks.com/products/polyspaceclientc.html. • D.M. Dhamdhere, Compiler Construction, Tata McGraw-Hill. • Semantic designs, “Flow analysis for control and data”, Available HTTP: http://www.semdesigns.com/Products/DMS/FlowAnalysis.html.

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Prediction Error in Selection of Variables - Documents

Share Prediction Error in Selection of Variables. ... On selection of periodic kernels parameters in time series prediction
Read more

prediction error in wildfire forecasting - Documents

Download prediction error in wildfire forecasting. Transcript. Halmar Halide @ physics unhas CICES 2014, Kendari
Read more

Evaluating the Reliability of Web Services Based on BPEL ...

Evaluating the Reliability of Web Services Based on BPEL Code Structure Analysis and Run-Time ... and error prone. We develop a ... prediction of fault ...
Read more

NCEP SST Analysis

... Prediction/Marine Modeling and Analysis ... error in the satellite retrieval code ... Time Global SST (RTG_SST_HR) analysis ...
Read more

From back-analysis to run-out prediction: a case study in ...

From back-analysis to run-out prediction: ... and numerically back-analysed using the RASH3D continuum mechanics numerical code. ... At the same time, ...
Read more

From back-analysis to run-out prediction: A case study in ...

KeywordsContinuum mechanics–Landslide prediction–Rheological parameters ... particle flow code ... the gully gradually increases over the time.
Read more

Patent US6205174 - Variable bitrate video coding method ...

A variable bitrate coding method includes an iterative process including a first analysis pass and a second prediction pass. Further, followed by a last ...
Read more

Computer Science CSC 405 Introduction to Computer Security

CSC 405 Introduction to Computer Security Topic 3. ... The attacker may use error correction codes to ... •Static source code analysis •Run time ...
Read more