【问题标题】:What does the message "unreachable entry point" mean?消息“无法访问的入口点”是什么意思?
【发布时间】:2016-07-25 15:20:59
【问题描述】:

我有一个包含多个 ACSL 断言的文件 (file.c):

#include <stdio.h>
#include <stdlib.h>

void foo()    {
  int a=0;
  //@ assert(a==0);
}

void print(const char* text)   {
    int a=0;
    //@ assert(a==0);
    printf("%s\n",text);
}

int main (int argc, const char* argv[])    {
    const char* a1 = argv[2];

    print(a1);
    foo();

    if (!a1)
      //@ assert(!a1);
        return 0;
    else
        return 1;
}

我想使用以下命令对所有断言进行切片:

frama-c -slice-assert @all file.c -then-on 'Slicing export' -print -ocode slice.c

但是,切片看起来并不像预期的那样(实际上它不包含文件中包含的任何函数):

/* Generated by Frama-C */
typedef unsigned int size_t;
/*@ ghost extern int __fc_heap_status __attribute__((__FRAMA_C_MODEL__)); */

/*@
axiomatic dynamic_allocation {
  predicate is_allocable{L}(size_t n) 
    reads __fc_heap_status;

  }
 */
void main(void)
{
  char const *a1;
  return;
}

相反,我得到这样的输出:

file.c:16:[kernel] warning: out of bounds read. assert \valid_read(argv+2);
[value] Recording results for main
[value] done for function main
file.c:16:[value] Assertion 'Value,mem_access' got final status invalid.
[slicing] making slicing project 'Slicing'...
[slicing] interpreting slicing requests from the command line...
[pdg] computing for function foo
[pdg] warning: unreachable entry point (sid:1, function foo)
[pdg] Bottom for function foo
[slicing] bottom PDG for function 'foo': ignore selection
[pdg] computing for function main
file.c:21:[pdg] warning: no final state. Probably unreachable...
[pdg] done for function main
[pdg] computing for function print
[pdg] warning: unreachable entry point (sid:5, function print)
[pdg] Bottom for function print
[slicing] bottom PDG for function 'print': ignore selection

这里出了什么问题,特别是unreachable entry point 是什么?观察:如果我将argv[2] 更改为argv[1] 我没有这些问题(但仍然在第一行得到警告)。

【问题讨论】:

    标签: frama-c program-slicing


    【解决方案1】:

    切片需要计算使用Value分析结果的PDG(Program Dependent Graph)。警告 unreachable entry point 意味着,在您给出的上下文中,函数 foo 不可访问(即,它是从不可访问的语句中调用的)。

    没有例子很难告诉你更多......


    编辑:

    在您提供的输出中,请注意以下几行:

    file.c:16:[kernel] warning: out of bounds read. assert \valid_read(argv+2);
    

    file.c:16:[value] Assertion 'Value,mem_access' got final status invalid.
    

    当价值分析遇到一个无效的属性时,它就不能再进一步了。因为这里警报来自第一个语句,所以其他所有内容都变得无法访问。无效属性是\valid_read(argv+2);,因为输入上下文的默认值是argv 的宽度为2。这可以通过使用选项-context-width 3 来解决,或者通过使用另一个不带参数的分析入口点(并用-main my_main 指定),明确定义argcargv,然后调用真实的main 和他们一起。

    建议仅在检查值分析结果是否正常后才使用切片。您可以使用-val 选项单独运行它,并根据需要调整其他选项。

    【讨论】:

    • 感谢您的回答。我已经能够制定一个说明性示例并相应地编辑(/重构)我的问题。
    猜你喜欢
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 2010-10-01
    • 2015-06-22
    • 1970-01-01
    • 2012-10-07
    • 2013-04-10
    相关资源
    最近更新 更多