C++ 调用oracle:malloc.c:2451:sYSMALLOc:Assertion

C++ 调用oracle:malloc.c:2451:sYSMALLOc:Assertion,c++,C++,所以我得到了这个错误 invoke-oracle: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (u

所以我得到了这个错误

invoke-oracle: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Abort (core dumped)
当程序运行此函数时

int  bloom_filter(int *filter,const  char *word, int num, int hnum){
uint64_t *hash;
printf("Using bloom_filter \n");
hash = (uint64_t *) malloc(hnum*sizeof(uint64_t));

int i,j, count =0;
 for (i =0; i < hnum; i++){
  hash[i] = hash_by(i,word);
  j = hash[i] % num;

  if(filter[j]== 1)
  count++;
  else
  filter[j] = 1;
 }
if (count == hnum)
return 1;
else
return 0;
}
int bloom_过滤器(int*过滤器,常量字符*字,int num,int hnum){
uint64_t*散列;
printf(“使用布卢姆过滤器”);
hash=(uint64_t*)malloc(hnum*sizeof(uint64_t));
int i,j,计数=0;
对于(i=0;i
您有堆损坏-尝试在调试器中单步执行此函数,查看
i
j
发生了什么,和/或在valgrind下运行代码,以捕获堆损坏(如果发生时间早于此)。确保
hash\u by
返回有效的内容。我尝试运行它,同时放置了一个“hash=(uint64_t)malloc(hnumsizeof(uint64_t))后面的printf;“它没有出现,所以我假设它与malloc有关。这是在第一次调用函数时发生的吗?我之所以这样问,是因为我没有看到对
散列
free()
的调用,所以您有内存泄漏。是的,它在第一次调用函数时发生。