1.MapleCOMSPS_LRB_VSIDS

1

/cygdrive/d/studySAT2022_06/MapleCOMSPS_LRB_VSIDS_no_drup/MapleCOMSPS_LRB_VSIDS/simp/Main.cc:43: undefined reference to `Minisat::memUsedPeak()'
collect2: error: ld returned 1 exit status

 

改正:

在main.c文件中mem_used的赋值将换为确定值,注释掉memUsedPeak()。

void printStats(Solver& solver)
{
    double cpu_time = cpuTime();
    double mem_used = 1; //memUsedPeak();

    。。。。。。

}

   
2

error: ‘fwrite_unlocked’ was not declared in this scope; did you mean ‘_fwrite_unlocked_r’?

375 | fwrite_unlocked(drup_buf, sizeof(unsigned char), buf_len, drup_file);

 

改正:

在solver.h文件中将函数fwrite_unlocked做替换为fwrite.

static inline void binDRUP_flush(FILE* drup_file)

{
    fwrite(drup_buf, sizeof(unsigned char), buf_len, drup_file);
    //fwrite_unlocked(drup_buf, sizeof(unsigned char), buf_len, drup_file);
    buf_ptr = drup_buf; buf_len = 0;
}

   
3

/MapleCOMSPS_LRB_VSIDS_no_drup/MapleCOMSPS_LRB_VSIDS/simp/SimpSolver.cc:24:10: fatal error: m4ri/m4ri.h: No such file or directory
24 | #include <m4ri/m4ri.h>

 

改正:

该版本在SimpSolver.cc中用到头文件定义了以下函数:

    bool SimpSolver::gaussElim();

    bool SimpSolver::performGaussElim(vec<XorScc*>& xor_sccs);

可以将这两个函数在.h的声明和在.cc的定义代码注释掉,同时将其被调用的两处也注释掉。

 

也可以用2019年之后拓展版本的simp文件夹整体将早期版本simp文件夹做替换

   
4

error: friend declaration of ‘Minisat::Lit Minisat::mkLit(Minisat::Var, bool)’ specifies default arguments and isn’t the only declaration [-fpermissive]
60 | inline Lit mkLit (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }

 

struct Lit {
    int x;

    // Use this as a constructor:
    friend Lit mkLit(Var var, bool sign = false);  //更正:将红色代码去掉

    bool operator == (Lit p) const { return x == p.x; }
    bool operator != (Lit p) const { return x != p.x; }
    bool operator < (Lit p) const { return x < p.x; } // '<' makes p, ~p adjacent in the ordering.
};


inline Lit mkLit (Var var, bool sign = false) { Lit p; p.x = var + var + (int)sign; return p; } //更正:红色代码添加

   
   
   

Linking: minisat ( /cygdrive/d/studySAT2022_06/MapleCOMSPS_CHB_VSIDS_no_drup/MapleCOMSPS_CHB_VSIDS/simp/Main.o /cygdrive/d/studySAT2022_06/MapleCOMSPS_CHB_VSIDS_no_drup/MapleCOMSPS_CHB_VSIDS/simp/SimpSolver.o utils/Options.o utils/System.o core/Solver.o )
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lm4ri
collect2: error: ld returned 1 exit status
make: *** [..//mtl/template.mk:77: minisat] Error 1

   
5

assertion "j < ts.size()" failed: file "../mtl/Alg.h", line 41, function: void Minisat::remove(V&, const T&) [with V = Minisat::vec<Minisat::Solver::Watcher>; T = Minisat::Solver::Watcher]
Aborted (core dumped)

 

查找原因是:

访问子句的  c.activity() 出错。如何纠正?

   
6

运行中出现异常终止并显示:

Segmentation fault (core dumped)

先检查是否正确的初始化外部文件指针(声明了,但没有初始化,在写操作时会报错,甚至没有写操作在关闭时访问该指针也会报错。)

随后,查询原因可能是内存泄漏:

百度搜到解释的很好的博客文章:https://blog.csdn.net/Iohboel/article/details/51474335

    造成segment fault,产生core dump的可能原因 

    1.内存访问越界   a) 由于使用错误的下标,导致数组访问越界   b) 搜索字符串时,依靠字符串结束符来判断字符串是否结束,但是字符串没有正常的使用结束符   c) 使用strcpy, strcat, sprintf, strcmp, strcasecmp等字符串操作函数,将目标字符串读/写爆。应该使用strncpy, strlcpy, strncat, strlcat, snprintf, strncmp, strncasecmp等函数防止读写越界。 

    2 多线程程序使用了线程不安全的函数。 

    3 多线程读写的数据未加锁保护。对于会被多个线程同时访问的全局数据,应该注意加锁保护,否则很容易造成core dump 

    4 非法指针 

         a) 使用空指针 

         b) 随意使用指针转换。一个指向一段内存的指针,除非确定这段内存原先就分配为某种结构或类型,或者这种结构或类型的数组,否则不要将它转换为这种结构或类型 的指针,而应该将这段内存拷贝到一个这种结构或类型中,再访问这个结构或类型。这是因为如果这段内存的开始地址不是按照这种结构或类型对齐的,那么访问它 时就很容易因为bus error而core dump. 

    5 堆栈溢出.不要使用大的局部变量(因为局部变量都分配在栈上),这样容易造成堆栈溢出,破坏系统的栈和堆结构,导致出现莫名其妙的错误。

   
7

运行中出现  Aborted (core dumped)

通常伴随或者断言位置或语句的指示。所以在写代码时在关键语句段适当加入断言语句十分必要。

   
8

assertion "r >= 0 && r < sz" failed: file "../mtl/Alloc.h", line 35, function: T& Minisat::RegionAllocator<T>::operator[](Minisat::RegionAllocator<T>::Ref) [with T = unsigned int; Minisat::RegionAllocator<T>::Ref = unsigned int]
Aborted (core dumped)

查看Alloc.h,

 1 // Simple Region-based memory allocator:
 2 
 3 template<class T>
 4 class RegionAllocator
 5 {
 6     T*        memory;
 7     uint32_t  sz;
 8     uint32_t  cap;
 9     uint32_t  wasted_;
10 
11     void capacity(uint32_t min_cap);
12 
13  public:
14     // TODO: make this a class for better type-checking?
15     typedef uint32_t Ref;
16     enum { Ref_Undef = UINT32_MAX };
17     enum { Unit_Size = sizeof(uint32_t) };
18 
19     explicit RegionAllocator(uint32_t start_cap = 1024*1024) : 
memory(NULL), sz(0), cap(0), wasted_(0){ capacity(start_cap); } 20 ~RegionAllocator() 21 { 22 if (memory != NULL) 23 ::free(memory); 24 } 25 26 27 uint32_t size () const { return sz; } 28 uint32_t wasted () const { return wasted_; } 29 30 Ref alloc (int size); 31 void free (int size) { wasted_ += size; } 32 33 // Deref, Load Effective Address (LEA), Inverse of LEA (AEL): 34 T& operator[](Ref r) { assert(r >= 0 && r < sz); return memory[r]; } 35 const T& operator[](Ref r) const { assert(r >= 0 && r < sz); return memory[r]; } 36 37 T* lea (Ref r) { assert(r >= 0 && r < sz); return &memory[r]; } 38 const T* lea (Ref r) const { assert(r >= 0 && r < sz); return &memory[r]; } 39 Ref ael (const T* t) {
assert((void*)t >= (void*)&memory[0] && (void*)t < (void*)&memory[sz-1]); 40 return (Ref)(t - &memory[0]); } 41 42 void moveTo(RegionAllocator& to) { 43 if (to.memory != NULL) ::free(to.memory); 44 to.memory = memory; 45 to.sz = sz; 46 to.cap = cap; 47 to.wasted_ = wasted_; 48 49 memory = NULL; 50 sz = cap = wasted_ = 0; 51 } 52 53 54 };

 

发现问题处在二元子句的处理上。以下函数代码中红色标出部分不能省略。如果去掉红色代码,运行dist8.c.cnf在36000次冲突左右会出现上述越界断言。

 1 // pathCs[k] is the number of variables assigned at level k,
 2 // it is initialized to 0 at the begining and reset to 0 after the function execution
 3 bool Solver::collectFirstUIP(CRef confl){
 4     involved_lits.clear();
 5     int max_level=1;
 6     Clause& c = ca[confl]; int minLevel = decisionLevel();
 7     for(int i=0; i<c.size(); i++) {
 8         Var v = var(c[i]);
 9         //        assert(!seen[v]);
10         if (level(v)>0) {
11             seen[v] = 1;
12             var_iLevel_tmp[v] = 1;
13             pathCs[level(v)]++;        
14             if (minLevel>level(v)) {
15                 minLevel=level(v);
16                 assert(minLevel>0);
17             }
18             //    varBumpActivity(v);
19         }
20     }
21 
22     int limit=trail_lim[minLevel-1];
23     for(int i=trail.size()-1; i>=limit; i--) {
24         Lit p=trail[i]; Var v=var(p);
25         if (seen[v]) {
26             int currentDecLevel=level(v);
27             //      if (currentDecLevel==decisionLevel())
28             //          varBumpActivity(v);
29             seen[v]=0;
30             if (--pathCs[currentDecLevel]!=0) {
31                 Clause& rc=ca[reason(v)];
32                 int reasonVarLevel = var_iLevel_tmp[v] + 1;
33                 if(reasonVarLevel>max_level) max_level = reasonVarLevel;
34                 if (rc.size()==2 && value(rc[0])==l_False) {
35                     // Special case for binary clauses
36                     // The first one has to be SAT
37                     assert(value(rc[1]) != l_False);
38                     Lit tmp = rc[0];
39                     rc[0] =  rc[1], rc[1] = tmp;
40                 }
41                 for (int j = 1; j < rc.size(); j++){
42                     Lit q = rc[j]; Var v1=var(q);
43                     if (level(v1) > 0) {
44                         if (minLevel>level(v1)) {
45                             minLevel=level(v1); 
limit=trail_lim[minLevel-1]; assert(minLevel>0); 46 } 47 if (seen[v1]) { 48 if (var_iLevel_tmp[v1]<reasonVarLevel) 49 var_iLevel_tmp[v1]=reasonVarLevel; 50 } 51 else { 52 var_iLevel_tmp[v1]=reasonVarLevel; 53 // varBumpActivity(v1); 54 seen[v1] = 1; 55 pathCs[level(v1)]++; 56 } 57 } 58 } 59 } 60 involved_lits.push(p); 61 } 62 } 63 double inc = var_iLevel_inc; 64 65 ....... 66 ...... 67 68 return true; 69 }

 

 

   
9

2017年版本编译通过后,运行中出现异常:

 

经查原因如下:

由于定义有BIN_DRUP

                  #define BIN_DRUP  //见solver.h

程序运行中遇到需要向外输出时见下面代码,如果没有相应的外部文件设定,就会出现上述错误。

 1 //见函数bool Solver::simplifyLearnt_tier2()含有以下代码段:
 2 
 3 #ifdef BIN_DRUP                    
 4         binDRUP('a', c , drup_file);           
 5                     //   binDRUP('d', add_oc, drup_file);
 6 #else                    
 7         for (int i = 0; i < c.size(); i++)
 8              fprintf(drup_file, "%i ", (var(c[i]) + 1) * (-2 * sign(c[i]) + 1));
 9         fprintf(drup_file, "0\n");            
10 
11         //fprintf(drup_file, "d ");
12         //for (int i = 0; i < add_oc.size(); i++)
13         //   fprintf(drup_file, "%i ", (var(add_oc[i]) + 1) * (-2 * sign(add_oc[i]) + 1));
14         //fprintf(drup_file, "0\n");
15 #endif 

解决办法之一

     在主函数中提供带路径的外部输出文件:my_drup_file.txt

     

 1 int main(int argc, char** argv)
 2 {
 3     try {
 4         setUsageHelp("USAGE: %s [options] <input-file> <result-output-file>\n\n
where input may be either in plain or gzipped DIMACS.\n
"); 5 printf("c This is COMiniSatPS.\n"); 6 7 #if defined(__linux__) 8 fpu_control_t oldcw, newcw; 9 _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) | _FPU_DOUBLE; _FPU_SETCW(newcw); 10 printf("c WARNING: for repeatability, setting FPU to use double precision\n"); 11 #endif 12 // Extra options: 13 // 14 IntOption verb ("MAIN", "verb", "Verbosity level
(0=silent, 1=some, 2=more).
",
1, IntRange(0, 2)); 15 BoolOption pre ("MAIN", "pre", "Completely turn on/off any preprocessing.",
true); 16 StringOption dimacs ("MAIN", "dimacs", "If given, stop after preprocessing and
write the result to this file.
"); 17 IntOption cpu_lim("MAIN", "cpu-lim","Limit on CPU time allowed in seconds.\n",
INT32_MAX, IntRange(0, INT32_MAX)); 18 IntOption mem_lim("MAIN", "mem-lim","Limit on memory usage in megabytes.\n",
INT32_MAX, IntRange(0, INT32_MAX)); 19 BoolOption drup ("MAIN", "drup", "Generate DRUP UNSAT proof.", false); 20 StringOption drup_file("MAIN", "drup-file", "DRUP UNSAT proof ouput file.",
"./mydrup_file.txt"); 21 22 parseOptions(argc, argv, true); 23 ...... 24 }

 程序运行前确保 mydrup_file.txt与exe文件在同一路径目录下。

 

 

解决办法之二

  直接在solver.h中屏蔽 #define BIN_DRUP即可。

   
 

造成segment fault,产生core dump的可能原因 :

1.内存访问越界   

  a) 由于使用错误的下标,导致数组访问越界   

  b) 搜索字符串时,依靠字符串结束符来判断字符串是否结束,但是字符串没有正常的使用结束符   

  c) 使用strcpy, strcat, sprintf, strcmp, strcasecmp等字符串操作函数,将目标字符串读/写爆。应该使用strncpy, strlcpy, strncat, strlcat, snprintf, strncmp, strncasecmp等函数防止读写越界。 

2 多线程程序使用了线程不安全的函数。 

3 多线程读写的数据未加锁保护。对于会被多个线程同时访问的全局数据,应该注意加锁保护,否则很容易造成core dump 

4 非法指针 

  a) 使用空指针 

  b) 随意使用指针转换。一个指向一段内存的指针,除非确定这段内存原先就分配为某种结构或类型,或者这种结构或类型的数组,否则不要将它转换为这种结构或类型 的指针,而应该将这段内存拷贝到一个这种结构或类型中,再访问这个结构或类型。这是因为如果这段内存的开始地址不是按照这种结构或类型对齐的,那么访问它 时就很容易因为bus error而core dump. 

5 堆栈溢出.不要使用大的局部变量(因为局部变量都分配在栈上),这样容易造成堆栈溢出,破坏系统的栈和堆结构,导致出现莫名其妙的错误。

   

 

其它错误

1

python 读入文件错误

ParserError: Error tokenizing data

解决方法:

csv文件默认的是以逗号为分隔符,但是经常混入中文逗号,这样在读取csv进行数据处理时,一定记得加上一个分隔符参数:

    df = pd.read_csv(infilename, sep=',')

这里的逗号是中文午字符。

在读取results2018d1glueFactor02NoSLS.csv时发生错误,增加分割符是英文逗号,也解决了问题。

   
2

运行时,出现:Segmentation fault (core dumped) 错误

指针m声明后没有初始化,后面使用 *m, 会出现这种错误。

 

   
3

曙光平台

发生如下两种错误之一,没有正常求解问题

/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /public/home/ac2joy4etx/lstech_maple2021_0/sources/simp/glucose)

解决办法

第一步:    

  先查看当前Linux服务器gcc版本中包含哪些库
  strings /usr/lib64/libstdc++.so.6 | grep GLIBC
  strings /usr/lib64/libstdc++.so.6|grep CXXABI

第二步:

  加载模块:module load compiler/gnu/9.3.0

  加载之前需要卸载与之冲突的相应模块,例如,    

    module unload compiler/rocm/2.9
    module unload compiler/devtoolset/7.3.1

              冲突提示实例:

compiler/gnu/9.3.0(4):ERROR:150: Module 'compiler/gnu/9.3.0' conflicts with the currently loaded module(s) 'compiler/rocm/2.9'
compiler/gnu/9.3.0(4):ERROR:102: Tcl command execution failed: conflict compiler

[ac2joy4etx@login04 ~]$ module load compiler/gnu/9.3.0
compiler/gnu/9.3.0(4):ERROR:150: Module 'compiler/gnu/9.3.0' conflicts with the currently loaded module(s) 'compiler/devtoolset/7.3.1'
compiler/gnu/9.3.0(4):ERROR:102: Tcl command execution failed: conflict compiler

   
posted on 2022-06-21 11:22  海阔凭鱼跃越  阅读(89)  评论(0编辑  收藏  举报