免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1208 | 回复: 0
打印 上一主题 下一主题

[C++] dense_hash_map 段错误求解 [复制链接]

论坛徽章:
5
戌狗
日期:2014-06-09 10:29:10酉鸡
日期:2014-12-01 16:05:27处女座
日期:2015-01-07 18:35:262015亚冠之水原三星
日期:2015-06-03 09:26:222015亚冠之布里斯班狮吼
日期:2015-06-15 10:53:54
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-09-20 12:13 |只看该作者 |倒序浏览
尝试使用dense_hash_map,同一个函数加载其他文件数据没问题,加载另一份数据就段错误,相关代码片段如下:
  1.     dense_hash_map<uint64_t, dense_hash_map<uint32_t, float> > g_map;
  2.     g_map.set_empty_key(-99999);
  3.     while( 1 == fread(&id, sizeof(uint64_t), 1, fpr) )
  4.     {   
  5.         iRet = fread(&udwNum, sizeof(uint32_t), 1, fpr );
  6.         if(iRet != 1)  
  7.         {   
  8.             break;  
  9.         }   

  10.         dense_hash_map<uint32_t, float> tmp_map;
  11.         tmp_map.set_empty_key(-99999);
  12.         for(int j=0; j<udwNum; j++)
  13.         {   
  14.             iRet = fread(&info, sizeof(ID2SCORE), 1, fpr);
  15.             if(iRet != 1)  
  16.             {   
  17.                 break;  
  18.             }   
  19.             tmp_map[info.id] = tmp_map[info.score];
  20.         }   
  21.         g_map[id] = tmp_map;
  22.     }
复制代码
相关堆栈如下:
(gdb) bt
#0  0x0000003b05479252 in _int_malloc () from /lib64/libc.so.6
#1  0x0000003b0547a6b1 in malloc () from /lib64/libc.so.6
#2  0x0000000000426aa0 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
#3  0x000000000042895c 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
#4  0x0000000000428401 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
#5  0x000000000042ae56 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> > >:perator= (this=0x7ffe3b08e220, ht=...) at /usr/local/include/sparsehash/internal/densehashtable.h:744
#6  0x000000000042abcf 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> > >:perator= (this=0x7ffe3b08e220) at /usr/local/include/sparsehash/dense_hash_map:113



求解,提前谢过
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP