LitmusKt: Concurrency Stress Testing for Kotlin
Denis Lochmelis, Evgenii Moiseenko, Yaroslav Golubev, Anton Podkopaev
TL;DR
LitmusKt addresses the challenge of verifying Kotlin concurrency across multiplatform targets by providing a DSL-driven litmus-testing framework with a Native custom runner and a JVM path using jcstress, enabling cross-platform behavior comparison. It contributes a first-of-its-kind tool for Kotlin concurrency litmus testing, discovers and fixes Kotlin/Native bugs such as unsafe publication, and integrates into the Kotlin CI pipeline, making it practical for researchers and practitioners. The work demonstrates how multiplatform concurrency semantics can be probed across platforms and highlights platform-specific weaknesses and the need for formal memory models. The approach offers a scalable way to expose subtle concurrency bugs and supports broader future work in runtime optimizations and false-sharing mitigation.
Abstract
We present LitmusKt - the first tool for litmus testing concurrent programs in Kotlin. The tool's novelty also lies in the fact that Kotlin is a multiplatform language, i.e., it compiles into multiple platforms, which means that the concurrency has to be tested on several of them. Our tool allows writing litmus tests in a single custom DSL, and these tests are then run in Kotlin/Native and Kotlin/JVM, two main platforms for concurrent programming in Kotlin. Using LitmusKt, we discovered novel bugs in the Kotlin compiler, which we then fixed and they are no longer present. Moreover, LitmusKt was integrated into the CI pipeline for Kotlin. LitmusKt is available on GitHub: https://github.com/JetBrains-Research/litmuskt. The demo is available on YouTube: https://youtu.be/oWCZp_Huwss.
