OpenMP双重释放或损坏(fasttop)错误(C ++)

时间:2019-06-26 04:24:09

标签: c++ openmp

使用OpenMP用C ++编写的以下代码出现double free or corruption (fasttop)错误。我是并行编程的新手。我想知道如何为MM数据结构使用锁。

  vector <unsigned char *> XX;
  int bbh;  
  .....
  .....
  ..... 
  unordered_map<uint64_t, vector<int>> MM;
  #pragma omp parallel for shared(MM)
  for (i = 0; i < seqns.size()-1; i++) {
    for (int p = 0; p < k*bbh; p += 2*bbh) {
      string s1((char*) (XX[i]+p));
      string s2((char*) (XX[i]+p+bbh));
      string s3 = s1+s2;
      uint64_t hash = 0;
      MetroHash64::Hash((uint8_t*)s3.c_str(), s3.length(), (uint8_t *)&hash, 0);
      if(MM.find(hash) != MM.end()) { MM[hash].push_back(i); }
      else {vector<int> v; v.push_back(i); MM.insert(make_pair(hash, v));}
    }
  }

0 个答案:

没有答案