一句话:提出 Fray,用 shadow locking 在不替换 JVM 现有并发原语的前提下实现受控并发测试,支持多种交错搜索算法并显著发现更多并发缺陷。
并发缺陷即使在无数据竞争的良同步程序中也难以发现和复现,而已有受控并发测试(CCT)算法难以用于真实 Java 程序:托管运行时与复杂同步原语使并发难以控制,成熟项目仍依赖朴素压力测试。本文从第一性原理梳理在任意 JVM 应用上实现 CCT 的设计空间,指出现有并发 mock、VM 改造、OS 级调度等选择在缺陷发现能力与适用范围上的局限,并提出 Fray:用 shadow locking 在不替换现有并发原语的前提下编排线程交错,忠实表达所有可能行为,从而支持随机游走、PCT、POS、SURW 等搜索算法。在 53 个含已知缺陷的基准上,Fray 随机游走比 JPF 多发现 70%、比 rr chaos 模式多发现 77% 的缺陷;在 Kafka、Lucene、Guava 的 2,664 个测试上发现 18 个真实缺陷,导致 371 个测试在特定交错下失败。
Concurrency bugs are hard to discover and reproduce, even in well-synchronized programs that are free of data races. Thankfully, prior work on controlled concurrency testing (CCT) has developed sophisticated algorithms—such as partial-order based and selectively uniform sampling—to effectively search over the space of thread interleavings. Unfortunately, in practice, these techniques cannot easily be applied to real-world Java programs due to the difficulties of controlling concurrency in the presence of the managed runtime and complex synchronization primitives. So, mature Java projects that make heavy use of concurrency still rely on naive repeated stress testing in a loop. In this paper, we take a first-principles approach for elucidating the requirements and design space to enable CCT on arbitrary real-world JVM applications. We identify practical challenges with classical design choices described in prior work—such as concurrency mocking, VM hacking, and OS-level scheduling—that affect bug-finding effectiveness and/or the scope of target applications that can be easily supported. Based on these insights, we present Fray, a new platform for performing push-button concurrency testing (beyond data races) of JVM programs. The key design principle behind Fray is to orchestrate thread interleavings without replacing existing concurrency primitives, using a concurrency control mechanism called shadow locking for faithfully expressing the set of all possible program behaviors. With full concurrency control, Fray can test applications using a number of search algorithms from a simple random walk to sophisticated techniques like PCT, POS, and SURW. In an empirical evaluation on 53 benchmark programs with known bugs (SCTBench and JaConTeBe), Fray with random walk finds 70% more bugs than JPF and 77% more bugs than rr ’s chaos mode. We also demonstrate Fray’s push-button applicability on 2,664 tests from Apache Kafka, Lucene, and Google Guava. In these mature projects, Fray successfully discovered 18 real-world concurrency bugs that can cause 371 of the existing tests to fail under specific interleavings. We believe that Fray serves as a bridge between classical academic research and industrial practice— empowering developers with advanced concurrency testing algorithms that demonstrably uncover more bugs, while simultaneously providing researchers a platform for large-scale evaluation of search techniques.
@article{paperbot2980,
title = {Fray: An Efficient General-Purpose Concurrency Testing Platform for the JVM},
author = {Ao Li and Byeongjee Kang and Vasudev Vikram and Isabella Laybourn and Samvid Dharanikota and Shrey Tiwari and Rohan Padhye},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {OOPSLA2},
year = {2025},
doi = {10.1145/3764119}
}