Assignment Quick Links

  1. Overview
  2. Build It
  3. Break It
    1. Infer details
  4. Fix It
  5. Oracle
  6. Program specifications
    1. logappend
    2. logread
  7. Grading
  8. Scoring
  9. Rules

Infer

Infer is a static analysis tool often used by engineers in the industry to find both trivial and non-trivial bugs in their code. It hard to write bug-free code; engineers know this, so they tend to write unit tests and beyond that, use tools like Infer to quickly find bugs before releasing the binaries.

Here’s your chance to learn about the tool and find bugs in your code and other’s! So how do you use Infer?

Infer is already installed in the Dockerfile provided to you in the Build It phase – see the those instructions for how to install and run the Docker container, if needed. The working directory on your host machine will appear as /connect inside the container.

Once in the container, perform the following steps to run the Infer analysis. path_to_code is the path inside the VM to the code you want to analyze. It’s simplest if you have the code in the working directory of your host machine, since then it will be accessible from inside the container in the /connect directory, and likewise, the results of your analysis will be accessible from outside the container. These steps assume you’re using the default Makefile provided in the initial handout.

$ cd <path_to_code>
$ make clean
$ infer -- make

The above lines will use Infer to execute the build process, and along the way, Infer will analyze the code. The results should be printed to standard out. You can also find a summary in ./infer-out/bugs.txt or use the infer-explore tool to learn more.

Be careful to run make clean before you run infer to ensure that you generate a correct analysis of the source code.

NOTE: Infer can be configured in a variety of ways. If the default configuration turns up too many warnings or too few actual bugs, please be sure to try out some of the additional command-line arguments.