Mutation-Based Fuzzing of the Swift Compiler with Incomplete Type Information
Authors:
- 31 March 2025
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 58-68
Abstract
Fuzzing statically-typed language compilers practically necessitates the generation of well-typed programs, which is a major challenge for fuzzing modern languages with rich type systems. Existing fuzzers only handle languages with simplistic type systems (e.g., C), only generate programs from small language subsets, or frequently generate ill-typed programs. In this work, we propose a mutation-based method for guaranteed well-typed program generation, even with minimal type system knowledge. With our method, we take a known well-typed seed program and annotate understood nodes with their types. We then try to replace annotated nodes with new type-equivalent ones, using a generator which fails if the input type is not understood. The end result is guaranteed overall well-typed as long as the original program was well-typed, even if most nodes are unannotated or the generator usually fails. We applied this approach to fuzzing the Swift compiler, and we are the first to fuzz Swift to the best of our knowledge. To implement our generator, we adapted constraint logic program-ming (CLP)-based fuzzing to work in a mutation-based context without a CLP engine, and this is the first such adaptation. Our fuzzer generates ~22k programs per second, and we used it to find 13 Swift bugs, of which 7 have been confirmed or fixed by developers to date. Five bugs involved the compiler rejecting a well-typed program, and were only discoverable thanks to our well-typed generation guarantee.Keywords
This publication has 22 references indexed in Scilit:
- Type-Centric Kotlin Compiler Fuzzing: Preserving Test Program Correctness by Preserving Types2021
- MiMIs: Simple, Efficient, and Fast Bounded-Exhaustive Test Case Generators2020
- Fuzzing the Rust Typechecker Using CLP (T)2015
- Many-core compiler fuzzing2015
- Making Random Judgments: Automatically Generating Well-Typed Terms from the Definition of a Type-System2015
- Language fuzzing using constraint logic programming2014
- SWI-PrologTheory and Practice of Logic Programming, 2011
- Finding and understanding bugs in C compilers2011
- Constructing Natural Language Interpreters in a Lazy Functional LanguageThe Computer Journal, 1989
- A theory of type polymorphism in programmingJournal of Computer and System Sciences, 1978