当前位置:网站首页>[南京大学]-[软件分析]课程学习笔记(一)-introduction
[南京大学]-[软件分析]课程学习笔记(一)-introduction
2022-07-07 05:51:00 【西杭】
文章目录
南京大学 Static program analysis
introduction
1. program language and static analysis
编程语言:
- 理论
- 语言设计
- 类型系统
- 语义和逻辑
- …
- 环境
- 编译器
- 运行时系统
- …
- 应用
- 程序分析
- 程序验证
- 程序合成
- …
背景:在过去的十年中,语言的核心基本没有变化,但是程序变得显著的更大和更复杂;
挑战:如何确保大规模复杂程序的可靠性、安全性和其他承诺
2. why we learn static analysis
程序的可靠性reliability:
- null pointer dereference 空指针引用
- 去引用的时候没有define,就会带来很多bug
- memory leak 内存泄漏
- malloc没有free,内存占用过多会导致crash
程序的安全性security:
- private information leak 私有信息的泄露
- injection attack 注入攻击
编译器优化
- dead code elimination 死代码消除
- code motion 代码移动
程序理解
- IDE call hierarchy 调用层次
- type indication 类型指示
3. what is static analysis
Static analysis analyzes a program P to reason about its behaviors and determines whether it satisfies some properties before running P.
静态分析通过分析程序P来推理其行为,并在运行P之前确定其是否满足某些属性
- Does P contain any private information leaks?
- Does P dereference any null potinters?
- Are all the cast operations in P safe? 类型转换操作符
- Can v1 and v2 in P point to the same memory location?
- Will certain assert statements in P fail?
- Is this piece of code in P dead(so that it could be eliminated)?
Rice theory 莱斯定理: 不存在一个方法可以确定的给出一个程序是否满足一些非平凡属性的判断。
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
递归可枚举的语言就是图灵机可识别的语言
non-trivial 不简单,重要
以上表述为一个perfect static analysis是不存在的
从学术的角度来看,一个perfect的static analysis需要满足以下两个条件:
- sound:over approximate 包含true
- complete: under approximate true包含
所以并不追求完美的静态分析,而是追求useful static analysis:
- Compromise soundness(false negatives)折中的漏报控制
- Compromise completeness (false positives) 折中的误报控制
Mostly compromising completeness: Sound but not fully-precise static analysis
绝大多数静态分析追求的都是追求Soundness,会造成误报
Soundness is critical to a collection of important(static-analysis) applications such as compiler optimization and program verification.
Static analysis: ensure (or get close to) soundness, while making good trade-offs between analysis precision and analysis speed.
确保soundness,并在分析精度和分析速度之间做好权衡
4. static analysis features and examples
Abstraction + Over-approximation
抽象和过近似
- abstraction
- over-approximation
- transfer function
- control flows
Example:
判断给定的程序中所有变量的符号:正、负或者是0.
- T:unknow 可正可负(over-approximation 过近似)
- bottom:undefined,除零操作,抛出异常操作
transfer function定义了如何在抽象值上评估不同的程序状态,并且应该根据分析问题和不同程序状态的语义去定义
- 1问题是除零、抛出异常,则应该为undefined;
- 2问题是下标为负,抛出异常,也应该为undefined
- 3问题则是over-approximated,也即是误报,在实际的程序中a=x+y=9,所以并不会报错,而在抽象化为符号的过程中会模糊这个界限,导致产生误报
控制流分析,y的两个值是两个branch,执行分支不同会使z的值产生变化。并且在实际中枚举所有路径是不可能的,空间特别庞大,因此flow merging则被很多静态分析采用。
边栏推荐
- Xcit learning notes
- Using helm to install rainbow in various kubernetes
- GFS distributed file system
- Openvscode cloud ide joins rainbow integrated development system
- [kuangbin] topic 15 digit DP
- 为什么要选择云原生数据库
- [IELTS speaking] Anna's oral learning records Part3
- Rainbow 5.7.1 supports docking with multiple public clouds and clusters for abnormal alarms
- Improve the delivery efficiency of enterprise products (1) -- one click installation and upgrade of enterprise applications
- Exercise arrangement 2.10, 11
猜你喜欢
Obsidan之数学公式的输入
Exercise arrangement 2.10, 11
Are you holding back on the publicity of the salary system for it posts such as testing, development, operation and maintenance?
SSM 整合
Pvtv2--pyramid vision transformer V2 learning notes
Merge sort and non comparison sort
[untitled]
The field value in Splunk subquery fuzzy matching CSV is*
[paper reading] icml2020: can autonomous vehicles identify, recover from, and adapt to distribution shifts?
Compilation and linking of programs
随机推荐
What is the method of manual wiring in PCB design in 22protel DXP_ Chengdu electromechanical Development Undertaking
[go ~ 0 to 1] obtain timestamp, time comparison, time format conversion, sleep and timer on the seventh day
uniapp 微信小程序监测网络
DeiT学习笔记
Exercise arrangement 2.10, 11
You should use Google related products with caution
JEditableTable的使用技巧
Teach you how to select PCB board by hand (II)
Low success rate of unit test report
国标GB28181协议视频平台EasyGBS新增拉流超时配置
2-3查找樹
【无标题】
Basic data types and string types are converted to each other
String operation
下载和安装orcale database11.2.0.4
MES系统,是企业生产的必要选择
Analyzing the influence of robot science and technology development concept on Social Research
如何在HarmonyOS应用中集成App Linking服务
21 general principles of wiring in circuit board design_ Provided by Chengdu circuit board design
Input of mathematical formula of obsidan