Finding Compiler Bugs through Cross-Language Code Generator and Differential Testing CCS: Software and its engineering Source code generation CCS: Software and its engineering Parsers CCS: Software and its engineering Compilers
Qiong Feng, Xiaotian Ma, Ziyuan Feng, Marat Akhin, Wei Song, Peng Liang · 2025
Read Finding Compiler Bugs through Cross-Language Code Generator and Differential Testing CCS: Software and its engineering Source code generation CCS: Software and its engineering Parsers CCS: Software and its engineering Compilers by Qiong Feng, Xiaotian Ma, Ziyuan Feng, Marat Akhin, Wei Song, Peng Liang (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2507-06584.txt.
Introduction
Qiong Feng and five co-authors built a bug-hunting tool in two thousand twenty-five for compilers that mix languages. Compilers turn high-level code into programs, and their errors can break safety. Most past checks covered one language at a time, leaving cross-language builds largely untested.
Their tool, CrossLangFuzzer, builds test programs that span JVM languages, then mutates them in three ways to widen variety. Running old and changed programs across compiler versions exposed twenty-four confirmed bugs in Kotlin, Groovy, Scala, and Java compilers. One mutation style found almost half the bugs. The team also sorts out which compiler owns each fault.
Catalog record
| CREATOR | Qiong Feng, Xiaotian Ma, Ziyuan Feng, Marat Akhin, Wei Song, Peng Liang |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 77 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2507-06584
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Finding Compiler Bugs through Cross-Language Code Generator and Differential Testing CCS: Software and its engineering Source code generation CCS: Software and its engineering Parsers CCS: Software and its engineering Compilers Qiong Feng, Xiaotian Ma, Ziyuan Feng, Marat Akhin, Wei Song, Peng Liang Abstract . Compilers play a central role in translating high-level code into executable programs, making their correctness essential for ensuring code safety and reliability. While extensive research has focused on verifying the correctness of compilers for single-language compilation, the correctness of cross-language compilation — which involves the interaction between two languages and their respective compilers — remains largely unexplored. To fill this research gap, we propose CrossLangFuzzer , a novel framework that introduces a universal intermediate representation (IR) for JVM-based languages and automatically generates cross-language test programs with diverse type parameters and complex inheritance structures. After generating the initial IR, CrossLangFuzzer applies three mutation techniques — LangShuffler , FunctionRemoval , and TypeChanger — to enhance program diversity. By evaluating both the original and mutated programs across multiple compiler versions, CrossLangFuzzer successfully uncovered 10 confirmed bugs in the Kotlin compiler, 4 confirmed bugs in the Groovy compiler, 7 confirmed bugs in the Scala 3 compiler, 2 confirmed bugs in the Scala 2 compiler, and 1 confirmed bug in the Java compiler. Among all mutators, TypeChanger is the most effective, detecting 11 of the 24 compiler bugs. Furthermore, we analyze the symptoms and root causes of cross-compilation bugs, examining the respective responsibilities of language compilers when incorrect behavior occurs during cross-language compilation. To the best of our knowledge, this is the first work specifically focused on identifying and diagnosing compiler bugs in cross-language compilation scenarios. Our research helps to understand these challenges and contributes to improving compiler correctness in multi-language environments. 1. Introduction Compilers play a central role in translating high-level code into executable programs, making their correctness crucial for ensuring code safety and reliability. Errors or inconsistencies in the compilation process can lead to unpredictable behavior, security vulnerabilities, and even system failures. Various approaches have been developed to generate diverse test programs and verify compiler correctness ( Chen et al. 2020 ) . For instance, most of generated-based compiler fuzzing techniques can generate programs with valid syntax to check whether they pass the compiler and produce the expected results, with invalid syntax to ensure they are rejected by the compiler, or programs that cause crashes to identify critical failures ( Yang et al. 2011 ; Livinskii et al. 2020 ; Ou et al. 2024 ) . While these approaches ( Yang et al. 2011 ; Livinskii et al. 2020 ; Dewey et al. 2014 ; Dewey et al. 2015 ; Chaliasos et al. 2022 ; Ou et al. 2024 ) have been extensively studied for verifying single-language compilers, the correctness of compilers in cross-language systems remains largely unexplored. Recent studies indicate that an increasing number of systems are implemented using multiple programming languages ( Yang et al. 2024b ) . For example, deep learning systems often combine C and Python ( Li et al. 2022b ) , while Linux systems start to use Rust in their C kernel ( Li et al. 2024 ; Panter and Eisty 2024 ) . Furthermore, on the Java Virtual Machine (JVM), interoperability between Java, Kotlin, Groovy, and Scala allows them to coexist and evolve smoothly within a single project ( Ardito et al. 2020 ; Mateus and Martinez 2020 ) . These four mainstream JVM languages (Java, Kotlin, Groovy, and Scala) frequently depend on one another at the source code level, posing challenges for compilers in resolving syntax and dependencies across different languages. Consider the compilation process of a Kotlin-Java cross-language system as an example. The Kotlin compiler first resolves the Kotlin skeleton (class and method signatures) and passes them to the Java compiler. Given this skeleton, the Java compiler then compiles the Java source code into Java bytecode. Next, the Kotlin compiler processes the Java bytecode and compiles the Kotlin source code into Kotlin bytecode. As we can see, cross-language compilation involves two compilers and follows a cyclical process. Due to differences in type systems, language concepts, and compilation rules, cross-language compilation can easily introduce errors. However, little research has been conducted on these compilation processes or on testing the robustness of compilers in handling cross-language compilation ( Marr et al. 2016 ; Garzella et al. 2020 ) . Testing the correctness of compilers in handling cross-language compilation presents two significant challenges. First, generating cross-language interactive code is inherently difficult due to fundamental differences between programming languages. Each language has its own intermediate representation (IR), which is often incompatible with others. Furthermore, differences in syntax rules, type systems, and underlying programming concepts make it challenging to construct code that seamlessly integrates multiple languages. Ensuring that the generated code adheres to the constraints of each language while maintaining interoperability adds another layer of complexity. Second, even if cross-language code is generated successfully, determining whether it is semantically valid poses another challenge. Cross-language interactions often involve implicit conversions and type coercions that may behave differently depending on the compilation process. Without a clear specification of how different compilers should interpret such interactions, it becomes difficult to establish whether the generated code is functionally correct or whether subtle inconsistencies could lead to unexpected behavior or compilation failures. To address the first challenge posed by differences in intermediate representations (IR) across programming languages, we propose CrossLangFuzzer , a novel framework designed to establish a universal IR for different JVM languages and systematically generate cross-language interaction code with various inheritance information and type parameters. By creating a standardized representation, CrossLangFuzzer ensures that the code can be seamlessly transformed and compiled across multiple languages within the JVM ecosystem. Furthermore, to enhance test program’s diversity and improve bug detection, we introduce three novel mutators: LangShuffler which randomly changes the code language, e.g., from Java to Kotlin; FunctionRemoval , which eliminates functions in a class or an interface; and TypeChanger , which modifies type parameters to assess the robustness of type resolution mechanisms. To address the second challenge—the difficulty of ensuring the correctness of generated cross-language code—we employ differential testing techniques. Since cross-language compilation involves compilers of different languages, we execute the generated code using two versions of one language’s compiler: the latest release and a previous stable release, while keeping the other language’s compiler fixed at its stable version. We then compare the compilation results to identify discrepancies and potential compiler miscompilations by minimizing the trigger program. Using this approach, CrossLangFuzzer has generated diverse cross-language test programs with various type parameters and nontrivial inheritance structure. Within one month’s bug hunting, CrossLangFuzzer successfully identified 10 confirmed bugs in the Kotlin compiler, 4 confirmed bugs in the Groovy compiler, 7 confirmed bugs in the Scala 3 compiler, 2 confirmed bugs in the Scala 2 compiler, and 1 confirmed bug in the Java compiler. These detected bugs exhibit diverse failure patterns and reveal fundamental weaknesses in cross-language compilation, highlighting the need for improved compiler robustness in multi-language ecosystems. The contributions of this work are listed below: (1) To the best of our knowledge, this is the first work to specifically target compiler bugs in JVM-based cross-language compilation. The designed IR in our