Skip to main content
QUICK REVIEW

[Paper Review] The Hitchhiker's Guide to Program Analysis: A Journey with Large Language Models

Haonan Li, Yu Hao|arXiv (Cornell University)|Aug 1, 2023
Software Engineering ResearchComputer Science11 citations
TL;DR

The paper proposes LLift, a fully automated framework that couples static analysis with large language models to detect use-before-initialization bugs in large codebases (Linux kernel), achieving 50% precision and 100% recall on tested cases, and discovering 13 new bugs.

ABSTRACT

Static analysis is a widely used technique in software engineering for identifying and mitigating bugs. However, a significant hurdle lies in achieving a delicate balance between precision and scalability. Large Language Models (LLMs) offer a promising alternative, as recent advances demonstrate remarkable capabilities in comprehending, generating, and even debugging code. Yet, the logic of bugs can be complex and require sophisticated reasoning and a large analysis scope spanning multiple functions. Therefore, at this point, LLMs are better used in an assistive role to complement static analysis. In this paper, we take a deep dive into the open space of LLM-assisted static analysis, using use-before-initialization (UBI) bugs as a case study. To this end, we develop LLift, a fully automated framework that interfaces with both a static analysis tool and an LLM. By carefully designing the framework and the prompts, we are able to overcome a number of challenges, including bug-specific modeling, the large problem scope, the non-deterministic nature of LLMs, etc. Tested in a real-world scenario analyzing nearly a thousand potential UBI bugs produced by static analysis, LLift demonstrates a potent capability, showcasing a reasonable precision (50%) and appearing to have no missing bugs. It even identified 13 previously unknown UBI bugs in the Linux kernel. This research paves the way for new opportunities and methodologies in using LLMs for bug discovery in extensive, real-world datasets.

Motivation & Objective

  • Motivate the need to balance precision and scalability in static analysis for large software systems like the Linux kernel.
  • Investigate whether large language models can assist in bug discovery where traditional static analysis struggles (e.g., time/memory constraints).
  • Develop a fully automated framework (LLift) that integrates static analysis with LLMs to identify Use-Before-Initialization bugs.
  • Design prompt strategies and workflow techniques to mitigate LLM limitations (non-determinism, context window, hallucination) and achieve reliable results.
  • Evaluate LLift on ~1,000 potential UBI bugs and report precision, recall, and newly discovered bugs.

Proposed method

  • Introduce post-constraint guided path analysis to prune infeasible paths using postconditions.
  • Employ task decomposition by splitting analysis into multiple, manageable conversations with the LLM.
  • Use progressive prompting to supply function definitions on demand, reducing context window strain.
  • Incorporate self-validation whereby the LLM reviews its own outputs to improve reliability.
  • Apply chain-of-thought prompting and source-code-based analysis to guide LLM reasoning.
  • Implement a software agent that orchestrates LLM calls via OpenAI API and processes results.

Experimental results

Research questions

  • RQ1Can LLMs meaningfully assist static analysis in detecting Use-Before-Initialization bugs in large-scale real-world codebases?
  • RQ2What prompt strategies and workflow designs enable reliable and scalable LLM-assisted bug discovery?
  • RQ3How does LLift perform in terms of precision and recall on a real-world dataset of potential UBI bugs?
  • RQ4What kinds of new bugs can LLift uncover that traditional static analysis may miss?

Key findings

  • LLift achieved a precision of 50% and a recall of 100% on nearly 1,000 analyzed UBI cases.
  • LLift identified 13 previously unknown UBI bugs in the Linux kernel, verified with the Linux community.
  • Over 1,000 analyzed cases, 26 reports were positive, demonstrating practical effectiveness on real-world data.
  • Compared to the base static analysis pipeline (UBITect), LLift handles difficult cases caused by time/memory constraints.
  • The approach demonstrates the feasibility of using LLMs to complement static analysis for large-scale bug discovery.
  • Open-source intent: plans to release code and data to foster further research.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.