• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

J4 ›› 2010, Vol. 32 ›› Issue (4): 79-82.doi: 10.3969/j.issn.1007130X.2010.

• 论文 • 上一篇    下一篇

一种自动化模型检测ANSIC程序的实用方法

王大伟,张大方,缪力   

  1. (1.湖南大学计算机与通信学院,湖南 长沙 410082;2.湖南大学软件学院,湖南 长沙 410082)
  • 收稿日期:2009-03-12 修回日期:2009-07-05 出版日期:2010-03-28 发布日期:2010-03-28
  • 通讯作者: 王大伟 E-mail:js392781@126.com
  • 作者简介:王大伟(1984-),男,江苏徐州人,硕士生,研究方向为程序验证;张大方,教授,博士生导师,CCF高级会员(40233302),研究方向为可信系统与网络、容错计算;缪力,副教授,研究方向为软件测试和程序分析。
  • 基金资助:
    国家自然科学基金资助项目(60673155);国家“可信软件”重大研究计划资助项目(90718008)

A Practical Method for Automatically Model Checking the ANSIC Programs

WANG Dawei,ZHANG Dafang,MIAO Li   

  1. (1.School of Computer and Communications,Hunan University,Changsha 410082;2.School of Software,Hunan University,Changsha 410082,China)
  • Received:2009-03-12 Revised:2009-07-05 Online:2010-03-28 Published:2010-03-28
  • Contact: WANG Dawei E-mail:js392781@126.com

摘要: 模型检测是一种验证有限状态系统的时序逻辑属性的形式化方法。为了利用模型检测技术,通常的办法是手工构建一个抽象模型,然而这个方法存在一些不足,如成本过高、易引入建模错误等。本文提出了一种自动化模型检测ANSIC程序的方法,并开发了模型提取工具C2Spin,它能够分析ANSIC源代码,并生成对应的PROMELA验证模型,从而显著降低了建模的开销。利用C2Spin,模型检测工具SPIN可以自动地检测使用C语言编写的应用程序中的多种错误,如死锁等。在初步实验中,依靠C2Spin生成的模型,我们发现了SPIN4.3.0的一个语义错误,以及Holzmann对两个经典互斥算法的实现程序中的活锁错误。这些结果表明,C2Spin能够帮助人们更加快速有效地测试C程序。

关键词: 形式化方法, 模型检测, 模型提取, ANSIC, PROMELA

Abstract: Model checking is a formal method for verifying the temporal logic properties of finite state systems. To use the technique, an abstract model is usually constructed by hand, but this approach has some weaknesses, for instance, the cost of modeling is considerably high and the artificial models are errorprone. In this paper, we present a practical method for model checking the ANSIC programs automatically. We built C2Spin, a model extractor which analyzes the C source code and extracts the PROMELA verification model from the source code, and thereby reduce the expense of modeling significantly. Then SPIN can detect various errors in the applications implemented in C mechanically using C2Spin, such as deadlock. In preliminary experiments, depending upon the models generated by C2Spin, we find a semantic bug in SPIN4.3.0 and similar livelocks in the implementation of two classic mutual exclusion algorithms written by Holzmann. The results show that C2Spin helps people test C programs more effectively and quickly.

Key words: formal method;model checking;model extraction;ANSIC;PROMELA

中图分类号: