SlideShare a Scribd company logo
1 of 24
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.

More Related Content

What's hot

Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
07 control+structures
07 control+structures07 control+structures
07 control+structuresbaran19901990
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc pptpssraikar
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructsGopikaS12
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming CourseDennis Chang
 
4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana4 compiler lab - Syntax Ana
4 compiler lab - Syntax AnaMashaelQ
 
Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Dhiviya Rose
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)Sami Said
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for EngineeringVincenzo De Florio
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLE2MATRIX
 
AVR_Course_Day3 c programming
AVR_Course_Day3 c programmingAVR_Course_Day3 c programming
AVR_Course_Day3 c programmingMohamed Ali
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorialraju reddy
 

What's hot (20)

Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
07 control+structures
07 control+structures07 control+structures
07 control+structures
 
Lex and Yacc ppt
Lex and Yacc pptLex and Yacc ppt
Lex and Yacc ppt
 
C formatted and unformatted input and output constructs
C  formatted and unformatted input and output constructsC  formatted and unformatted input and output constructs
C formatted and unformatted input and output constructs
 
C++ Programming Course
C++ Programming CourseC++ Programming Course
C++ Programming Course
 
4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana4 compiler lab - Syntax Ana
4 compiler lab - Syntax Ana
 
Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2
 
Compiler Design Tutorial
Compiler Design Tutorial Compiler Design Tutorial
Compiler Design Tutorial
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Cd lab manual
Cd lab manualCd lab manual
Cd lab manual
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Ch6
Ch6Ch6
Ch6
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for Engineering
 
System Verilog Tutorial - VHDL
System Verilog Tutorial - VHDLSystem Verilog Tutorial - VHDL
System Verilog Tutorial - VHDL
 
verilog
verilogverilog
verilog
 
AVR_Course_Day3 c programming
AVR_Course_Day3 c programmingAVR_Course_Day3 c programming
AVR_Course_Day3 c programming
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
C Programming
C ProgrammingC Programming
C Programming
 

Viewers also liked

Lec08-CS110 Computational Engineering
Lec08-CS110 Computational EngineeringLec08-CS110 Computational Engineering
Lec08-CS110 Computational EngineeringSri Harsha Pamu
 
&lt;marquee>html title testfsdjk34254&lt;/marquee>
&lt;marquee>html title testfsdjk34254&lt;/marquee>&lt;marquee>html title testfsdjk34254&lt;/marquee>
&lt;marquee>html title testfsdjk34254&lt;/marquee>slideshareperson2
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypesMonika Sanghani
 
XP - eXtreme Programming - 2010
XP - eXtreme Programming - 2010XP - eXtreme Programming - 2010
XP - eXtreme Programming - 2010Jônatas Paganini
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
Floating point units
Floating point unitsFloating point units
Floating point unitsdipugovind
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationRitu Ranjan Shrivastwa
 
floating point multiplier
floating point multiplierfloating point multiplier
floating point multiplierBipin Likhar
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAAzhar Syed
 
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Rahul Borthakur
 

Viewers also liked (12)

Lec08-CS110 Computational Engineering
Lec08-CS110 Computational EngineeringLec08-CS110 Computational Engineering
Lec08-CS110 Computational Engineering
 
&lt;marquee>html title testfsdjk34254&lt;/marquee>
&lt;marquee>html title testfsdjk34254&lt;/marquee>&lt;marquee>html title testfsdjk34254&lt;/marquee>
&lt;marquee>html title testfsdjk34254&lt;/marquee>
 
Memory management of datatypes
Memory management of datatypesMemory management of datatypes
Memory management of datatypes
 
IEEE Floating Point
IEEE Floating PointIEEE Floating Point
IEEE Floating Point
 
XP - eXtreme Programming - 2010
XP - eXtreme Programming - 2010XP - eXtreme Programming - 2010
XP - eXtreme Programming - 2010
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Floating Point Numbers
Floating Point NumbersFloating Point Numbers
Floating Point Numbers
 
Floating point units
Floating point unitsFloating point units
Floating point units
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
floating point multiplier
floating point multiplierfloating point multiplier
floating point multiplier
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGA
 
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
 

Similar to Code Analysis-run time error prediction

The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionSarmad Ali
 
0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdfKhaledIbrahim10923
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler ConstructionAhmed Raza
 
Static Code Analysis and Cppcheck
Static Code Analysis and CppcheckStatic Code Analysis and Cppcheck
Static Code Analysis and CppcheckZachary Blair
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone CivettaCocoaHeads France
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTElena Laskavaia
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]Abhishek Sinha
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
Valuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler DesignValuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler DesignLesa Cote
 
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis ToolsGNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis ToolsAdaCore
 

Similar to Code Analysis-run time error prediction (20)

Cpcs302 1
Cpcs302  1Cpcs302  1
Cpcs302 1
 
CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019CodeChecker Overview Nov 2019
CodeChecker Overview Nov 2019
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
Ch1 (1).ppt
Ch1 (1).pptCh1 (1).ppt
Ch1 (1).ppt
 
0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf0100_Embeded_C_CompilationProcess.pdf
0100_Embeded_C_CompilationProcess.pdf
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
CodeChecker summary 21062021
CodeChecker summary 21062021CodeChecker summary 21062021
CodeChecker summary 21062021
 
Static Code Analysis and Cppcheck
Static Code Analysis and CppcheckStatic Code Analysis and Cppcheck
Static Code Analysis and Cppcheck
 
Compiler design
Compiler designCompiler design
Compiler design
 
Cd econtent link1
Cd econtent link1Cd econtent link1
Cd econtent link1
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDTEclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
Eclipse Con 2015: Codan - a C/C++ Code Analysis Framework for CDT
 
Programming in C [Module One]
Programming in C [Module One]Programming in C [Module One]
Programming in C [Module One]
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Valuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler DesignValuable Information on Lexical Analysis in Compiler Design
Valuable Information on Lexical Analysis in Compiler Design
 
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis ToolsGNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
GNAT Pro User Day: Latest Advances in AdaCore Static Analysis Tools
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Code Analysis-run time error prediction

  • 2. Overview • Introduction • Existing solutions • Run time errors • Design • Implementation • Future Work
  • 3. 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.
  • 4. 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
  • 5. 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
  • 7. 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
  • 8. 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  
  • 9. 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.
  • 10. 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.
  • 11. 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
  • 12.   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.
  • 13. 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 */
  • 14. 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.
  • 15. 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
  • 16. 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.
  • 17. Specifications •Why Java for developing analyser?
  • 19. 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
  • 20. 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
  • 21. 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:
  • 23. 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
  • 24. 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.