Mining Exception-Handling Rules as Sequence Association Rules

Authors: Suresh Thummalapenta and Tao Xie.



ABSTRACT

Programming languages such as Java and C++ provide exception-handling constructs to handle exception conditions. Applications are expected to handle these exception conditions and take necessary recovery actions such as releasing opened database connections. Failing to take necessary recovery actions such as rolling back transactions can not only cause performance degradation, but also lead to critical issues. In this paper, we propose a novel approach that mines exception-handling rules, which describe expected behavior when exceptions occur. Existing mining approaches mine association rules of the form “FCa -> FCe”, which describes that the function call FCa should be followed by the function call FCe in all paths. In this paper, we develop the first novel mining algorithm to mine conditional association rules of the form “(FC1c ...FCnc ) & FCa -> (FC1e ...FCne )”, which describe that FCa should be followed by a sequence of function calls (FC1e ...FCne ) only when FCa is preceded by the sequence (FC1c ...FCnc ). Such form of rules is required to characterize common exception-handling rules. We show the usefulness of these rules by applying these rules on five real-world applications to detect violations. In our evaluation, we show that our approach detects 294 real exception-handling rules in five benchmark applications including 285 kLOC and also finds 160 defects, where 87 defects are new defects that are not found by a previous related approach.


Our ICSE 2009 can be found here.

Updates on our Evaluation Results

The developers responded on first ten defects that we reported, where seven defects are accepted and only three defects are rejected. The bug reports for these ten defects are available in the HsqlDB Bug Tracker system (http://sourceforge.net/tracker/?group_id=23316&atid=378131) with IDs #1896449, #1896448, and #18964433. Although these three rejected defects are violations of real rules, developers described that the violation-triggering conditions of these defects cannot be satisfied in the context of the HsqlDB application. For example, a rejected defect is a violation of real rule "DatabaseMetaData.getPrimaryKeys -> ResultSet.close". The preceding rule describes that the close function call should be invoked on ResultSet, when getPrimaryKeys throws any exceptions. The response from the developers (Bug report ID: #1896448) for this defect is "Although it can throw exceptions in general, it should not throw with HSQLDB. So it is fine.", which describes that the violation-triggering condition cannot be satisfied in the context of the HsqlDB application.


Subjects

The subjects used in our evaluation are as shown below: The latest versions of preceding subjects used for the verification of detected violations in our evaluation.

Evaluation Results

Evaluation 1: Mined Exception-Handling Rules

Sheet Format


The attribute Frequency is used to compute the rank for the exception-handling rule stored in the field ID.

Detected Exception-Handling Rules

Evaluation 2: Detected Violations by the top 10 exception-handling rules

Sheet Format


The attributes Frequency and Support are used to compute the rank for the detected violations.

Detected Violations

Evaluation 3: Comparison with a related approach WN-miner [Weimer and Necula TACAS05]

Comparison of Mined Exception-Handling Rules

CAR-Miner Sheet Format

WN-miner Sheet Format


Results

New defects that are detected by CAR-Miner and not found by WN-Miner

Sheet Format


Results

Evaluation 4: New defects detected by conditional association rules

Sheet Format


Results


Please contact for any additional information.