SlideShare a Scribd company logo
Hidden Truths in Dead
Software Paths
Michael Eichberg, Ben Hermann, Mira Mezini, and
Leonid Glanz
ESEC/FSE 2015, Bergamo, Italy
When is a path dead?
if	
  (maxBits	
  >	
  4	
  ||	
  maxBits	
  <	
  8)	
  {	
  
	
  	
  	
  maxBits	
  =	
  8;	
  
}	
  
if	
  (maxBits	
  >	
  8)	
  {	
  
	
  	
  	
  maxBits	
  =	
  16;	
  
}
OpenJDK 8 update 25, com.sun.imageio.plugins.png.PNGMetadata, line 1842ff
Hidden inside a 278 LOC method
Hypothesis
In well-written code every path
between an instruction and all its
successors is eventually taken
A path that will never be taken
indicates an issue
Identifying Infeasible Paths
public	
  static	
  X	
  doX(SomeType[]	
  array)	
  {	
  
if	
  (array	
  !=	
  null	
  ||	
  array.length	
  >	
  0)	
  {	
  (a)	
  }	
  
//	
  …	
  (b)	
  
}//	
  (ex)
1: public static X doX(SomeType[] array){
2: if (array != null || array.length > 0) {(a) }
5: // … (b)
6: }// (ex)
ifnonnull array arraylength array ifgt (>0)
(a)
(b) (ex)
(B) Corresponding CFG
true true false
false
(A) Java Source Code.
ifnonnull array arraylength array ifgt (>0)
(C) Computed AIFG
false
Java Bytecode
Java Bytecode
:- array is null
CFG
Identifying Infeasible Paths
1: public static X doX(SomeType[] array){
2: if (array != null || array.length > 0) {(a) }
5: // … (b)
6: }// (ex)
ifnonnull array arraylength array ifgt (>0)
(a)
(b) (ex)
(B) Corresponding CFG
true true false
false
ifnonnull array arraylength array ifgt (>0)
(a)
(b) (ex)
(C) Computed AIFG
true true false
false
relevant missing edge
a missing edge
Java Bytecode
Java Bytecode
:- array is null
:- array not null
1: public static X doX(SomeType[] array){
2: if (array != null || array.length > 0) {(a) }
5: // … (b)
6: }// (ex)
ifnonnull array arraylength array ifgt (>0)
(a)
(b) (ex)
(B) Corresponding CFG
true true false
false
ifnonnull array arraylength array ifgt (>0)
(a)
(b) (ex)
(C) Computed AIFG
true true false
false
relevant missing edge
a missing edge
Java Bytecode
Java Bytecode
:- array is null
:- array not null
CFG
AIFG
Abstract Interpretation
Not targeted at a specific goal
Not a whole program analysis,
but instead everything may be an entry point
Inter-procedural, path-, flow-, object- and context-sensitive

with configurable call chain length (typically low)
Abstract Interpretation
Integers
support all arithmetic operations (of the JVM)
maximum size for intervals before we consider
them as AnyInt
float, long, double
at type level
reference values
objects distinguished by their allocation site
alias- and path-sensitive
Post-Processing
Compiler Generated Dead Code
The Intricacies of Java
Established Idioms
Assertions
Reflection and Reflection-like Mechanisms
Post-Processing
Compiler Generated Dead Code
void	
  conditionInFinally(java.io.File	
  f)	
  {	
  
boolean	
  completed	
  =	
  false;	
  
try	
  {	
  
f.canExecute();	
  
completed	
  =	
  true;	
  
}	
  finally	
  {	
  	
  
if	
  (completed)	
  doSomething();	
  }	
  
}
Finally blocks are included twice by Java compilers
Post-Processing
The Intricacies of Java
Throwable	
  doFail()	
  {	
  throw	
  new	
  Exception();	
  }	
  
