Safe by Accident: Crash-Testing LLM-Written Code
Abstract
Evaluations of LLM-written code run it once, in one environment, and credit the code with whatever passes. We show that this credit can belong to the environment. We crashed LLM-written backend code just before each database, file and email call, re-ran it as an operator would, and judged the result under two transaction modes of Python's sqlite3: the default, in which the library quietly opens a transaction, and autocommit, in which it does not. Across 9,100 solutions from ten models on 24 backend tasks, more than half (54%) of the database code that survives every crash in the default mode is left half-updated in autocommit mode. This holds for every model, and it hides in ordinary code, including with conn: blocks that look like transactions but open none. Telling the model that its connection is in autocommit mode does not change what the local code models write, while the API models' unsafe share falls by 30 points. Asking for crash safety helps every model, and strong models repair nearly all unsafe code, but often write safe code only when asked. Thus, much of the crash safety that LLM-written database code appears to have is borrowed from the library rather than designed into it, and a second test under a less forgiving configuration reveals the difference.
Create a lesson
Metadata
- Comments
- 9 pages, 4 figures, 4 tables
Related papers
RootSink: Reproducible C/C++ Crashes with Tested Repair Sites
Shared title terminologycs.SESuryansh Singh Sijwali, Achintya Lakshmanan, Abhiram Dodda et al.
Think Before You Code: A Benchmark for Testing LLMs on Software Engineering Deliberation
Shared title terminologycs.SEAshman Mehra
Can Coding Agents Write and Transpile Unit Tests
Shared title terminologycs.SEGil Pasternak, AJ Langley, Tom Yotam et al.
Spec-Driven PBT: Deriving Semantic Invariants from Code Specifications for Agentic Property-based Testing
Shared title terminologycs.SEAditya Shukla, Kartik Gupta, Ali Alavi et al.
Outcome Over Learning? Evidence from Student Use of AI Code Assistants for Unit Test Writing
Shared title terminologycs.SEDaniel Hinbest, Jeremy S. Bradbury, Michael A. Miljanovic
DEIA: Evidence-Grounded Crash Repair with Change-Aware Test Design for HarmonyOS ArkTS
Shared title terminologycs.SEXuhui Lu, Zhihao Liu, Xiaoke Fang et al.