一句话:提出 SafeExit,通过对比正常与中断执行的退出行为,自动检测并定位非优雅退出造成的清理缺失。
软件可能因中断/信号处理代码的缺陷,或开发者有意的调试操作而发生非优雅退出,其遗留的过时状态会引发各种“怪异”问题;常见的重启修复方式代价高且影响其他正常进程。本文设计 SafeExit,通过监控程序在正常执行下的退出行为获得“期望清理行为”,再检查被中断执行时的实际退出行为,两者对比即可发现并定位缺失的清理行为,从而支持轻量级修复。作者将 SafeExit 应用于 10 个领域的 38 个程序,在 36 个程序中识别出 133 类清理行为,并在 292 次中断执行中检测到 2861 个缺失行为。为预测未见输入场景下的缺失行为,SafeExit 使用采样输入场景训练预测模型,平均 F-measure 达 92.5%。
Software encounters ungraceful exits due to either bugs in the interrupt/signal handler code or the intention of developers to debug the software. Users may suffer from ”weird” problems caused by leftovers of the ungraceful exits. A common practice to fix these problems is rebooting, which wipes away the stale state of the software. This solution, however, is heavyweight and often leads to poor user experience because it requires restarting other normal processes. In this paper, we design SafeExit, a tool that can automatically detect and pinpoint the root causes of the problems caused by ungraceful exits, which can help users fix the problems using lightweight solutions. Specifically, SafeExit checks the program exit behaviors in the case of an interrupted execution against its expected exit behaviors to detect the missing cleanup behaviors required for avoiding the ungraceful exit. The expected behaviors are obtained by monitoring the program exit under a normal execution. We apply SafeExit to 38 programs across 10 domains. SafeExit finds 133 types of cleanup behaviors from 36 programs and detects 2861 missing behaviors from 292 interrupted executions. To predict missing behaviors for unseen input scenarios, SafeExit trains prediction models using a set of sampled input scenarios. The results show that SafeExit is accurate with an average F-measure of 92.5%.