1. Introduction
Reproducing concurrency bugs is a notorious challenge in software engineering. These "Heisenbugs" are inherently non-deterministic, often disappearing when developers attempt to observe them through traditional debugging tools. The primary limitation of existing debuggers is their reliance on line-level granularity. In modern languages like Java, a single source line can compile into multiple bytecode instructions (e.g., complex conditional checks or compound assignments). Race conditions occurring between these instructions—a phenomenon termed "In-Line" bugs—remain invisible to standard line-based tools.
Furthermore, existing solutions often require manual source code instrumentation, which can introduce "probe effects" that alter timing and mask the very bugs they are meant to find. SPDebugger addresses these gaps by providing a fine-grained, non-intrusive system for deterministic thread interleaving.
2. The Sequence Point Abstraction
The core innovation of SPDebugger is the Sequence Point (SP). Unlike traditional breakpoints, an SP is a multi-dimensional marker that defines a precise execution state. It consists of four primary components: a target thread ID, a specific code location (defined by file, line, and column), a global sequence ID, and execution constraints.
By incorporating column-level positioning, SPDebugger can pause execution between the atomic components of a single logical expression. Additionally, the inclusion of state-aware constraints, such as an iteration_counter, allows the tool to handle "Loop Debugging" scenarios where a bug only manifests after a specific number of iterations.
3. Deterministic Execution Control
SPDebugger enforces a specific execution schedule defined in an external XML file, decoupling the debugging logic from the application source code. This schedule is managed at runtime by a Global Sequence Counter (GSC), which acts as a logical clock.
As illustrated in the state transition model, when a thread reaches a designated Sequence Point, the system checks if the current GSC matches the SP's assigned sequence ID. If the thread arrives out of turn, it is moved to a Suspended state. It only transitions back to Ready and eventually Running once the GSC reaches the appropriate value and all associated constraints are satisfied. This mechanism ensures that threads execute in the exact order required to reproduce a specific race condition.
To achieve this without source modification, SPDebugger utilizes the ASM library for bytecode manipulation at startup and the Java Debugging Interface (JDI) to monitor thread states. This allows the tool to be applied to third-party libraries and legacy JAR files where source code is unavailable.
4. Experimental Evaluation
The researchers evaluated SPDebugger against 40 documented concurrency bugs from major Java projects, including JBoss Cache, Apache Tomcat, and the JDK. These cases spanned line-based, in-line, and loop-based scenarios.
- Reproduction Rate: SPDebugger achieved a 100% reproduction rate across all 40 test cases. In comparison, the state-of-the-art tool IMUnit reproduced only 20 cases (50%), failing entirely on in-line and loop-based bugs.
- Instrumentation Effort: Despite its higher precision, the human effort required to use SPDebugger was comparable to existing tools. On average, developers needed to define 4.35 Sequence Points per schedule, similar to the 4 events required by IMUnit.
- Non-Intrusiveness: SPDebugger successfully reproduced all bugs without a single modification to the original source code, effectively eliminating the risk of probe effects.
5. Conclusion
SPDebugger provides a robust framework for deterministic concurrency debugging by moving beyond line-level granularity. By combining column-level sequence points with an external scheduling language and bytecode manipulation, it offers a powerful means to capture and resolve the most elusive thread-interleaving bugs. Future work will focus on automating the identification of buggy patterns to further reduce the manual effort required to define execution schedules.
Summary updated