Data race occurs when multiple threads simultaneously access shared data without appropriate synchronization, and at least one is write. System with a data race is nondeterministic and may generate different outputs even with the same input, according to different interleaving of data access. We present a model-based approach for detecting data races in concurrent Java programs. We extend UML Activity diagrams with data operation tags, to model program behavior. Program under test (PUT) is instrumented according to the model. It is then executed with random test cases generated based on path analysis of the model. Execution traces are reverse engineered and used for post-mortem verification. First, data races are identified by searching the time overlaps of entering and exiting critical sections of different threads. Second, implementation could be inconsistent with the design. The problem may tangle with race condition and makes it hard to detect races. We compare the event sequences with the behavior model for consistency checking. Identified inconsistencies help debuggers locate the defects in the PUT. A prototype tool named\emph{$toc4j$} implements the proposed approach and was successfully applied to several cases studies.
Index Terms:
race condition, UML activity diagram
Citation:
Bin Lei, Linzhang Wang, Xuandong Li, "UML Activity Diagram Based Testing of Java Concurrent Programs for Data Race and Inconsistency," icst, pp.200-209, 2008 International Conference on Software Testing, Verification, and Validation, 2008