[Paper Review] Gauntlet: Finding Bugs in Compilers for Programmable Packet Processing
Gauntlet is a domain-specific tool that combines random program generation, automated translation validation, and model-based testing to detect compiler bugs in P4 16 compilers. It uncovered 96 distinct bugs—62 crashes and 34 semantic issues—across P4C, the P4 reference software switch, and Barefoot Tofino back ends, with 54 fixed and the tool now integrated into P4C's CI pipeline.
Programmable packet-processing devices such as programmable switches and network interface cards are becoming mainstream. These devices are configured in a domain-specific language such as P4, using a compiler to translate packet-processing programs into instructions for different targets. As networks with programmable devices become widespread, it is critical that these compilers be dependable. This paper considers the problem of finding bugs in compilers for packet processing in the context of P4-16. We introduce domain-specific techniques to induce both abnormal termination of the compiler (crash bugs) and miscompilation (semantic bugs). We apply these techniques to (1) the open-source P4 compiler (P4C) infrastructure, which serves as a common base for different P4 back ends; (2) the P4 back end for the P4 reference software switch; and (3) the P4 back end for the Barefoot Tofino switch. Across the 3 platforms, over 8 months of bug finding, our tool Gauntlet detected 96 new and distinct bugs (62 crash and 34 semantic), which we confirmed with the respective compiler developers. 54 have been fixed (31 crash and 23 semantic); the remaining have been assigned to a developer. Our bug-finding efforts also led to 6 P4 specification changes. We have open sourced Gauntlet at p4gauntlet.github.io and it now runs within P4C's continuous integration pipeline.
Motivation & Objective
- To address the critical need for dependable compilers in programmable packet-processing devices, which are central to modern network infrastructure.
- To overcome the limitations of general-purpose compiler bug-finding techniques by exploiting the domain-specific constraints of P4, such as absence of loops and pointers.
- To develop a scalable, automated, and precise method for detecting both crash and semantic bugs in P4 compilers.
- To integrate the tool into continuous integration pipelines to enable ongoing, automated verification of compiler correctness.
Proposed method
- Randomly generate syntactically correct and well-typed P4 programs to trigger compiler crashes, leveraging P4's minimal undefined behavior to simplify test generation.
- Apply automated translation validation using formal semantics to verify correctness across compiler passes, enabled by P4’s finite and decidable program equivalence due to bounded constructs.
- Use model-based testing to generate input-output packet pairs based on formal semantics, enabling black-box testing of compilers without access to intermediate representations.
- Develop a formal interpreter and semantics for P4 16 to support both translation validation and model-based testing, reducing reliance on manual verification per compiler pass.
- Integrate Gauntlet into P4C’s CI pipeline to enable continuous, automated regression testing and early detection of regressions.
- Support extensibility via an extension model for handling target-specific externs, though accurate semantics for these remain challenging without low-level hardware knowledge.
Experimental results
Research questions
- RQ1Can domain-specific constraints in P4 be exploited to simplify and automate compiler bug finding compared to general-purpose languages?
- RQ2To what extent can automated translation validation be made precise and scalable in a DSL like P4, where program equivalence is decidable?
- RQ3How effective is a combination of random program generation, translation validation, and model-based testing in uncovering real-world compiler bugs in production P4 compilers?
- RQ4Can such a tool be integrated into CI pipelines to enable continuous verification and improve long-term compiler reliability?
Key findings
- Gauntlet detected 96 new and distinct compiler bugs across three P4 compiler back ends: 62 crash bugs and 34 semantic bugs.
- Of the 96 reported bugs, 54 were fixed (31 crash and 23 semantic), while the remaining 42 were assigned to developers for resolution.
- The tool led to 6 changes in the P4 specification, indicating its impact on language design and standardization.
- Gauntlet is now integrated into the P4C continuous integration pipeline, enabling ongoing, automated regression testing.
- The approach demonstrates that domain-specific languages with restricted semantics allow for precise, automated, and scalable compiler verification, overcoming limitations of prior general-purpose techniques.
- The success of Gauntlet suggests that similar techniques can be generalized to other domain-specific languages beyond P4, especially those with decidable semantics and limited undefined behavior.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.