zoukankan      html  css  js  c++  java
  • Proj THUDBFuzz Paper Reading: 南京大学软件分析课程2020, 16 CFL-Reachability and IFDS

    Feasible and Realizable Paths

    Given a path, determine whether it is feasible is, in general, undecidable.
    Realizable Paths: The paths in which “returns” are matched with corresponding “calls”
    明显,feasible path一定满足realizable。
    所以我们可以先识别realizable paths,避开分析unrealizable paths。
    这里课件上的例子实在不能理解为什么不是exit main。

    CFL-Reachablity

    如果路径的边上面的标签串成的字符串是特定的上下文无关语言中的词汇,则称B is reachable from A.
    A path is considered to connect two nodes A and B, or B is reachable from A, only if the concatenation of the labels on the edges of the path is a word in a specified context-free language.
    在这里就是)i前面一定紧跟着一个(i,在消除匹配到的之后紧跟着也行,反过来(i则不一定跟着)i,也就是可以调用子函数而不返回。

    这样就把寻找unrealizable paths的问题转化为括号匹配问题。

    Overview of IFDS

    特点

    "Precise Interprocedural Dataflow Analysis via Graph Reachability” Thomas Reps, Susan Horwitz, and Mooly Sagiv, POPL’95
    是一个使用图可达性来做程序分析的框架。
    IFDS分别代表进程间Interprocedural,有限Finite(finite domains),分布式Distributive(distributive flow functions),子集Subset。
    是meet-over-all-realizable-paths的。

    算法

    一共三步:

    1. 为程序P创建supergraph G并基于当前问题定义G中所有边的flow functions
    2. 将supergraph G*中定义的flow functions转化为representation relations即exploded supergraph G#。
    3. 最后,在G#上使用Tabulation算法通过解决图可达性的思路来解决该问题

    Supergraph and Flow Functions


    G* has three edges for each procedure call:

    • An intraprocedural call-to-return-site edge from Callp to Retp
    • An interprocedural call-to-start edge from Callp to sp of the called procedure
    • An interprocedural exit-to-return-site edge from ep of the called procedure to Retp

    课件中定义flow functions的基本形式是λ param: body。例如: λ x.x+1
    注意:

    1. call-to-return这种边只允许传递本地变量,所以要在传递时把全局变量特意去掉,以减少假阳样本。(?)

    例如,对探查可能没有初始化的变量,

    感觉具体的应用范围还是有点局限,对外部调用需要人工建函数,对很多变量的情况未必处理得很好,而且还是context-insensitive的。

    Exploded Supergraph and Tabulation Algorithm

    Exploded Supergraph

    直接用<程序点, 变量>作为节点,以transfer function为逻辑参考来画边,令人很怀疑能否处理AND这个逻辑

    Tabulation Algo

    用函数p入口点Sp的自环来表示可达性非常有趣也有创造性,这样就只需记录Sp,起始状态->节点,大大加快了速度,节约了空间。

    Understanding the Distributivity of IFDS

    IFDS的局限性

    由于constant propagation(像SAT一样直接解出全体可行解??)有无穷个选项,所以IFDS不能解
    而考虑到IDFS难以表示y=x.f,也就是说难以表示o_i∈ x AND o_j ∈ o_i.f,做pointer analysis的效果也不会好。
    例如z = x + y,显然要想知道z的值,必须要同时知道x和y的值。
    为了处理这个,必须要拆成z = x; z = z + y;
    给定语句S,如果除了S本身,我们还需要知道两个及以上的input data facts,那么这个分析就是not distributive,不应该用IFDS来做。在IFDS中,每个data fact和其传递都应该互相独立无关,可以分别处理结果不会产生变化。F(x∩y) = F(x)∩F(y)的高端版本

  • 相关阅读:
    python之面向对象编程
    python的模块引用和查找路径
    python的迭代器、生成器、三元运算、列表解析、生成器表达式
    python文件操作
    lesson4-图像分类-小象cv
    lesson3-神经序列模型I-小象
    fast ai环境配置
    YOLO
    lesson2-cnn-fastai
    mask-code-python
  • 原文地址:https://www.cnblogs.com/xuesu/p/14341587.html
Copyright © 2011-2022 走看看