一句话:提出消息历史逻辑,通过逐步精化回调控制流验证事件驱动应用的回调可达性断言。
事件驱动框架中回调控制流对程序员和静态分析均不透明,既难以精确刻画又难以证明依赖回调顺序的性质。本文提出折中方案:在应用与框架边界处推理方法调用历史,即消息历史,并据此按需逐步精化回调控制流。作者定义了带边界迁移的仅应用迁移系统、消息历史程序逻辑和时序规格逻辑,并将消息历史断言与回调控制流规格事后组合,用于目标导向验证器。原型工具 Historia 在真实问题案例上能区分缺陷版与修复版,并在开源 Android 应用中证明多回调缺陷模式不存在。
This paper considers the callback reachability problem --- determining if a callback can be called by an event-driven framework in an unexpected state. Event-driven programming frameworks are pervasive for creating user-interactive applications (apps) on just about every modern platform. Control flow between callbacks is determined by the framework and largely opaque to the programmer. This opacity of the callback control flow not only causes difficulty for the programmer but is also difficult for those developing static analysis. Previous static analysis techniques address this opacity either by assuming an arbitrary framework implementation or attempting to eagerly specify all possible callback control flow, but this is either too coarse to prove properties requiring callback-ordering constraints or too burdensome and tricky to get right. Instead, we present a middle way where the callback control flow can be gradually refined in a targeted manner to prove assertions of interest. The key insight to get this middle way is by reasoning about the history of method invocations at the boundary between app and framework code --- enabling a decoupling of the specification of callback control flow from the analysis of app code. We call the sequence of such boundary-method invocations message histories and develop message-history logics to do this reasoning. In particular, we define the notion of an application-only transition system with boundary transitions, a message-history program logic for programs with such transitions, and a temporal specification logic for capturing callback control flow in a targeted and compositional manner. Then to utilize the logics in a goal-directed verifier, we define a way to combine after-the-fact an assertion about message histories with a specification of callback control flow. We implemented a prototype message history-based verifier called Historia and provide evidence that our approach is uniquely capable of distinguishing between buggy and fixed versions on challenging examples drawn from real-world issues and that our targeted specification approach enables proving the absence of multi-callback bug patterns in real-world open-source Android apps.
@article{paperbot1846,
title = {Historia: Refuting Callback Reachability with Message-History Logics},
author = {Shawn Meier and Sergio Mover and Gowtham Kaki and Bor-Yuh Evan Chang},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {OOPSLA2},
year = {2023},
doi = {10.1145/3622865}
}