introduction to static analysis
play

Introduction to Static Analysis 17654: Analysis of Software - PDF document

Introduction to Static Analysis 17654: Analysis of Software Artifacts Jonathan Aldrich


  1. Introduction to Static Analysis 17�654: Analysis of Software Artifacts Jonathan Aldrich ��������� �������������������������������������������������������� � ���������������� Find the Bug! Source: Engler et al., ���������������������� ������������������������������������������ ������������������� , OSDI ’00. disable interrupts ���������������� ������������������������ re�enable interrupts ��������� �������������������������������������������������������� � ���������������� 1

  2. Metal Interrupt Analysis Source: Engler et al., ���������������������� ������������������������������������������ ������������������� , OSDI ’00. enable => err(double enable) is_enabled enable disable is_disabled end path => err(end path with/intr disabled) disable => err(double disable) ��������� �������������������������������������������������������� � ���������������� Applying the Analysis Source: Engler et al., ���������������������� ������������������������������������������ ������������������� , OSDI ’00. initial state is_enabled transition to is_disabled final state is_disabled: ERROR! transition to is_enabled final state is_enabled is OK ��������� �������������������������������������������������������� � ���������������� 2

  3. Outline • Why static analysis? • The limits of testing and inspection • What is static analysis? • How does static analysis work? • AST Analysis • Dataflow Analysis ��������� �������������������������������������������������������� � ���������������� ��������� �������������������������������������������������������� � ���������������� 3

  4. Process, Cost, and Quality Slide: William Scherlis ���������"���#�"���"�� �$$����"������("������ �����"����"$��"�%�����"� �"$�����������"��$�$���� ����$������&��$��� �������(����%� ���������'������ �!%��#�!�"� ���������" *�"�����"�)��+ ��������������!�� ����%��)����� �������� ������� ������� ����������� ���� ������������������������������������������������ ��������������������� ������������������� � � ����!������������ ��������� �������������������������������������������������������� � ���������������� Root Causes of Errors • Requirements problems • Don’t fit user needs ����������������������������� • Design flaws Hard Does design achieve goals? • Lacks required qualities Is design implemented right? • Implementation errors • Assign Is data initialized? � • Checking Security Is dereference/indexing valid? • Algorithm • Timing Are threads synchronized? Hard • Interface Are interface semantics followed? • Relationship Are invariants maintained? Taxonomy: [Chillarege et al., Orthogonal Defect Classification] ��������� �������������������������������������������������������� � ���������������� 4

  5. Existing Approaches • Testing: �������������� • Limitations ������ • Non�local interactions • Uncommon paths • Verifies features work • Non�determinism • Finds algorithmic problems • Static analysis: �����!����� ���������� • Inspection: ������� ������� • Verifies non�local ������ consistency • Missing requirements • Checks all paths • Design problems • Considers all non� • Style issues deterministic choices • Application logic ��������� �������������������������������������������������������� � ���������������� Static Analysis Finds “Mechanical” Errors • Defects that result from inconsistently following simple, mechanical design rules • Security vulnerabilities • Buffer overruns, unvalidated inputK • Memory errors • Null dereference, uninitialized dataK • Resource leaks • Memory, OS resourcesK • Violations of API or framework rules • e.g. Windows device drivers; real time libraries; GUI frameworks • Exceptions • Arithmetic/library/user�defined • Encapsulation violations • Accessing internal data, calling private functionsK • Race conditions • Two threads access the same data without synchronization ��������� �������������������������������������������������������� �� ���������������� 5

  6. Empirical Results on Static Analysis • Nortel study [Zheng et al. 2006] • 3 C/C++ projects • 3 million LOC total • Early generation static analysis tools • Conclusions • Cost per fault of static analysis 61�72% compared to inspections • Effectively finds assignment, checking faults • Can be used to find potential security vulnerabilities ��������� �������������������������������������������������������� �� ���������������� Empirical Results on Static Analysis • InfoSys study [Chaturvedi 2005] • 5 projects • Average 700 function points each • Compare inspection with and without static analysis • Conclusions • Fewer defects • Higher productivity Adapted from [Chaturvedi 2005] ��������� �������������������������������������������������������� �� ���������������� 6

  7. Quality Assurance at Microsoft (Part 1) • Original process: manual code inspection • Effective when system and team are small • Too many paths to consider as system grew • Early 1990s: add massive system and unit testing • Tests took weeks to run • Diversity of platforms and configurations • Sheer volume of tests • Inefficient detection of common patterns, security holes • Non�local, intermittent, uncommon path bugs • Was treading water in Windows Vista development • Early 2000s: add static analysis • More on this later ��������� �������������������������������������������������������� �� ���������������� Outline • Why static analysis? • What is static analysis? • Abstract state space exploration • How does static analysis work? • What do practical tools look like? • How does it fit into an organization? ��������� �������������������������������������������������������� �� ���������������� 7

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend