Lab 10
1 Fuzzing!
2 SMo  L Tutorial
9.3.900

Lab 10🔗

Course Homepage

1 Fuzzing!🔗

Let’s use your random term generation to find ... something?

  • Copy your interp function from Assignment 4 or 5, along with its helper functions. Try calling interp on one of your random terms.

  • Write a recursive function run-trials that accepts a number of trials and a maximum depth and runs the given number of trials, calling interp on a random term each time. Use a with-handlers block to compute what fraction of random programs complete without an error.

    Here’s an example of using with-handlers:

    #lang racket
     
    (define (maybe-crash)
      (/ 10 (random 4)))
     
     
    (define (do-a-thing)
      (with-handlers ([;; which exceptions should we catch?
                       exn:fail?
                       ;; what should we return when we catch one?
                       (λ (exn)
                         ;; let's display the message and return #f
                         (eprintf "~a\n" (exn-message exn))
                         #f
                         )])
        (maybe-crash)))
     
     
    (build-list 10 (λ (_) (do-a-thing)))
  • Refine your function random-term so that it only produces "closed" CFAEs: that is, those with no free variables. To do this, your function must accept a list of currently-bound variables, so that it can be sure to pick varrefs only from this list. Call this function random-closed-term.

  • Shrink the language by omitting numbers, booleans, strings, and ’if’, and fixing the number of arguments at one so that no errors can occur. Then, search for a term that loops forever!

2 SMoL Tutorial🔗

Continuing with the SMoL tutorial, do the next two sections: "mutvars1" and "mutvars2".

At the end of each section you will be prompted to save a PDF file of the completed tutor; do that! For lab credit, you should be prepared to show these two PDFs, in addition to the code you produced to solve the problems above.

}