Docsity

Advanced Programming Languages: Homework Assignment 6F and 6C - EECS 590, Lecture notes of Programming Languages

Toggle sidebar
bg1
Advanced Programming Languages
Homework Assignment 6F and 6C
EECS 590
Optional Partners. You may optionally work with exactly one partner of your choice. If
you do work with exactly one partner, the two of you together must complete 150% as much
as a single person. The assignment details explain how much is required for one person.
If you work with a partner, do half again as much (which is defined formally below in the
assignment description and often involves picking some other aspect). Choose one of the
following:
1. Work alone, completing the assignment as described below.
2. Work with exactly one partner, collectively completing 150% as much as a single person.
Each element of the assignment below has a concluding note about what is expected
for partners.
The course staff cannot be responsible for partners that disappear or drop the course at
the last minute. If your partner becomes unavailable, you can fall back on submitting the
standard singleton 100% of the assignment.
Logistics. The previous homework assignment was largely theoretical. This homework
assignment is largely practical. There is no peer review component for this homework as-
signment.
In class we have covered operational semantics (large- and small-step), axiomatic seman-
tics (including verification condition generation) and some abstract interpretation. You are
now qualified to pull ideas from many of those techniques together and create a non-trivial
program analysis.
This analysis will target off-the-shelf C programs. We will use the CIL library to parse and
process C programs into an IMP-like OCaml representation. We will use the Z3 automated
theorem prover of de Moura and Bjorner to reason about infeasible paths or otherwise decide
questions of logic.
Our analysis will automatically generate test inputs that will force the subject program
to cover all of its branches. This is undecidable in general (by direct reduction with the
halting problem). Automated test input (and test case) generation is a research problem
that is receiving quite a bit of attention; see the papers on the course webpage for more
1
pf3
pf4
pf5

Partial preview of the text

Download Advanced Programming Languages: Homework Assignment 6F and 6C - EECS 590 and more Lecture notes Programming Languages in PDF only on Docsity!

Advanced Programming Languages

Homework Assignment 6F and 6C

EECS 590

Optional Partners. You may optionally work with exactly one partner of your choice. If you do work with exactly one partner, the two of you together must complete 150% as much as a single person. The assignment details explain how much is required for one person. If you work with a partner, do half again as much (which is defined formally below in the assignment description and often involves picking some other aspect). Choose one of the following:

  1. Work alone, completing the assignment as described below.
  2. Work with exactly one partner, collectively completing 150% as much as a single person. Each element of the assignment below has a concluding note about what is expected for partners.

The course staff cannot be responsible for partners that disappear or drop the course at the last minute. If your partner becomes unavailable, you can fall back on submitting the standard singleton 100% of the assignment.

Logistics. The previous homework assignment was largely theoretical. This homework assignment is largely practical. There is no peer review component for this homework as- signment. In class we have covered operational semantics (large- and small-step), axiomatic seman- tics (including verification condition generation) and some abstract interpretation. You are now qualified to pull ideas from many of those techniques together and create a non-trivial program analysis. This analysis will target off-the-shelf C programs. We will use the CIL library to parse and process C programs into an IMP-like OCaml representation. We will use the Z3 automated theorem prover of de Moura and Bjorner to reason about infeasible paths or otherwise decide questions of logic. Our analysis will automatically generate test inputs that will force the subject program to cover all of its branches. This is undecidable in general (by direct reduction with the halting problem). Automated test input (and test case) generation is a research problem that is receiving quite a bit of attention; see the papers on the course webpage for more

information. This problem is also known as program reachability, the same issue we discussed in the context of software model checking. I have provided an introductory analysis. It performs flow-sensitive, path-sensitive, context-insensitive, intraprocedural path enumeration, symbolic execution, and constraint generation to create test inputs. Unlike previous assignments, for this assignment you may change anything in the main file you like. Initial steps:

  1. Compile tigen, our test-input generation program. See the file README-GradPL.txt in the code archive for details. Reproducing the systems research results of others is a key part of modern research. Getting the code up and running is explicitly part of this assignment and is your responsibility. Talk to your friends, post on the forum, scour the Internet — do whatever it takes to make it happen.
  2. Take a look at some of the included small subject programs. Think about how you would generate test inputs to reach and cover all of their branches. Then run tigen and inspect the test cases it actually creates. As a sanity check, on my machine, the report.txt output is:

