DiffSpec: Differential Testing with LLMs using Natural Language Specifications and Code Artifacts

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Rao, Nikitha, Gilbert, Elizabeth, Green, Harrison, Ramananandro, Tahina, Swamy, Nikhil, Goues, Claire Le, Fakhoury, Sarah
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866910928640933888
author Rao, Nikitha
Gilbert, Elizabeth
Green, Harrison
Ramananandro, Tahina
Swamy, Nikhil
Goues, Claire Le
Fakhoury, Sarah
author_facet Rao, Nikitha
Gilbert, Elizabeth
Green, Harrison
Ramananandro, Tahina
Swamy, Nikhil
Goues, Claire Le
Fakhoury, Sarah
contents Differential testing can be an effective way to find bugs in software systems with multiple implementations that conform to the same specification, like compilers, network protocol parsers, or language runtimes. Specifications for such systems are often standardized in natural language documents, like Instruction Set Architecture (ISA) specifications or IETF RFC's. Large Language Models (LLMs) have demonstrated potential in both generating tests and handling large volumes of natural language text, making them well-suited for analyzing artifacts like specification documents, bug reports, and code implementations. In this work, we leverage natural language and code artifacts to guide LLMs to generate targeted tests that highlight meaningful behavioral differences between implementations, including those corresponding to bugs. We introduce DiffSpec, a framework for generating differential tests with LLMs using prompt chaining. We demonstrate DiffSpec's efficacy on two different (extensively tested) systems, eBPF runtimes and Wasm validators. Using DiffSpec, we generated 1901 differentiating tests, uncovering at least four distinct and confirmed bugs in eBPF, including a kernel memory leak, inconsistent behavior in jump instructions, undefined behavior when using the stack pointer, and tests with infinite loops that hang the verifier in ebpf-for-windows. We also found 299 differentiating tests in Wasm validators pointing to two confirmed and fixed bugs.
format Preprint
id arxiv_https___arxiv_org_abs_2410_04249
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle DiffSpec: Differential Testing with LLMs using Natural Language Specifications and Code Artifacts
Rao, Nikitha
Gilbert, Elizabeth
Green, Harrison
Ramananandro, Tahina
Swamy, Nikhil
Goues, Claire Le
Fakhoury, Sarah
Software Engineering
Differential testing can be an effective way to find bugs in software systems with multiple implementations that conform to the same specification, like compilers, network protocol parsers, or language runtimes. Specifications for such systems are often standardized in natural language documents, like Instruction Set Architecture (ISA) specifications or IETF RFC's. Large Language Models (LLMs) have demonstrated potential in both generating tests and handling large volumes of natural language text, making them well-suited for analyzing artifacts like specification documents, bug reports, and code implementations. In this work, we leverage natural language and code artifacts to guide LLMs to generate targeted tests that highlight meaningful behavioral differences between implementations, including those corresponding to bugs. We introduce DiffSpec, a framework for generating differential tests with LLMs using prompt chaining. We demonstrate DiffSpec's efficacy on two different (extensively tested) systems, eBPF runtimes and Wasm validators. Using DiffSpec, we generated 1901 differentiating tests, uncovering at least four distinct and confirmed bugs in eBPF, including a kernel memory leak, inconsistent behavior in jump instructions, undefined behavior when using the stack pointer, and tests with infinite loops that hang the verifier in ebpf-for-windows. We also found 299 differentiating tests in Wasm validators pointing to two confirmed and fixed bugs.
title DiffSpec: Differential Testing with LLMs using Natural Language Specifications and Code Artifacts
topic Software Engineering
url https://arxiv.org/abs/2410.04249