南大《软件分析》课程笔记——第一课
前言
课程网站:https://pascal-group.bitbucket.io/teaching.html
课程视频在B站有
感谢两位老师分享
概述
课程介绍
Static Program Analysis
PL(Programming Languages)
三类编程语言
- 命令式
- 函数式
- 逻辑式
- 程序可靠性
- 程序安全性
- 编译优化
- 程序理解
PL(Program Language)
- 理论:语言设计,类型系统,语义和逻辑
- 环境:编译器,运行系统
- 应用:程序分析,程序验证,程序合成
- 技术:抽象解释(Abstract interpretation),数据流分析(Data-flow analysis, ),Hoare logic,Model checking,Symbolic execution等等
Static Analysis
什么是静态分析?在程序运行前就进行分析以推断其行为并确定在运行之前是否满足某些属性。
Rice's Theorem
“Any non-trivial property of the behavior of programs in a r.e. language is undecidable.”
r.e. (recursively enumerable) = recognizable by a Turing-machine
A property is trivial if either it is not satisfied by any r.e. language, or if it is satisfied by all r.e. languages; otherwise it is non-trivial.
non-trivial properties
~= interesting properties
~= the properties related with run-time behaviors of programs
不存在满足Sound&Complete的静态分析程序,理解翻译为全面性和完整性吧
即分别对应漏报率(false negatives)与误报率(false positives),不存在完美的静态分析程序使漏报率与误报率为0。
- Compromise soundness (false negatives) 妥协全面性,对程序进行了under-approximate欠拟合,不会误报但是有漏报
- Compromise completeness (false positives) 妥协完整性,对程序进行了over-approximate过拟合,不会漏报但又误报
Mostly compromising completeness: Sound but not fully-precise static analysis
大部分静态分析程序要求做到sound即覆盖全面,优先追求漏报率低,再降低误报率。
Necessity of Soundness
Static Analysis: ensure (or get close to) soundness, while making good trade-offs between analysis precision and analysis speed.
在精度和速度之间做平衡
Static Analysis = Abstraction + Over-approximation
Abstraction
抽象化,将具体值变为抽象值
Over-approximation
Trsansfer Functions
在静态分析中,传递函数定义了如何评估关于抽象值的不同程序语句。
Over-approximation(翻成过于近似?)的静态分析会产生误报
Control Flows: