Frama-C werror插件(https://github.com/sylvainnahas/framac-werror)在此代码中报告错误,但是Eva没有报告任何问题。我曾尝试增加Frama-C的详细程度,但仍然看不到问题出在哪里。我正在运行通过opam在Mac OS 10.13.6上安装的Frama-C 18.0(Argon)。
#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.
但是,如果我删除标记为“ / *问题?* /”的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!),但是我看不到它是什么。有关如何找出伊娃不满意的任何提示?
答案 0 :(得分:4)
werror
插件在这里似乎有问题。请注意,它是一个旧的插件,可能不再维护了。 (实际上,它甚至不能与最新的Frama-C版本一起使用。)
我快速浏览了一下代码,并发出警告,因为Werror
读取了{{1}中对fprintf
进行调用的前提的可访问性状态 }}。 Eva证明此呼叫已死,并且可访问性状态收到状态my_assert_crash
。但是,不应将此视为错误,并且必须修补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
插件,该插件已集成在Frama-C发行版中。您将获得完整的反馈。这是您的示例的结果:
Report