Facebook Infer: Finding bugs before it goes live

Facebook Infer: Finding bugs before it goes live

facebook infer static analyzer:

Today facebook released an open-sourcing development tool named facebook infer static analyzer to identify the bugs before you ship. Facebook infer is a tool to identify the bugs before it goes live, meaning we can not write a bug code which million people use/experience. A single bug with this much user base application will create much problem which we can not even imagine. So facebook releasing their own bug finding tool before it comes to live named facebook infer.

They are using this tool to find the bugs on their mobile applications (android and ios) and also for messenger and instagram.

What is facebook infer ?

Facebook infer is a automated static analyzer which scans the complete programs for correctness.

architecture of facebook infer

 

Why we need facebook infer ?

Generally a null pointer exception and memory leakage issues are source and major reason for application crashes. At present, facebook infer can find these kind of bugs before making it to live. Almost all the flows to be checked at once using this tool makes really a great sense and reduce the major and high severiorty defects.

facebook infer static analyzer – a great tool for all the developers:

Testing is more difficult and hectic work than the development works. To test the single bug fix, a tester need to test the complete functionality of the application to ensure no other impacts, which is again a tough job for the testers and hence so much resources and time also needed for the repeated cases.

 

So what facebook infer static analyzer can do here ?

Running a facebook infer for the codebase finds many defects which saves the developers many hours finding and fixing the bugs and also results in better products at end user perspective.

You can find complete details about fb infer here

facebook infer static analyzer: finding bugs in Java Sample Program

Sample Java Bug Program:

HelloInfer.java

This is the untested sample java program written just to explain the facebook infer behaviour.


class HelloInfer.java {
public static void main(String[] args){
HelloInfer hInfer = new HelloInfer();
String strValue = hInfer.testInfer();
System.out.println(strValue);
}

public String testInfer(){
String str = null;
// Which throws null pointer exception.
return str.length();
}
}

Running facebook infer for the above program:

infer -- javac HelloInfer.java

fbinfer response:

Starting Analysis
Analysis Done

HelloInfer.java:11: NULL_DEREFERENCE
object str last assigned on line 9 could be null and it is dereferenced at line 11

 

Correction after facebook infer findings:

public String testInfer(){
String str = null;
return str == null ? "":str.length();
}

 

Now Running facebook infer again:
infer -- javac HelloInfer.java

Starting Analysis
Analysis Done

No issues found

 

Prerequiste:

To run facebook infer you need python (>=2.7).

Downloading facebook infer:

Currently it has been released only for Mac OS and Linux.

For Mac OS: Download facebook infer for Mac OS

For Linux : Download facebook infer for Linux

Since facebook infer windows package is not released, we could not share you the installation guide and real time sample programs. We will be updating this post with the examples once the fb infer windows package released. Bookmark this page or subscribe us to not to miss our tech updates.

622 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *