Eva不报错怎么把-werror错误和代码问题联系起来?

How to associate -werror errors with code problem when Eva doesn't report any errors?

Frama-C werror 插件(https://github.com/sylvainnahas/framac-werror)报告此代码错误,但 Eva 没有报告任何问题。我试过增加 Frama-C 的冗长程度,但我仍然看不出问题出在哪里。我是 运行 Frama-C 18.0 (Argon) 通过 opam 安装在 Mac OS 10.13.6.

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

#define MY_ASSERT(must_be_true__) \
(void)((must_be_true__) ? (void)0 : my_assert_crash())

void my_assert_crash() {
    fprintf(stderr, "my_assert_crash\n");  /* problem here? */
    exit(1);
}

int main(void) {
    MY_ASSERT(true);
    return 0;
}

Frama-C 命令行和输出为:

$ frama-c -c11 -machdep x86_64 assertion_no_diagnostic.c -eva -eva-slevel 10 -then -nonterm -then -werror -werror-no-external
[kernel] Parsing assertion_no_diagnostic.c (with preprocessing)
[eva] Analyzing a complete application starting at main
[eva] Computing initial state
[eva] Initial state computed
[eva:initial-state] Values of globals at initialization

[eva] done for function main
[eva] ====== VALUES COMPUTED ======
[eva:final-states] Values at end of function main:
  __retres ∈ {0}
[werror] Analysis reports 1 bug(s) (invalid and complete proofs). Aborting.

但是,如果我删除标记为“/* problem here? */”的 fprintf 行,错误消息就会消失:

$ frama-c -c11 -machdep x86_64 assertion_non_fprintf_before_exit.c -eva -eva-slevel 10 -then -nonterm -then -werror -werror-no-external
[kernel] Parsing assertion_non_fprintf_before_exit.c (with preprocessing)
[eva] Analyzing a complete application starting at main
[eva] Computing initial state
[eva] Initial state computed
[eva:initial-state] Values of globals at initialization

[eva] done for function main
[eva] ====== VALUES COMPUTED ======
[eva:final-states] Values at end of function main:
  __retres ∈ {0}

我觉得我在做一些愚蠢的事情(特别是因为这是我第一次尝试使用 Frama-C!)但我看不出它是什么。关于如何找出伊娃不高兴的事情有什么建议吗?

这里的werror插件似乎有问题。请注意,这是一个旧插件,可能不再维护。 (事实上​​ ,它甚至无法使用最新的 Frama-C 版本进行开箱即用的编译。)

我快速浏览了一下代码,发出警告是因为 Werror 读取了调用 [=14= 的先决条件的 可访问性状态 ] 在 my_assert_crash。 Eva 证明此调用已死亡,可访问性状态收到状态 Invalid。但是,这不应算作错误,Werror 必须打补丁。我建议您应用以下补丁。但是,您会注意到您仍然会收到与死代码相关的错误。

diff --git a/inspector.ml b/inspector.ml
index 09d40fa..816ec2e 100644
--- a/inspector.ml
+++ b/inspector.ml
@@ -55,8 +57,9 @@ object(self)

   method statistics (ip:Property.t) st =
     begin
-      ignore(ip);
-      self#categorize st;
+      match ip with
+      | Property.IPReachable _ -> ()
+      | _ -> self#categorize st
     end

   method abort_on_error =

总体而言,Werror 需要进行重大更新。我的建议是改用 Report 插件,它集成在 Frama-C 发行版中。您将获得完整的反馈。这是您示例的结果:

[...] many statuses

--------------------------------------------------------------------------------
--- Status Report Summary
--------------------------------------------------------------------------------
   135 Completely validated
   363 Considered valid
     1 Dead property
     1 Unreachable
   500 Total