[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [creduce-dev] reduction using dynamic information



A couple more thoughts:

- Recording dynamic information will be particularly useful in reducing bugs in file-processing programs, if we can manage to support arrays. In this scenario, a file is loaded from disk into an array, processed (wrongly), and then compared against a reference image. We should be able to automatically eliminate all of the code that interacts with the filesystem. Arrays will be more painful to implement and we shouldn't worry about this right now.

- The scheme we've been talking about so far is about cutting out computations that satisfy the inputs necessary for seeing a compiler bug. But compiler bugs also have an output side, which is necessary to observe that the bug happened. In Csmith there's the checksum code for example. By printing the values of variables in buggy and not-buggy executions, C-Reduce can search for the first program point where some variable takes on the wrong value. In this case the generated code becomes:

{ int tmp = expr1;
  static int _creduce_checked = 0;
  if (!_creduce_checked) {
     if (tmp != reference_value) abort();
     _creduce_checked = 1;
  }
  x = foo(tmp, expr2);}

Thus, we can also shorten the output side of compiler bugs. It remains to be seen if C-Reduce will tend to just remove this code, instead of removing the code that follows it. There may be a way to convince it to do the right thing, such as requiring that an interesting program contains an abort() call.

John



On 7/12/16 1:00 PM, Yang Chen wrote:
On 2016-07-12 08:36, John Regehr wrote:

I have two small tweaks to suggest. We should print the value only
once (or else we might get a lot of output for an expression that
lives in a loop) and we should make the value easy to recognize in
case the program prints other stuff.  So perhaps:

  { int tmp1 = expr1;
    static int _creduce_printed = 0;
    if (!_creduce_printed) {
      printf("creduce_value(%d)\n", tmp1);
      _creduce_printed = 1;
    }
    x = foo(tmp1, expr2);}

Also we'll have to add a prototype for printf() to the compilation
unit or maybe it's better to simply include stdio.h.


Got it. Thanks for the suggestion.

- Yang