Object	
  compute(Object	
  o)	
  {	
  
if	
  (o	
  ==	
  null)	
  {	
  return	
  doFail();	
  }	
  
else	
  return	
  o;	
  
}
Post-Processing
Established Idioms
switch	
  (i)	
  {	
  
case	
  1:	
  break;	
  
//	
  complete	
  enumerable	
  of	
  all	
  cases	
  
default:	
  throw	
  new	
  UnknownError();	
  
}
Post-Processing
Assertions
Reflection and Reflection-like Mechanisms
Study: JDK 8 Update 25
Category Percentage
Null Confusion 54 %
Range Double Checks 11 %
Dead Extensibility 9 %
Unsupported Operation
Usage
7 %
Unexpected Return
Value
5 %
Forgotten Constant 4 %
Confused Language
Semantics
3 %
Type Confusion 3 %
Confused Conjunctions 2 %
Obviously Useless
Code
1 %
False Positives 1 %
• Found 556 issues
• For 19 we found no
source code
• 279 of 537 were
considered irrelevant
• The remaining 258
issues were manually
inspected
Null Confusion
Infeasible path because of too much checks for null
Infeasible path because of too less checks for null
if	
  (o	
  ==	
  null)	
  return	
  doSomething();	
  
if	
  (o	
  ==	
  null)	
  return	
  doSomeOtherThing();
int	
  num	
  =	
  array.length;	
  
if	
  (array	
  ==	
  null)	
  	
  
throw	
  InvalidArgumentException();
Range Double Checks
if	
  (extendableSpaces	
  <=	
  0)	
  return;	
  
int	
  adjustment	
  =	
  (target	
  -­‐	
  currentSpan);	
  
int	
  spaceAddon	
  =	
  (extendableSpaces	
  >	
  0)	
  ?	
  
adjustment	
  /	
  extendableSpaces	
  :	
  0;
OpenJDK 8 update 25, javax.swing.text.ParagraphView$Row.layoutMajorAxis, line 1095ff
Dead Extensibility
//	
  For	
  now	
  we	
  set	
  owner	
  to	
  null.	
  In	
  the	
  
future,	
  it	
  may	
  be	
  

//	
  passed	
  as	
  an	
  argument.	
  

Window	
  owner	
  =	
  null;	
  

if	
  (owner	
  instanceof	
  Frame)	
  {	
  ...	
  }
OpenJDK 8 update 25, javax.print.ServiceUI.printDialog, line 189ff
Summary
General analysis approach to find various
different and complex issues
Dead Path detection using Abstract Interpretation
We evaluated on the JDK (and on the
Qualitas Corpus)
We filter out irrelevant issues
Thanks and please try it out
http://www.opal-­‐project.de/tools/bugpicker/
And also see my other talk on a Capability Model
for Java on Friday’s 11:30 session R8.c in the
same room

More Related Content

PDF
Symbolic Execution (introduction and hands-on)
PDF
Measuring maintainability; software metrics explained
DOCX
Java Questioner for
PPTX
C++ Presentation
PDF
Analyzing the Dolphin-emu project
PPT
Control Statements, Array, Pointer, Structures
PPT
EMBEDDED SYSTEMS 4&5
PDF
C++17 introduction - Meetup @EtixLabs
Symbolic Execution (introduction and hands-on)
Measuring maintainability; software metrics explained
Java Questioner for
C++ Presentation
Analyzing the Dolphin-emu project
Control Statements, Array, Pointer, Structures
EMBEDDED SYSTEMS 4&5
C++17 introduction - Meetup @EtixLabs

What's hot (20)

DOCX
Quiz test JDBC
PPT
Handling Exceptions In C &amp; C++ [Part B] Ver 2
PDF
College1
PPTX
PDF
Solid C++ by Example
PDF
C programming session3
PPTX
Summary of C++17 features
PPTX
C++ vs C#
PDF
PPTX
Isorc18 keynote
PDF
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
PDF
The Goal and The Journey - Turning back on one year of C++14 Migration
PDF
Deep C
PDF
Cpp17 and Beyond
PPTX
What has to be paid attention when reviewing code of the library you develop
PPTX
What is to loop in c++
PDF
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
DOCX
Java level 1 Quizzes
PDF
C language
PPT
Os Reindersfinal
Quiz test JDBC
Handling Exceptions In C &amp; C++ [Part B] Ver 2
College1
Solid C++ by Example
C programming session3
Summary of C++17 features
C++ vs C#
Isorc18 keynote
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
The Goal and The Journey - Turning back on one year of C++14 Migration
Deep C
Cpp17 and Beyond
What has to be paid attention when reviewing code of the library you develop
What is to loop in c++
Fast, Private and Verifiable: Server-aided Approximate Similarity Computation...
Java level 1 Quizzes
C language
Os Reindersfinal
Ad

