ISOLATING THE CAUSES OF EMERGENT FAILURES IN COMPUTER SOFTWARE
Ross Gore
Virginia Modeling Analysis and Simulation Center, Old Dominion University, Norfolk, VA, 23529, USA
SUMMARY
Faults in computer software can be either deterministic or non-deterministic. For deterministic faults, a variety of approaches exist for automated debugging including statistical approaches, state-altering approaches, and general approaches. Although these approaches are effective, they assume the fault in the software is deterministic; the activation of the fault is reproduced with a certain set of inputs to the system. However, for many faults, the assumption that a fault is deterministic is not true. The activation and propagation of the fault are not always reproducible. These types of faults are emergent. Emergent faults are caused by (i) employing stochastics in software and (ii) the effect of the internal environment of the system on fault activation conditions. In the first case, the output of software that employs stochastics can include some natural random variance. In these cases, it is difficult to determine if the software passes or fails a given test case because there is variance in the output. In the second case, the states of a system (e.g., hardware, operating system behavior, and application) executing the program can impact defect activation. For each of these cases, we present specific approaches to account for the non-determinism needs to be introduced to enable existing automated debugging approaches to be applied. These techniques, used in combination with traditional automated debugging approaches, represent different methodologies available to handle emergent faults in software.
INTRODUCTION
When a failure is first observed in software, the prospect of localizing the fault causing it can be daunting. A software fault is an invalid token or bag of tokens in a program statement that will cause a failure when the compiled code for the program that implements the source code is executed (Munson et al ., 2006). A software failure occurs when the output of an executed test case, supplied for the program, does not produce the output specified by the requirements (Laprie et al ., 1992).
Common practice is to apply classic debugging techniques to identify the program statements and interactions that lead to the fault. This practice is largely manual and it can consume weeks, months, and even years of effort resulting in the consumption of an enormous amount of resources. As a result, any improvement in the process can greatly decrease the cost. This has motivated the development of a variety of different automated debuggers that assist in fault localization by automating part of the process of searching for faults (Harrold et al ., 1998; Renieris and Reiss, 2003; Vessey, 1986; Jones and Harrold, 2005; Jones et al ., 2002).
Although these debuggers are effective, they assume the fault in the software is deterministic. Deterministic faults are activated and propagated with a certain set of inputs every time the software runs. In other words, they are always reproducible. However, for many faults, this assumption is not true. Over multiple runs, the activation and propagation of the fault cannot always be reproduced. These types of faults are emergent. Emergent faults primarily occur in two classes of software.
The first class of software employs floating-point computations and continuous stochastic distributions to represent, or support the evaluation of, an underlying model. This class of software includes exploratory simulations where the test cases for the software are defined by an analytical solution. The stochastics create at least two difficult questions for users tasked with localizing emergent faults: (i) does an output have to match an analytical solution exactly to be correct and (ii) if not, how close must an output be to the analytical solution to not be considered a fault?
The second class of software is implemented in an environment where the scheduling of internal tasks (e.g., hardware, operating system behavior, and application) that execute the software can influence how and when within execution a fault is activated. Reproducing a specific execution sequence for this class of software is difficult because events are scheduled by the operating system, not the software being tested. To debug a fault, the programmer must predict the order of execution that caused the fault. Furthermore, many faults activated by effects of the internal system environment crash the system itself, ending the debugging process prematurely.
The remainder of the chapter proceeds as follows. First, we provide an overview of the different automated debugging approaches that can be applied for non-emergent faults. Then, we define emergent faults and discuss how they arise in the two aforementioned classes of software. For each of these classes of software, we present specific techniques to account for the absent determinism. Finally, we describe how these techniques provide infrastructure to enable existing automated debugging approaches to be applied to enable effective localization of emergent faults.
ISOLATING THE CAUSE OF DETERMINISTIC FAILURE
In this section, the advantages and drawbacks of existing fault localization approaches for deterministic faults are reviewed. Deterministic faults are reproduced with a certain set of inputs to the system every time the inputs are present. First, statistical approaches to deterministic fault localization are discussed, followed by state-altering approaches. Then, fault-specific approaches and static approaches to deterministic fault localization are reviewed.
Statistical Debugging Approaches
There has been considerable research on using statistical approaches for deterministic fault localization. These approaches, referred to as statistical debuggers, require test inputs, corresponding execution profiles, and a labeling of the test executions as either succeeding or failing. The execution profiles reflect the coverage of program elements. The approaches employ an estimate of suspiciousness to rank the program elements.
Developers examine program elements in decreasing order of the suspiciousness estimate until the fault is discovered. Program elements refer to individual program statements or the truth values of conditional propositions represented by branches or inserted predicates. Statistical approaches at the statement level are more efficient but less effective than approaches at the predicate level because they only consider statement coverage and not the values of variables within statements. Statement-level statistical approaches are reviewed in Statement-Level Approaches section, then predicate-level statistical approaches are summarized in Predicate-Level Approaches section.
Statement-Level Approaches
Statement-level statistical fault localization research focuses on the discovery that failing program executions are likely to have different statement coverage patterns compared to passing program executions (Harrold et al ., 1998). Initial research in this area centered around identifying statistics of statement coverage to effectively estimate the suspiciousness of statements.
The goal was to create a statistic that maximized the suspiciousness estimate for the program statement containing the fault. In the nearest neighbor approach, a failing execution is paired with a larger number of passing executions. The passing execution that is most similar to the failing execution is identified and differences between the two are labeled as suspicious (Renieris and Reiss, 2003).
Set-union and set-intersection approaches have been explored as well. The set-intersection approach identifies suspicious statements by computing the set difference between the statements that are present in every passed execution and the statements in a single failing execution (Vessey, 1986). The set-union approach identifies suspicious statements by removing the union of all statements (or entities) in passing executions from the statements (or entities) within a failing execution (Vessey, 1986). Formally, given a set of passing test cases P containing individual passed test cases p i , and a single failing test case f , the set of coverage entities executed by each p is E p , and the coverage entities ( E initial ) executed by f is E f , the two approaches are shown in Figure 12.1 .
Figure 12.1 The set union and set intersection approaches to statistical debugging.
Tarantula is the first statistical approach to recognize that statements exercised more often by failing runs than by passing runs are likely to be faulty (Jones and Harrold, 2005; Jones et al ., 2002). Tarantula calculates the fraction of failed executions that execute a statement, over all passed executions. It uses the former fraction over the sum of the two fractions as the statement's suspiciousness estimate. The Tarantula suspiciousness estimate measures specificity (or precision).
Figure 12.2 shows the program, mid(), and its test suite. The program mid() takes three integers as input and is required to output the median value. The function fails to properly identify the median number for some inputs because there is a fault in Statement 7. Statement 7 should read m = x ; however, it reads m = y .
Figure 12.2 Statistical debugging example using Tarantula.
Figure 12.2 illustrates the process of employing statistical debugging to localize this fault. The debugger begins by executing mid() for each of the test inputs shown at the top of the figure. The execution of mid() for each test input is traced to record the statements that are executed. The columns below the test inputs reflect each execution trace: a black dot signifies that the statement was executed, and the lack of a black dot signifies that the statement was not executed.
Once mid() is executed for a given test input, the actual output of the program is compared to the specified output. The actual and specified outputs for each test input are shown immediately below the execution trace. The actual output is written in italics and the specified output is underlined. These outputs determine if the corresponding execution trace is labeled as passing or failing. If the actual output matches the specified output, then the execution trace passes; otherwise, it fails. The result of applying this labeling process to each execution trace of mid() is shown in the bottom row of the figure.
Labeling each execution trace as passing or failing enables the suspiciousness and rank of each statement in the source code of mid() to be computed. Suspiciousness measures how likely it is that a statement contains a fault. It is calculated by computing the ratio of the number of failing execution traces that include the statement to the number of total execution traces that include the statement. The suspiciousness of each statement is shown in second right-most column of Figure 12.2 . The eclipse plugin for Tarantula is shown in Figure 12.3 , note the program being debugged is different from the one shown in Figure 12.2 .
Figure 12.3 Eclipse plugin for automated debugging based on Tarantula's ranking. Note: the program being debugged is different from the one shown in Figure 12.2 .
Other statement suspiciousness estimates balance Tarantula's specificity measure with a sensitivity (or recall) measure. For example, in statement-level bug isolation (SBI), Yu et al . combine the proportion of executions including the statement that are faulty and the proportion of faulty executions in which the statement appears together via their harmonic mean to yield a suspiciousness estimate balancing both sensitivity and specificity (Yu et al ., 2008). Similarly, the Ochiai measure balances sensitivity and specificity via their geometric mean (Abreu et al ., 2007).
Over time, Tarantula, SBI, and other similar approaches were shown to be more effective than set-union and set-intersection (Jones and Harrold, 2005; Yu et al ., 2008; Abreu et al ., 2007). As a result, Tarantula, SBI, and other similar approaches have been enhanced. Researchers have explored how to cluster test cases in Tarantula to facilitate multiple developers to debug a faulty program in parallel (Jones et al ., 2007). Others observed that some groups of statements, referred to as dynamic basic blocks, are always executed by the same set of test cases. To optimize Tarantula, they find a subset of the original test suite that aims to maximize the number of dynamic basic blocks executed (Baudry et al ., 2006).
More recent research has focused on identifying the best measure to estimate statement suspiciousness. The explored measures include F 1 measure (harmonic mean of specificity and sensitivity) (Yu et al ., 2008), Tarantula suspiciousness (specificity) (Jones and Harrold, 2005), capture propagation (specificity of basic blocks) (Zhang et al ., 2009), and the Ochiai measure (geometric mean of sensitivity and specificity) (Abreu et al ., 2007). Research has shown that in practice, the most effective estimate of statement suspiciousness is the Ochiai measure (Abreu et al ., 2007).
However, even the Ochiai measure can be further improved. Research has shown that all statement-level suspiciousness estimates contain confounding bias due to subject program control and data flow dependencies and that it can be improved by a causal model at the statement level that reduces these biases (Baah et al ., 2010, 2011).
Predicate-Level Approaches
Predicate-level statistical debugging approaches represent a class of fault localization techniques that share a common structure. Each approach consists of a set of conditional propositions, or predicates, which are inserted into a program and tested at particular points. A single predicate can be thought of as partitioning the space of all test cases into two subspaces: those satisfying the predicate and those not. Better predicates create partitions that more closely match the space where the fault is expressed. Similar to statements, the predicates are ranked, based on their estimated suspiciousness and guide developers in finding and fixing faults.
As shown in Figure 12.4 , the canonical predicate-level statistical debugger Cooperative Bug Isolation (CBI) (Liblit et al ., 2003, 2005; Liblit, 2008) computes the proportion of failing executions where a predicate is evaluated (true or false) and the proportion of failing executions where a predicate is evaluated and true. It then calculates the increase from the former proportion to the latter proportion and uses the resulting increase as an estimate of the predicate's suspiciousness. SOBER introduces the concept of statement evaluation bias to express the probability that a predicate is evaluated to be true in an execution (Liu et al ., 2005). By collecting such evaluation biases of a statement in all failed executions and those in all passed executions, SOBER compares the two distributions of evaluation biases and accordingly estimates the suspiciousness of the predicate (Liu et al ., 2005).
Figure 12.4 An example of CBI-ranked predicates from a numeric program.
Recent work has improved the effectiveness and efficiency of predicate-level statistical debugging. Adaptive Bug Isolation showed that the number of program points that need to be instrumented and monitored to identify fault predicting predicates can be significantly reduced with adaptive sampling (Nainar and Liblit, 2010). The reduction in the number of instrumented program points improves overall efficiency of predicate-level approaches but not the effectiveness. Compound Boolean predicates combine existing CBI predicates together via Boolean expressions. The result is improved effectiveness but increased overhead (Nainar et al ., 2007). In their work with the Holmes debugging tool, Chilimbi et al . explored profiling paths instead of predicates to identify sources of program failures (Chilimbi et al ., 2009). Profiling paths, as opposed to predicates, require additional instrumentation but can provide more context on how faults are exercised, which can aid developers in debugging. Finally, Zhang et al . showed that Boolean expression short circuit rules used in some compilers can cause the effectiveness of predicate-based approaches to vary significantly for some subject programs (Zhang et al ., 2010).
State-Altering Approaches
State-altering approaches to deterministic fault localization attempt to identify the cause of program failure by repeatedly altering the program's state and re-executing the program. Here, program state refers to the values of variables, constants, and inputs to the software. As the program is executed, variables can change values, the change in these values reflects a change in the state of program. For example, a control variable in a loop changes the state of the program every time the loop is executed.
Delta Debugging systematically narrows down the variables and values relevant to the failure, by iteratively modifying the program state for each test case and observing if there is any difference in the outcome (Zeller, 2002; Zeller and Hildebrandt, 2002). The process identifies cause–effect chains relevant to a failure and these chains lead to the isolation of the faulty statement (Cleve and Zeller, 2005). Recently, the efficiency of Delta Debugging has been significantly improved by encoding test case inputs into a hierarchy (Misherghi and Su, 2006). Interesting Value Map Pairs (IVMP) is a similar but more aggressive state-altering approach than Delta Debugging. IVMP potentially modifies values at every executed statement in a failing test case. This improves effectiveness but leads to a less efficient approach (Jeffrey et al ., 2008, 2009).
Predicate Switching differs from both Delta Debugging and IVMP by only altering the outcomes of branches during the execution of a failing run. As a result, Predicate Switching only provides a subset of the state alterations that are performed in IVMP and Delta Debugging. Moreover, because predicate switching only alters control flow, it may cause the execution of the subject program to enter an inconsistent program state (Zhang et al ., 2006).
Other General Approaches
Several fault localization approaches cannot be categorized as statistical or state-altering. These approaches have not been shown to be as effective as the previously described tools; however, they have influenced the design of the most effective fault localization techniques and are useful in preventing errors.
Invariant-based approaches formulate program invariants regarding the proper behavior of a subject program. When the formulated invariants are violated, the behavior is reported to the developer as a possible error. The Daikon tool automatically infers likely program invariants by dynamically analyzing program executions (Ernst et al ., 2001). The inferred invariants are inserted into the program and report potential errors when violated at runtime.
Check “n” Crash derives error conditions in a program statically and generates test cases to dynamically determine if the error exists (Csallner and Smaragdakis, 2005). Eclat infers an operational model of the correct behavior of a program and identifies inputs whose execution patterns differ from the model. In Eclat, those inputs with a differing execution pattern are likely to reveal errors (Pacheco and Ernst, 2009). Similarly, the FindBugs tool automatically detects a commonly observed set of predefined error patterns in Java programs (Hovemeyer and Pugh, 2004). The PathExpander tool provides support to increase the path coverage of dynamic error detection tools by executing non-taken paths in a sandbox environment (Lu et al ., 2006). This allows for error detection in paths that would have otherwise not been taken and analyzed.
Most fault localization tools identify faulty statements causing an error. However, the goal of the analysis for some tools is to facilitate developers in explaining how an identified fault causes an error. For example, one method uses distance metrics to compare passing and failing program executions and isolate the differences between them (Groce et al ., 2006). The identified differences are used to shed light on how a fault causes an error. Ko and Myers developed a debugging tool called The Whyline, shown in Figure 12.5 , to help developers better understand program behavior (Ko and Myers, 2008). The Whyline allows developers to select a question concerning the output of a program, and the tool then uses a combination of static and dynamic analysis techniques to search for possible explanations.
Figure 12.5 An overview of the Whyline tool being used in a graphical programming environment.
Addressing Software with Multiple Faults
Each of the approaches in Isolating the Cause of Deterministic Failure section is also applicable to software with multiple faults. The following algorithm guarantees that each approach gives at least one predication for each fault that is present in a program:
- 1. Rank each statement in descending order of likelihood that it is faulty.
- 2. Remove the top-ranked statement and discard all execution traces where the statement is true.
- 3. Repeat the process until either the set of execution traces or statements is empty.
EMERGENT FAILURES
The previously described approaches assume that the fault in the software is deterministic ; the activation of the fault is reproduced with a certain set of inputs to the system. These faults are also referred to as Bohrbugs (Grottke and Trivedi, 2005). The term, Bohrbugs, alludes to physicist Niels Bohr and his simple and intelligent atom model. However, for many faults, the assumption that a fault is deterministic is not true. The activation and propagation of the fault are not always reproducible (Munson et al ., 2006). These types of faults are emergent and are also referred to as Mandelbugs alluding to the “Mandelbrot set” (Grottke and Trivedi, 2005). Emergent faults occur due to:
- Employing stochastics in software: The output of software that employs stochastics can include some natural random variance. In these cases, it is difficult to determine if the software passes or fails a given test case because there is variance in the output.
- The effect of the internal environment of the system on activation conditions: The states of a system (e.g., hardware, operating system behavior, and application) executing the program can impact defect activation. The activation of defects is influenced by states of the system running the program including hardware, software (e.g., operating system and other application programs running on the system), and so on.
In each of these cases, the symptom of the emergent bug is far removed from the root cause making it very hard to detect because the bugs are intermittent, inconsistent, or infrequent and materialize far away from the actual place they are spawned.
As an example of such an episode, consider the case in which a piece of software that works perfectly in one environment, yet fails to work in another environment. If many things have changed (e.g., different hardware, different compiler, and different linker), then there are simply too many degrees of freedom to enable systematic testing under controlled conditions to isolate the bug. Such testing can be done, given enough time and resources, but it is very difficult.
There have been several empirical studies on deterministic and emergent failures in large industrial software systems. The results have been eye-opening. Researchers studied 18 Jet Propulsion Laboratory NASA space missions and showed that even when testing mechanisms were in place, a large number of faults still existed (Grottke et al ., 2010). Furthermore, the Tandem system shows that a significant proportion of faults in large and complicated systems are related to emergent failures as opposed to deterministic ones (Lee and Iyer, 1993). Recently, researchers have begun attempting to classify reports of failures to determine if the failure is caused by a deterministic or emergent fault. These classifications have confirmed that emergent failures require more time to fix and more specific debugging strategies to address them (Green et al ., 2006; Hoffman et al ., 2004). In the remaining sections of this chapter, we present explicit techniques to address emergent faults due to stochastics and emergent faults due to environmental configurations.
STOCHASTICS IN SOFTWARE
The output of software that employs stochastics can include some natural random variance. Frequently these pieces of software are exploratory simulations, where the precise output for a given test case is not known. This occurs in stochastic simulations with test cases where analytical solutions are specified. Despite the existence of an expected value for the test case, the output will include random variance due to the user of stochastics.
In these cases, it is difficult to determine if the software passes or fails a given test case. In the debugging approaches described in Isolating the Cause of Deterministic Failure section, this is required. The labeling of test cases as passing or failing must be a Boolean function. An example helps elucidate this problem.
Consider the pseudocode implementing the Ising model shown in Figure 12.6 . The Ising model is used to study ferromagnetism in statistical mechanics. The model consists of discrete variables called spins that can be in one of two states. The spins are arranged in a graph, and each spin interacts with its nearest neighbors (Brush, 1967).
Figure 12.6 A visualization of the Ising model and the algorithm used to implement it.
The Monte Carlo implementation of the Ising model shown in Figure 12.6 represents the spin lattice as a two-dimensional array of integers, each valued at positive or negative one. The program makes randomly proposed changes to these spins, using a Metropolis algorithm to enforce the Boltzmann distribution. The output of the simulation is the final value of magnetization – the absolute value of the lattice's total spin per unit volume – averaged over configurations generated by the Metropolis algorithm. For each input, the specified value for the final magnetization is the analytical solution, given by Brush (1967).
Due to the stochastics within the code in Figure 12.6 , many test cases will approach their analytical solution but almost none will match it exactly. As a result, almost every test case will be classified as failing. This creates at least two difficult questions for users tasked with localizing emergent faults in this and similar situations: (i) does an output have to match the analytical solution exactly to be considered a passing test case and (ii) if not, how close must an output be to the analytical solution to be considered passing?
To address this problem, researchers employ an approach inspired by fuzzy logic that enables a subject program to both pass and fail a given test case. This approach, fuzzy passing extents, enables users to address the two previous questions for emergent faults caused by stochastics (Gore et al ., 2011).
Thus, by employing fuzzy passing extents, debugging approaches built for deterministic software can remain effective for stochastic software, where previously they were in applicable. Overview of Fuzzy Logic section gives an overview of fuzzy logic to facilitate an understanding of fuzzy passing extents. Then Tackling State-Space Explosion section presents fuzzy passing extents.
Overview of Fuzzy Logic
Fuzzy logic is a form of many-valued logic centered around approximate reasoning, as opposed to the exact reasoning featured in traditional logic theory. In traditional logic theory, a variable can have one of the two truth values: true or false. However, in fuzzy logic, variables can have any continuous truth value in the range 0 and 1 ([0,1]). This enables fuzzy logic to process incomplete data and provide approximate solutions to problems that traditional logic finds difficult to solve (Zadeh, 2010).
Basic applications of fuzzy logic characterize subranges of a continuous variable. For example, human age can be described with several separate membership functions defining particular age ranges in which one might qualitatively be considered young, middle-aged, and old. Each function maps an age measurement to a truth value in the 0–1 range ([0,1]). These truth values are used to determine how one's age might be described.
In Figure 12.7 , the meanings of the expressions young, middle-aged, and old are age-scale mapping functions. A point on the age scale has three truth values – one for each of the three functions (young, middle-aged, and old). The vertical line shown in Figure 12.7 represents a particular age and the three arrows reflect the value of each function for the specified age. The dark gray dashed arrow (old) has a truth-value of zero, signifying that the age (35) is not old. The light gray dashed arrow (young) has a truth-value of 0.2 signifying that age 35 is slightly young. Finally, the solid arrow has a truth-value of 0.8 and signifies that age 35 is fairly middle-aged.
Figure 12.7 Fuzzy membership with designations of young, middle-aged, and old.
Fuzzy Passing Extents
Fuzzy passing extents remove the requirement that the outputs of test cases must be either strictly passing or strictly failing. Instead, fuzzy passing extents allow a user to specify a continuous function to classify outputs. Fuzzy passing extents assume that the output of a program is (or can easily be transformed to) some ordered set of real numbers. This is typical of most software that employs stochastics. This set is referred to as the output list, X . The passing extent, u , of the output list, X , is computed using the equation shown in Figure 12.8 .
Figure 12.8 Equation specifying the passing extent, u , of an output list X .
In Figure 12.8 , W is an ordered set of weights that focuses attention on particular parts of the output list. The functions f i encode information about the specified (or passing) output and the tolerance for deviation from that output. The passing extent u reflects the extent to which executing a single test case for a faulty subject program produces the specified (or passing) output. The sum of the passing extent of every test case in the test suite reflects the total number of passing test cases. This sum and similar measures derived from u are used in place of the existing terms in the techniques presented in Isolating the Cause of Deterministic Failure section.
Fuzzy passing extents are a continuous generalization of Boolean pass/fail detection (Harrold et al ., 1998; Liblit, 2008; Liu et al ., 2005). This means that while they do not guarantee improvements in the effectiveness of predicate-level statistical debuggers, fuzzy passing extents can reproduce the results of each of the suspiciousness estimates previously presented in this chapter.
Ultimately, choosing the functions for the passing extent for the test cases of a faulty subject program is a nontrivial problem, and one that is entirely dependent on the user. However, the fuzzy formalism allows a choice that can enable the Boolean function used to label passing and failing test cases in existing debugging approaches for deterministic software to be applicable to software that employs stochastics.
Fuzzy Passing Extents
An example helps elucidate the utility of fuzzy passing extents. Recall the implementation of the two-dimensional Ising model in Figure 12.6 . The implementation represents the spin lattice as a two-dimensional array of integers, each valued at positive or negative one. Random changes are proposed to these spins using a Metropolis algorithm to enforce the Boltzmann distribution. The output of the simulation is the final value of magnetization – the absolute value of the lattice's total spin per unit volume – averaged over configurations generated by the Metropolis algorithm. As previously discussed, this implementation of the Ising model should approximate the analytical solution, given by Brush (1967).
However, the following fault, based on published mistakes, is injected into the simulation: the absolute value of each sweep's magnetization is not taken while summing magnetizations to compute the average (line 18 of the pseudo-code) (Gore et al ., 2011). Over many sweeps, one would expect the faulty behavior to always result in zero magnetization because the algorithm would thoroughly sample states magnetized in positive and negative directions. However, over fewer sweeps, the magnetization will often be close to plus or minus the analytical solution. The reason for this is that both the positive and negative magnetizations are surrounded by relatively probable configurations. If the random walk of the Metropolis algorithm wanders toward one direction of magnetization, it has a low probability of moving to the other within a small number of moves.
The result is an implementation of the Ising model that produces output that approaches the analytical solution at times and output that significantly veers away from the analytical solution at others. To isolate this fault, predicate-level statistical debugging (i.e., CBI) with fuzzy passing extents can be applied to isolate the cause of the failure.
The fuzzy passing function for the model is a curve centered on the analytical solution,
, for each input. Formally, function is:
, where a is the tolerance for deviation. Here, a = 1.0. A graph that plots fuzzy passing extents found by applying the fuzzy passing function is shown in Figure 12.9 . The divergence between the analytical solution and the expected results for several of the test cases is highlighted by the low fuzzy passing extents shown on the far right of the curve.
Figure 12.9 The result of applying the fuzzy passing function to test cases for the faulty implementation of the Ising model. The center portion of the curve reflects fuzzy passing values that applying the fuzzy function to the test cases did not yield.
Due to the low fuzzy passing extent of these test cases, the suspiciousness of the predicate (magnetization < 0) localizes the values of magnetization (in line 18 of the pseudo-code) that are <0. The passing extents for this predicate are significantly lower than the other predicates because repeated negative values of magnetization cause the simulation to significantly deviate from the analytical solution. The fuzzy passing extents corresponding to this predicate are shown on the right side of Figure 12.9 .
This analysis is not possible without fuzzy passing extents because it is extremely unlikely that any of the test cases will exactly match the analytical solution for the Ising model. This example illustrates how important it is to make debugging approaches applicable to programs that employ stochastics.
FAULTS ACTIVATED BY EFFECTS OF THE INTERNAL SYSTEM ENVIRONMENT
Eliminating faults activated by effects of the internal system environment is not an easy task. Reproducing these types of faults is difficult because the execution sequence of the software is non-deterministic. For example, the multi-threaded program shown in Figure 12.10 , contains four lines of code across two threads yielding six unique execution sequences and four unique program end states.
Figure 12.10 A multi-threaded program with four lines yielding six unique execution sequences and four unique end states.
Reproducing any one of these six sequences is difficult because threads are scheduled by the operating system, not the software being tested. To debug a fault, the programmer must predict the order of thread execution that caused the fault to gain insight into the error and fix it. Furthermore, many faults activated by effects of the internal system environment, crash the system itself.
To address these emergent faults requires introducing a scheduling software layer to eliminate the non-determinisim within the internal environment. The scheduling software layer, shown in Figure 12.11 , is implemented by redirecting calls to the original operating system to alternate implementations where determinism is explicitly scheduled. By capturing and explicitly scheduling the calls related to the non-determinism, the software is able to impose determinism on the system. The result is the capability to organize and explicitly schedule different possible execution sequences. This capability enables the scheduler to explore each possible the execution sequence that could have activated the fault, without repeatedly trying execution sequences that have been previously scheduled. Once the sequence that activates the fault is found, it can be replayed and the debugging methods discussed in Isolating the Cause of Deterministic Failure section can be applied.
Figure 12.11 Software layer and flow diagram for scheduling determinism in programs with emergent faults (Musuvathi et al ., 2008).
An example of this approach is the tool Chess developed by Microsoft for systematic and deterministic testing of concurrent programs (Musuvathi et al ., 2008). For multi-threaded program, Chess takes complete control over the scheduling of threads and asynchronous events, thereby capturing all the interleaving non-determinism in the program. This provides two important benefits. First, if an execution results in an error, Chess has the capability to reproduce the erroneous thread interleaving. This substantially improves the debugging experience. Second, Chess uses systematic enumeration techniques (Clarke and Emerson, 1981; Killian et al ., 2007; Godefroid, 1997; Queille and Sifakis, 1981; Musuvathi et al ., 2002; Yang et al ., 2006) to force every run of the program along a different thread interleaving. Such a systematic exploration greatly increases the chances of finding errors in existing tests without developers having to think of pathological input configurations to stress the system.
In order to build such a software layer, several challenges must be addressed. First, such a software layer should avoid perturbing the system under test and be able to test the code as is. Testers do not have the luxury of changing code. Similarly, testers cannot change the operating system. Therefore, the added software layer should easily integrate with existing test infrastructure with no modification to the system under test.
Second, the layer must systematically accomplish the nontrivial task of capturing and exploring all interleaving non-determinism. For example, concurrency is enabled in most systems via Application Program Interfaces (APIs) that contain a myriad of threading and synchronization functions, many with different options and parameters. The layer must understand the precise semantics of these functions to capture and explore the non-determinism inherent in them. Failure to do so may result in lack of reproducibility, the introduction of false behaviors, and ultimately undermine the credibility of the approach.
Finally, a scheduling layer must explore the space of interleavings intelligently, as the set of interleavings grows exponentially with the number of entities and the number of steps executed by each entity. To effectively search large state spaces, a testing tool must not only reduce the search space by avoiding redundant search (Godefroid, 1996) but also prioritize the search toward potentially erroneous interleavings (Musuvathi and Qadeer, 2007).
We address the second and third challenges in more detail next.
Right Layer of Abstraction
A program typically uses system calls implemented in the operating system kernel. In these cases, the scheduler is implemented by redirecting system calls to alternate implementations added on to the operating system. These alternate implementations need to capture and expose the non-determinism of original system calls.
However, for more complex APIs where functionality is implemented outside of the operating system, the design of the scheduler must be adjusted. One acceptable design choice is to include an implementation of these primitives as part of the program. For example, if a third-party library implements locks, the scheduler can treat this library as part of the program under test. Under these circumstances, the scheduler only needs to understand the simpler system primitives that the lock implementation uses.
Although this choice makes the scheduler implementation easier, it also prevents the scheduler from exposing all the non-determinism in the lock implementation. For instance, the library could implement a particular queuing policy that determines the order in which threads acquire locks. Including this implementation as part of the program prevents the scheduler from emulating other queuing policies that future versions of this library might implement. In the extreme, one can include the entire operating system with the program and implement the scheduler at the virtual machine monitor layer.
Ideally, the scheduler should implement a well-documented standard so that the work involved in building the scheduler can be reused across many subject programs.
Tackling State-Space Explosion
Given a program with n threads that execute k atomic steps in total, the number of thread interleavings grows as a scalar factor of n k . This exponential growth creates an enormous amount of interleavings. To be effective in such a large space of interleavings, it is essential to limit focus on interesting and potentially fault-yielding ones.
One approach to limit focus is to only explore fair interleavings. Systems calls implicitly assume that the underlying operating system schedule is fair. This means that every call will be scheduled eventually. An unfair operating system schedule does not guarantee that every system call will be scheduled.
As a result, the scheduling software layer only has to explore program execution sequences that are fair. Otherwise errors found on execution sequences that are unfair will be useless as the developer would consider these sequences impossible in practice. Finally, fair scheduling is important because it enables the scheduler to return control to the subject program possessing the emergent fault. Unfair schedules result in program sequences that do not terminate. As a result, the scheduling layer never returns control to the subject program.
Other approaches include chunking the code in atomic blocks and only scheduling interleavings of those blocks as opposed to interleavings for every line of code. Identifying where to divide the code into chunks is a difficult process. However, based on the subject program at hand, a number of heuristics exist to facilitate this process (Musuvathi et al ., 2008). Employing this approach reduces the number of interleavings for n threads that execute k atomic steps divided into c chunks from n k to k c .
The state space can be even further reduced by combining the idea of chunking blocks of code with saving parts of thread interleavings. Given divisions that break the threads into manageable chunks, schedulers can reason that two execution traces with the same interleaving chunks will behave the same. This means that only one of the two threads need to be explored, thus limiting the overall state space.
SUMMARY
In this chapter, we reviewed automated approaches to debugging deterministic and emergent faults. For deterministic faults, a variety of approaches exist for automated debugging including statistical statement-based approaches, statistical predicate-based approaches, and state-altering approaches. Furthermore, a number of other different general approaches to automated debugging exist as well.
Although these approaches are effective, they assume that the fault in the software is deterministic . This means that the activation of the fault is reproduced with a certain set of inputs to the system. However, for many faults, the assumption that a fault is deterministic is not true. These types of faults are emergent.
Emergent faults are caused by (i) employing stochastics in software and (ii) the effect of the internal environment of the system on fault activation conditions. In the first case, the output of software that employs stochastics can include some natural random variance. In these cases, it is difficult to determine if the software passes or fails a given test case because there is variance in the output. In the second case, the states of a system (e.g., hardware, operating system behavior, and application) executing the program can impact defect activation.
For each of these cases, a specific approach to account for the non-determinism needs to be introduced to enable existing automated debugging approaches to be applied. Fuzzy passing extents can be employed in software with stochastics to enable a single test case to both pass and fail. Similarly, introducing an additional scheduling layer with alternate implementations of the operating system's system calls can remove the non-determinism in programs where the internal environment of the system impacts fault activation. Both of these techniques, used in combination with traditional automated debugging approaches, represent different methodologies available to handle emergent faults in software.
REFERENCES
- Abreu, R., Zoeteweij, P. and van Gemund, A.J.C. (2007) On the accuracy of spectrum-based fault localization. Proceedings of the Testing: Academic and Industrial Conference Practice and Research Techniques – MUTATION. Washington, D.C.: IEEE Computer Society, pp. 89–98.
- Baah, G.K., Podgurski, A. and Harrold, M.J. (2010) Causal inference for statistical fault localization. Proceedings of the 19th International Symposium on Software Testing and Analysis (ISSTA '10), ACM, New York, pp. 73–84.
- Baah, G.K., Podgurski, A. and Harrold, M.J. (2011) Mitigating the confounding effects of program dependences for effective fault localization. Proceedings of the 19th ACM SIGSOFT Symposium and the 13th European Conference on Foundations of Software Engineering (ESEC/FSE '11), ACM, New York, pp. 146–156.
- Baudry, B., Fleurey, F. and Traon, Y.L. (2006) Improving test suites for efficient fault localization. Proceedings of the 28th International Conference on Software engineering (ICSE '06) , ACM, New York, pp. 82–91.
- Brush, S.J. (1967) History of the lenz-Ising model. Review of Modern Physics , 39 (4), 883–893.
- Chilimbi, T.M., Liblit, B., Mehra, K., Nori, A.V. and Vaswani, K. (2009) Holmes: effective statistical debugging via efficient path profiling. Proceedings of the 31st International Conference on Software Engineering (ICSE '09), IEEE Computer Society, Washington, DC, pp. 34–44.
- Clarke, E. and Emerson, E. (1981) Synthesis of synchronization skeletons for branching time temporal logic. LNCS: Logic of Programs , 131 , 52–71.
- Cleve, H. and Zeller, A. (2005) Locating causes of program failures. Proceedings of the 27th International Conference on Software Engineering, ACM, New York, pp. 342–351.
- Csallner, C. and Smaragdakis, Y. (2005) Check ‘n’ crash: combining static checking and testing. Proceedings of the 27th International Conference on Software Engineering (ICSE '05), ACM, New York, pp. 422–431.
- Ernst, M.D., Cockrell, J., Griswold, W.G., and Notkin, D. (2001) Dynamically discovering likely program invariants to support program evolution. IEEE Transactions on Software Engineering , 27 (2), 99–123.
- Godefroid, P. (1996) Partial-Order Methods for the Verification of Concurrent Systems: An Approach to the State-Explosion Problem , Lecture Notes in Computer Science .
- Godefroid, P. (1997) Model checking for programming languages using Verisoft. Proceedings of Principles of Programming Languages , ACM, New York, pp. 174–186.
- Gore, R., Kamensky, D. and Reynolds, P.F. (2011) Applying enhanced fault localization technology to Monte Carlo simulations. Proceedings of the 43rd Conference on Winter Simulation (WSC '11), Society for Computer Simulation, San Diego, pp. 2798–2809.
- Green, N.W., Hoffman, A.R., and Garrett, H.B. (2006) Anomaly trends for long-life robotic spacecraft. Journal of Spacecraft and Rockets , 43 (1), 218–224.
- Groce, A., Chaki, S., Kroening, D., and Strichman, O. (2006) Error explanation with distance metrics. International Journal of Software Tools Technology Transfer , 8 (3), 229–247.
- Grottke, M. and Trivedi, K.S. (2005) A classification of software faults. Journal of Reliability Engineering Association of Japan , 27 (7), 425–438.
- Grottke, M., Nikora, A.P. and Trivedi, K.S. (2010) An empirical investigation of fault types in space mission system software. Proceedings of IEEE/IFIP International Conference on Dependable Systems and Networks, pp. 447–456.
- Harrold, M.J., Rothermel, G., Wu, R., and Yi, L. (1998) An empirical investigation of program spectra. SIGPLAN Notices , 33 , 83–90.
- Hoffman, A.R., Green, N.H. and Garrett, H.B. (2004, August) Assessment of in-flight anomalies of long life outer planet missions. Environmental Testing for Space Programmes, vol. 558, pp. 43–50.
- Hovemeyer, D. and Pugh, W. (2004) Finding bugs is easy. SIGPLAN Notices , 39 , 92–106.
- Jeffrey, D., Gupta, N. and Gupta, R. (2008) Fault localization using value replacement. Proceedings of the 2008 International Symposium on Software Testing and Analysis, ACM, New York, pp. 167–178.
- Jeffrey, D., Gupta, N. and Gupta, R. (2009) Effective and efficient localization of multiple faults using value replacement. 25th IEEE International Conference on Software Maintenance (ICSM '09) , IEEE Computer Society, Washington, D.C., pp. 221–230.
- Jones, J. and Harrold, M.J. (2005) Empirical evaluation of the tarantula automatic faultlocalization technique. Proceedings of the 20th IEEE/ACM International Conference on Automated Software Engineering, ASE '05, ACM, New York, pp. 273–282.
- Jones, J.A., Harrold, M.J. and Stasko, J. (2002) Visualization of test information to assist fault localization. Proceedings of the 24th International Conference on Software Engineering (ICSE '02), ACM, New York, pp. 467–477.
- Jones, J.A., Bowring, J.F. and Harrold, M.J. (2007) Debugging in parallel. Proceedings of the 2007 International Symposium on Software Testing and Analysis (ISSTA '07), ACM, New York, pp. 16–26.
- Killian, C.E., Anderson, J.W., Jhala, R. and Vahdat, A. (2007) Life, death, and the critical transition: finding liveness bugs in systems code. Proceedings of Networked Systems Design and Implementation, ACM, New York, pp. 243–256.
- Ko, A.J. and Myers, B.A. (2008) Debugging reinvented: asking and answering why and why not questions about program behavior. Proceedings of the 30th International Conference on Software Engineering, ACM, New York, pp. 301–310.
- Laprie, J.C.C., Avizienis, A., and Kopetz, H. (1992) Dependability: Basic Concepts and Terminology , Springer-Verlag, New York, NY.
- Lee, I. and Iyer, R.K. (1993) Faults, symptoms, and software fault tolerance in the tandem guardian90 operating system. Proceedings of Twenty-Third International Symposium on Fault-Tolerant Computing, IEEE Computer Society, Washington, D.C., pp. 20–29.
- Liblit, B. (2008) Cooperative debugging with five hundred million test cases. Proceedings of the 2008 International Symposium on Software Testing and Analysis (ISSTA '08), ACM, New York, pp. 109–120.
- Liblit, B., Aiken, A., Zheng, A.X., and Jordan, M.I. (2003) Bug isolation via remote program sampling. SIGPLAN Notices , 38 , 141–154.
- Liblit, B., Naik, M., Zheng, A.X., Aiken, A. and Jordan, M.I. (2005) Scalable statistical bug isolation. Proceedings of the 2005 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI '05), ACM, New York, pp. 15–26.
- Liu, C., Yan, X., Long, F. et al . (2005) SOBER: statistical model-based bug localization. SIGSOFT Software Engineering Notes , 30 , 286–295.
- Lu, S., Zhou, P., Liu, W., Zhou, Y. and Torrellas, J. (2006) Pathexpander: architectural support for increasing the path coverage of dynamic bug detection. Proceedings of the 39th Annual IEEE/ACM International Symposium on Microarchitecture (MICRO 39), IEEE Computer Society, Washington, D.C., pp. 38–52.
- Misherghi, G. and Su, Z. (2006) Hdd: hierarchical delta debugging. Proceedings of the 28th International Conference on Software Engineering, ACM, New York, pp. 142–151.
- Munson, J.C., Nikora, A.P., and Sherif, J.S. (2006) Software faults: a quantifiable definition. Advances in Software Engineering , 37 (5), 327–333.
- Musuvathi, M. and Qadeer, S. (2007) Iterative context bounding for systematic testing of multithreaded programs. Proceedings of Programming Language Design and Implementation, ACM, New York, pp. 446–455.
- Musuvathi, M., Park, D., Chou, A., Engler, D. and Dill, D.L. (2002) CMC: a pragmatic approach to model checking real code. Proceedings of Operating Systems Design and Implementation, ACM, New York, pp. 75–88.
- Musuvathi, M., Qadeer, S., Ball, T., Basler, G., Nainar, P.A. and Neamtiu, I. (2008) Finding and reproducing Heisenbugs in concurrent programs. Proceedings of USENIX Symposium on Operating Systems Design and Implementation, ACM, New York, pp. 267–280.
- Nainar, P.A. and Liblit, B. (2010) Adaptive bug isolation. Proceedings of the 32nd ACM/IEEE International Conference on Software Engineering (ICSE '10), ACM, New York, pp. 255–264.
- Nainar, P.A., Chen, T., Rosin, J. and Liblit, B. (2007) Statistical debugging using compound boolean predicates. Proceedings of the 2007 International Symposium on Software Testing and Analysis (ISSTA '07), ACM, New York, pp. 5–15.
- Pacheco, C. and Ernst, M.D. (2009) Eclat: automatic generation and classification of test inputs. ECOOP 2005 – Object-Oriented Programming, 19th European Conference, Glasgow, pp. 504–527.
- Queille, J. and Sifakis, J. (1981) Specification and verification of concurrent systems in CESAR. Proceedings of International Symposium on Programming, Springer-Verlag, New York, pp. 337–351.
- Renieris, M. and Reiss, S. (2003) Fault localization with nearest neighbor queries. 18th IEEE International Conference on Automated Software Engineering (ASE 2003), IEEE Computer Society, Montreal, pp. 30–39.
- Vessey, I. (1986) Expertise in debugging computer programs: an analysis of the content of verbal protocols. IEEE Transactions on Systems, Man, and Cybernetics: Systems , 16 , 621–637.
- Yang, J., Twohey, P., Engler, D.R., and Musuvathi, M. (2006) Using model checking to find serious file system errors. ACM Transactions on Computer Systems , 24 (4), 393–423.
- Yu, Y., Jones, J.A. and Harrold, M.J. (2008) An empirical study of the effects of test-suite reduction on fault localization. Proceedings of the 30th International Conference on Software Engineering (ICSE '08), ACM, New York, pp. 201–210.
- Zadeh, L.A. (2010) A summary and update of fuzzy logic. IEEE International Conference on Granular Computing, IEEE Computer Society, Los Alamos, pp. 42–44.
- Zeller, A. (2002) Isolating cause-effect chains from computer programs. Proceedings of the 10th ACM SIGSOFT Symposium on Foundations of Software Engineering , ACM, New York, pp. 1–10.
- Zeller, A. and Hildebrandt, R. (2002) Simplifying and isolating failure-inducing input. IEEE Transactions on Software Engineering , 28 , 183–200.
- Zhang, X., Gupta, N. and Gupta, R. (2006) Locating faults through automated predicate switching. Proceedings of the 28th International Conference on Software Engineering (ICSE '06), ACM, New York, pp. 272–281.
- Zhang, Z., Chan, W.K., Tse, T.H., Jiang, B. and Wang, X. (2009) Capturing propagation of infected program states. Proceedings of the 7th Joint Meeting of the European Software Engineering Conference and the ACM SIGSOFT Symposium on The Foundations of Software Engineering (ESEC/FSE '09), ACM, New York, pp. 43–52.
- Zhang, Z., Jiang, B., Chan, W.K. et al . (2010) Fault localization through evaluation sequences. Journal of Systems Software , 83 , 174–187.