0
点赞
收藏
分享

微信扫一扫

C++ tcmalloc::SLL_Next segmentation fault

八怪不姓丑 2022-11-01 阅读 97


显示调用栈不是出错的代码点,怀疑是内存错误。

Program terminated with signal S, Segmentation fault.
#0 0x00000000010ca227 in tcmalloc::SLL_Next(void*) ()
(gdb) bt
#0 0x00000000010ca227 in tcmalloc::SLL_Next(void*) ()
#1 0x00000000010ca2b8 in tcmalloc::SLL_TryPop(void**, void**) ()
#2 0x00000000010ca715 in tcmalloc::ThreadCache::FreeList::TryPop(void**) ()
#3 0x00000000011ebe6c in tc_newarray ()

C++ tcmalloc::SLL_Next segmentation fault_ios

C++ tcmalloc::SLL_Next segmentation fault_ios_02

 

这篇文章遇到相同的报错,原因是double free

​​查找内存错误 - 金庆的专栏 - C++博客

C++ tcmalloc::SLL_Next segmentation fault_ios_03

http://www.cppblog.com/jinq0123/archive/2019/12/16/217028.html​​ 

我遇到的原因是,使用了一个map,使用clear清空,多次之后,map的空间便没有释放,所以得使用swap清空

#include <iostream>
#include <map>
#include <malloc.h>
using namespace std;
void func()
{
map<int,string> mp;
int i = 5000000;
while(i--)
mp.insert(make_pair(i,string("hell000o")));
map<int,string>().swap(mp);
}
int main()
{
func();
cout <<"done."<<endl;
malloc_trim(0);
while(1);
}



举报

相关推荐

0 条评论