Similar to Hidden Truths in Dead Software Paths (20)

PPTX
Price of an Error
KEY
Java Performance MythBusters
PDF
Forgive me for i have allocated
PDF
Mathematicians: Trust, but Verify
PDF
100 bugs in Open Source C/C++ projects
PDF
Orthogonal Functional Architecture
PDF
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
PDF
Klee and angr
PDF
100 bugs in Open Source C/C++ projects
PDF
Haskell for data science
PDF
ITI COPA Java MCQ important Questions and Answers
PDF
Java coding pitfalls
PDF
What You Need to Know about Lambdas
ODP
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
PDF
core java
PPTX
Symbolic Execution And KLEE
PDF
20160520 what youneedtoknowaboutlambdas
PPT
Os Reindersfinal
PPTX
200 Open Source Projects Later: Source Code Static Analysis Experience
DOCX
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Price of an Error
Java Performance MythBusters
Forgive me for i have allocated
Mathematicians: Trust, but Verify
100 bugs in Open Source C/C++ projects
Orthogonal Functional Architecture
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
Klee and angr
100 bugs in Open Source C/C++ projects
Haskell for data science
ITI COPA Java MCQ important Questions and Answers
Java coding pitfalls
What You Need to Know about Lambdas
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
core java
Symbolic Execution And KLEE
20160520 what youneedtoknowaboutlambdas
Os Reindersfinal
200 Open Source Projects Later: Source Code Static Analysis Experience
Consider this code using the ArrayBag of Section 5.2 and the Locat.docx
Ad

Recently uploaded (20)

PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Types of Token_ From Utility to Security.pdf
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
assetexplorer- product-overview - presentation
PPTX
Cybersecurity: Protecting the Digital World
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Custom Software Development Services.pptx.pptx
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Trending Python Topics for Data Visualization in 2025
Time Tracking Features That Teams and Organizations Actually Need
GSA Content Generator Crack (2025 Latest)
iTop VPN Crack Latest Version Full Key 2025
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Weekly report ppt - harsh dattuprasad patel.pptx
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
How to Use SharePoint as an ISO-Compliant Document Management System
Types of Token_ From Utility to Security.pdf
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Oracle Fusion HCM Cloud Demo for Beginners
Digital Systems & Binary Numbers (comprehensive )
assetexplorer- product-overview - presentation
Cybersecurity: Protecting the Digital World
Advanced SystemCare Ultimate Crack + Portable (2025)
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Custom Software Development Services.pptx.pptx

