如何修复CLIPS的“ ProfileInfoCommand”的核心转储?

时间:2019-10-31 04:26:07

标签: rules rule-engine clips expert-system

CLIPS版本:6.31
语言:c++ clips C API

ProfileInfoCommand之后执行EnvRun时,我得到一个coredump文件。
为什么会发生此错误?这里有使用错误吗?还是这是一个错误?

c ++代码1:

#define PROFILING_FUNCTIONS 1

// ...

EnvReset(clips);

// ...
EnvLoadFactsFromString(clips, facts.str().c_str(), -1);
// ...

EnvRun(clips, 100000);
ProfileInfoCommand(clips);

我知道是否将PROFILING_FUNCTIONS定义为1,EnvRun函数将自动启动配置文件。因此,我在ProfileInfoCommand之后使用EnvRun,但是发生了核心转储!

我也尝试使用另一种方法,但是该过程还生成了一个核心转储(与the c++ code 1相同的回溯)。
c ++代码2:

EnvReset(clips);
Profile(clips, "constructs");

// ...
EnvLoadFactsFromString(clips, facts.str().c_str(), -1);
// ...

EnvRun(clips, max_iters);
Profile(clips, "off");
ProfileInfoCommand(clips);

核心转储文件如下:

Core was generated by `/mnt/home/worker/project/ae-arbiter/dist/bin/arbiter-8003 --flagfile=flags.'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000bc6b80 in EnvRtnArgCount (theEnv=Cannot access memory at address 0x7f879c3f6af8
) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:306
306    for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.x86_64
(gdb) bt
#0  0x0000000000bc6b80 in EnvRtnArgCount (theEnv=0x7f85e6454f70) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:306
#1  0x0000000000bc6bcd in EnvArgCountCheck (theEnv=0x7f85e6454f70, functionName=0xda1188 "profile", countRelation=2, expectedNumber=1) at /mnt/home/worker/project/ae-arbiter/src/clips/argacces.cc:337
#2  0x0000000000c40803 in ProfileInfoCommand (theEnv=0x7f85e6454f70) at /mnt/home/worker/project/ae-arbiter/src/clips/proflfun.cc:245
#3  0x0000000000b62d12 in arbiter::lib::ClipsModuleExecute (clips=0x7f85e6454f70, features=..., max_iters=100000, result_func=..., module_name=..., halt=@0x7f879c3f6fdc)
    at /mnt/home/worker/project/ae-arbiter/src/lib/clips-utils.cc:357
...
...

1 个答案:

答案 0 :(得分:0)

在调用EnvRun时,将PROFILING_FUNCTIONS设置为1不会自动分析代码。它确定配置文件功能是否包含在CLIPS可执行文件中。请参见Advanced Programming Guide的2.2节。 Basic Programming Guide的第13.15节“分析命令”中介绍了CLIPS命令可进行分析的功能。无法直接调用ProfileInfoCommand。如果要调用CLIP命令/函数(不是《高级编程指南》中描述的API的一部分),请使用EnvEval API:

DATA_OBJECT returnValue;

EnvEval(theEnv,"(profile-info)",&returnValue);