Return to Video

How Failures Come to Be - Software Debugging

  • 0:00 - 0:05
    We can see a program as a succession of program states.
  • 0:05 - 0:09
    Each program states consists of several variables with values.
  • 0:09 - 0:14
    As a program executes, it processes these states and transforms them into a new states.
  • 0:14 - 0:19
    For instance, by reading variables and writing variables. This is the normal mode of operation.
  • 0:19 - 0:24
    Now, however, since in the beginning, we have a normal input and in the end we have a failure,
  • 0:24 - 0:29
    there must be a defect somewhere in our program that actually causes the problem.
  • 0:29 - 0:33
    So let me assume that this statement we're executing here actually has a defect.
  • 0:33 - 0:38
    What happens is that now, when executed, it introduces
  • 0:38 - 0:42
    an error in the program state which we call an infection.
  • 0:42 - 0:47
    This infection is now being propagated possibly to other state
  • 0:47 - 0:52
    and eventually becomes visible as a failure towards the user.
  • 0:52 - 0:56
    What we get in here is actually an entire cause-effect chain.
  • 0:56 - 1:01
    You see, these failures, which is an infection, is caused by earlier infections
  • 1:01 - 1:11
    and if we are at a state where the infection has no further origin, that is, the input state is the same,
  • 1:11 - 1:16
    and the output is infected, and we know the statement that was executed at this precise moment
  • 1:16 - 1:20
    which caused this transition from the same state to infected state,
  • 1:20 - 1:26
    this is the statement which caused the infection, this is the statement which has the defect.
  • 1:26 - 1:31
    When we're debugging now, we need to identify this cause-effect chain
  • 1:31 - 1:36
    not only do we need to identify but we also need to break the cause-effect chain.
  • 1:36 - 1:42
    If we can break this cause-effect chain from defect to failure, then we're done with debugging.
  • 1:42 - 1:47
    So all of this looks very simple, however, in real life, it's much more complicated than that.
  • 1:47 - 1:51
    To start with, not every defect automatically causes a failure.
  • 1:51 - 1:56
    It may well be that the defect causes an infection which later simply is not
  • 1:56 - 1:59
    propagated as a real life infection just as well.
  • 1:59 - 2:03
    So the infection is not propagated and never ever becomes visible to the user.
  • 2:03 - 2:08
    It may not even cause a failure at all or the statement with the defect may not even be executed
  • 2:08 - 2:14
    or only under very specific circumstances may actually cause an infection and later a failure.
  • 2:14 - 2:18
    This is the problem of testing. You can execute a program again and again,
  • 2:18 - 2:24
    never have a failure and still have a defect in there, however, if a program fails,
  • 2:24 - 2:33
    that is if we actually see a failure, then we can always trace it back to the defect that causes it.
  • 2:33 - 2:38
    So if there's a failure, we can always fix it by following back the cause-effect chain.
  • 2:38 - 2:43
    But then the next problem is: these states are huge.
  • 2:43 - 2:50
    So over here we have 1, 2, 3, 4, ... 12 variables. Cute.
  • 2:50 - 2:57
    In reality, we have 10,000 of such variables and not only do we have 10,000 of such variables,
  • 2:57 - 3:02
    we also have 10,000 of steps between defect and failure.
  • 3:02 - 3:06
    So tracing back the cause-effect chain can be much,
  • 3:06 - 3:10
    much more complicated that it is in this simple picture.
  • 3:10 - 3:14
    The longer the cause-effect chain, that is the longer the time we have to cover,
  • 3:14 - 3:19
    the more states we have to cover, the harder is to debug it.
  • 3:19 - 3:23
    And also, the larger the state, the more we have to search for an infection.
  • 3:23 - 3:27
    Again, this makes debugging harder and harder.
  • 3:27 - 3:31
    It's like finding a needle in a haystack except that the haystack
  • 3:31 - 3:35
    sometimes is larger than any haystack you'll ever find on earth.
Title:
How Failures Come to Be - Software Debugging
Video Language:
English
Team:
Udacity
Project:
CS259 - Software Debugging
Duration:
03:36

English subtitles

Revisions Compare revisions