Hidden Truths in Dead Software Paths

  • 1. Hidden Truths in Dead Software Paths Michael Eichberg, Ben Hermann, Mira Mezini, and Leonid Glanz ESEC/FSE 2015, Bergamo, Italy
  • 2. When is a path dead? if  (maxBits  >  4  ||  maxBits  <  8)  {        maxBits  =  8;   }   if  (maxBits  >  8)  {        maxBits  =  16;   } OpenJDK 8 update 25, com.sun.imageio.plugins.png.PNGMetadata, line 1842ff Hidden inside a 278 LOC method
  • 3. Hypothesis In well-written code every path between an instruction and all its successors is eventually taken A path that will never be taken indicates an issue
  • 4. Identifying Infeasible Paths public  static  X  doX(SomeType[]  array)  {   if  (array  !=  null  ||  array.length  >  0)  {  (a)  }   //  …  (b)   }//  (ex) 1: public static X doX(SomeType[] array){ 2: if (array != null || array.length > 0) {(a) } 5: // … (b) 6: }// (ex) ifnonnull array arraylength array ifgt (>0) (a) (b) (ex) (B) Corresponding CFG true true false false (A) Java Source Code. ifnonnull array arraylength array ifgt (>0) (C) Computed AIFG false Java Bytecode Java Bytecode :- array is null CFG
  • 5. Identifying Infeasible Paths 1: public static X doX(SomeType[] array){ 2: if (array != null || array.length > 0) {(a) } 5: // … (b) 6: }// (ex) ifnonnull array arraylength array ifgt (>0) (a) (b) (ex) (B) Corresponding CFG true true false false ifnonnull array arraylength array ifgt (>0) (a) (b) (ex) (C) Computed AIFG true true false false relevant missing edge a missing edge Java Bytecode Java Bytecode :- array is null :- array not null 1: public static X doX(SomeType[] array){ 2: if (array != null || array.length > 0) {(a) } 5: // … (b) 6: }// (ex) ifnonnull array arraylength array ifgt (>0) (a) (b) (ex) (B) Corresponding CFG true true false false ifnonnull array arraylength array ifgt (>0) (a) (b) (ex) (C) Computed AIFG true true false false relevant missing edge a missing edge Java Bytecode Java Bytecode :- array is null :- array not null CFG AIFG
  • 6. Abstract Interpretation Not targeted at a specific goal Not a whole program analysis, but instead everything may be an entry point Inter-procedural, path-, flow-, object- and context-sensitive
 with configurable call chain length (typically low)
  • 7. Abstract Interpretation Integers support all arithmetic operations (of the JVM) maximum size for intervals before we consider them as AnyInt float, long, double at type level reference values objects distinguished by their allocation site alias- and path-sensitive
  • 8. Post-Processing Compiler Generated Dead Code The Intricacies of Java Established Idioms Assertions Reflection and Reflection-like Mechanisms
  • 9. Post-Processing Compiler Generated Dead Code void  conditionInFinally(java.io.File  f)  {   boolean  completed  =  false;   try  {   f.canExecute();   completed  =  true;   }  finally  {     if  (completed)  doSomething();  }   } Finally blocks are included twice by Java compilers
  • 10. Post-Processing The Intricacies of Java Throwable  doFail()  {  throw  new  Exception();  }   Object  compute(Object  o)  {   if  (o  ==  null)  {  return  doFail();  }   else  return  o;   }
  • 11. Post-Processing Established Idioms switch  (i)  {   case  1:  break;   //  complete  enumerable  of  all  cases   default:  throw  new  UnknownError();   }
  • 13. Study: JDK 8 Update 25 Category Percentage Null Confusion 54 % Range Double Checks 11 % Dead Extensibility 9 % Unsupported Operation Usage 7 % Unexpected Return Value 5 % Forgotten Constant 4 % Confused Language Semantics 3 % Type Confusion 3 % Confused Conjunctions 2 % Obviously Useless Code 1 % False Positives 1 % • Found 556 issues • For 19 we found no source code • 279 of 537 were considered irrelevant • The remaining 258 issues were manually inspected
  • 14. Null Confusion Infeasible path because of too much checks for null Infeasible path because of too less checks for null if  (o  ==  null)  return  doSomething();   if  (o  ==  null)  return  doSomeOtherThing(); int  num  =  array.length;   if  (array  ==  null)     throw  InvalidArgumentException();
  • 15. Range Double Checks if  (extendableSpaces  <=  0)  return;   int  adjustment  =  (target  -­‐  currentSpan);   int  spaceAddon  =  (extendableSpaces  >  0)  ?   adjustment  /  extendableSpaces  :  0; OpenJDK 8 update 25, javax.swing.text.ParagraphView$Row.layoutMajorAxis, line 1095ff
  • 16. Dead Extensibility //  For  now  we  set  owner  to  null.  In  the   future,  it  may  be  
 //  passed  as  an  argument.  
 Window  owner  =  null;  
 if  (owner  instanceof  Frame)  {  ...  } OpenJDK 8 update 25, javax.print.ServiceUI.printDialog, line 189ff
  • 17. Summary General analysis approach to find various different and complex issues Dead Path detection using Abstract Interpretation We evaluated on the JDK (and on the Qualitas Corpus) We filter out irrelevant issues
  • 18. Thanks and please try it out http://www.opal-­‐project.de/tools/bugpicker/ And also see my other talk on a Capability Model for Java on Friday’s 11:30 session R8.c in the same room