kaede_1 发表于 2016-09-20 12:13

dense_hash_map 段错误求解

尝试使用dense_hash_map,同一个函数加载其他文件数据没问题,加载另一份数据就段错误,相关代码片段如下:
    dense_hash_map<uint64_t, dense_hash_map<uint32_t, float> > g_map;
    g_map.set_empty_key(-99999);
    while( 1 == fread(&id, sizeof(uint64_t), 1, fpr) )
    {   
      iRet = fread(&udwNum, sizeof(uint32_t), 1, fpr );
      if(iRet != 1)
      {   
            break;
      }   

      dense_hash_map<uint32_t, float> tmp_map;
      tmp_map.set_empty_key(-99999);
      for(int j=0; j<udwNum; j++)
      {   
            iRet = fread(&info, sizeof(ID2SCORE), 1, fpr);
            if(iRet != 1)
            {   
                break;
            }   
            tmp_map = tmp_map;
      }   
      g_map = tmp_map;
    }
相关堆栈如下:
(gdb) bt
#00x0000003b05479252 in _int_malloc () from /lib64/libc.so.6
#10x0000003b0547a6b1 in malloc () from /lib64/libc.so.6
#20x0000000000426aa0 in google::libc_allocator_with_realloc<std::pair<unsigned int const, float> >::allocate (this=0x7ffe3b08e260, n=64)
    at /usr/local/include/sparsehash/internal/libc_allocator_with_realloc.h:62
#30x000000000042895c in google::dense_hashtable<std::pair<unsigned int const, float>, unsigned int, std::tr1::hash<unsigned int>, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SelectKey, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::clear_to_size (this=0x7ffe3b08e220, new_num_buckets=64) at /usr/local/include/sparsehash/internal/densehashtable.h:777
#40x0000000000428401 in google::dense_hashtable<std::pair<unsigned int const, float>, unsigned int, std::tr1::hash<unsigned int>, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SelectKey, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::copy_from (this=0x7ffe3b08e220, ht=..., min_buckets_wanted=4) at /usr/local/include/sparsehash/internal/densehashtable.h:638
#50x000000000042ae56 in google::dense_hashtable<std::pair<unsigned int const, float>, unsigned int, std::tr1::hash<unsigned int>, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SelectKey, google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::SetKey, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::operator= (this=0x7ffe3b08e220, ht=...) at /usr/local/include/sparsehash/internal/densehashtable.h:744
#60x000000000042abcf in google::dense_hash_map<unsigned int, float, std::tr1::hash<unsigned int>, std::equal_to<unsigned int>, google::libc_allocator_with_realloc<std::pair<unsigned int const, float> > >::operator= (this=0x7ffe3b08e220) at /usr/local/include/sparsehash/dense_hash_map:113



求解,提前谢过
页: [1]
查看完整版本: dense_hash_map 段错误求解