array-1.i.c : reached 0 / 4 array-2.i.c : reached 8 / 8 array-3.i.c : reached 0 / 10 array-4.i.c : reached 1 / 4 balanced.i.c : reached 4 / 8 bsearch-1.i.c : reached 4 / 8 bsearch-2.i.c : reached 6 / 8 bubblesort.i.c : reached 5 / 6 conway.i.c : reached 6 / 6 dotprod.i.c : reached 2 / 2 eq-index.i.c : reached 6 / 6 fibo.i.c : reached 6 / 6 float-1.i.c : reached 2 / 6 float-2.i.c : reached 7 / 8 float-3.i.c : reached 5 / 8 float-4.i.c : reached 4 / 14 float-5.i.c : reached 1 / 4 gcd.i.c : reached 4 / 4 hailstone.i.c : reached 5 / 6 leven.i.c : reached 7 / 10 many-features.i.c : reached 0 / 8 matmul.i.c : reached 3 / 6 matrix-path.i.c : reached 0 / 8 mymin-1.i.c : reached 7 / 8 roman.i.c : reached 21 / 28 selsort.i.c : reached 6 / 6

  • Modify tigen so that its performance and scalability are non-trivially improved. This typically requires more “engineering” than “theory”, but getting an analysis to run on millions of lines of code (e.g., the Linux kernel, SQL Server) is very difficult. Your modified version should run significantly faster on large benchmarks of your choosing.
  • Modify or post-process tigen so that the performance of its generated test inputs is non-trivially improved. That is, perform test suite selection or test suite reduction or even time-aware test suite prioritization. Ideally we would like the smallest number of test cases that require the smallest amount of wall-clock time to execute but still covert the greatest fraction of the subject programs. This is a reasonable project if you are more interested in CS theory than in systems hackery.
  • Modify tigen to handle record data types (e.g., structures and/or unions).
  • Modify tigen to handle floating-point data types. In practice, this ends up being insufficient for full credit for most students, as they “merely” use Z3’s Real datatype without considering the differences between real numbers in mathematics and IEEE floating point numbers. Think carefully before you select this option.
  • Modify tigen to accept additional constraints provided by the user (e.g., pre- and post- conditions on the subject program, an external constraint language that you parse at the beginning, or whatever you like). For example, you may want to specify that you’re only interested in test inputs involving negative numbers. Part of a larger project might be to have tigen output multiple diverse test inputs that cover the same path.
  • Modify tigen to be context-sensitive. You might compute the call graph and analyze the functions in reverse dependency order. You might do a full-blown CFL reachability analysis. Or you might just start in the target function and take very long paths through the entire reachable program. Handling recursion is a related topic.
  • Modify tigen so that it implements key ideas from Godefroid et al.’s DART project. This would presumably involve some notion of random test input generation (see their paper).
  • Modify tigen so that it implements key ideas from Sen et al.’s CUTE project. This would presumably involve some notion of concolic testing (see their paper).
  • Modify tigen so that it implements key ideas from Lakhotia et al.’s AUSTIN project. This would presumably involve some of the empirical optimizations and best practices described in their paper.

If you work with a partner, the two of you must do 150% of the code changing described above. This may involve fully completing one big task and also completing one small task. This may instead involve fully completing one big task and partially completing another big task.

Exercise 6C. Coding. Submit your modified tigen.ml file. In addition, submit two new subject programs in the style of the subject programs already included. Your homework should perform well on those new subject programs. If you work with a partner, the two of you must do 150% of the work described above for 6C.

Exercise 6F-1. Bookkeeping [4 points].

  1. How did this assignment go? What were the high points and the low points? We’re interested in hearing your opinions, and this is also an opportunity to speak directly about any meta-level concerns that arose during this assignment. For example, if you ran out of time, you might feel more comfortable mentioning that here than in the formal section of the report.

If you work with a partner, the two of should either answer separately or give a longer joint answer for 6F-1.

Exercise 6F-2. Report [22 points]. Provide a multi-paragraph report describing your changes (as above) as well as any other compelling figures or charts relevant to supporting your case. Recall that you should demonstrate that you did something useful with respect to this homework’s goals of using program analysis techniques either (1) in your research or (2) to understand programs or (3) to find bugs or (4) to verify properties of programs or (5) to make related tools more usable. If you work with a partner, the two should do 150% of the work described above (which necessitates a commensurately longer report, etc.).

Exercise 6F-3. Research Communication [4 points]. Compose a brief (one- or two- paragraph) email to one of the authors of the tools or papers you used in this homework and include the text of it in your submission. In addition, indicate whether you are willing to use your name or whether you would like to be portrayed as an anonymous student in my class. I will check off the fact that you wrote something and potentially forward it along. You can comment on any aspect of your experience with their work — your comments need not be positive. For example, you might ask Bjorner why Z3 doesn’t handle multiplication, complain to Kodumal or Das that OLF isn’t precise enough for C programs, or tell Necula or McPeak that you find CIL’s memory lvalue semantics unintuitive. You might even write to Lakhotia and ask him how he managed to scale to large programs given all the difficulties you observed when wrestling with C. If you do offer criticism, strive to make it constructive by commenting on what you would have liked to have seen instead or how you might like to see things improved if the time were available. If you absolutely cannot think of anything to say, thank them for making their tools available and let them know that you used them with success. Even minor comments about documentation or a fresh-eyed perspective on usability can be helpful.