Chinaunix

标题: 求高手解决list remove崩溃问题 [打印本页]

作者: zhangruichao88    时间: 2015-03-18 15:44
标题: 求高手解决list remove崩溃问题
今天循坏跑程序,出现这个错误,求高手解答错误是怎么引起的?


Core was generated by `./audit'.
Program terminated with signal 11, Segmentation fault.
#0  0x08053437 in std::list<Thread*, std::allocator<Thread*> >::remove (this=0x82ff0c0, __value=@0xb2540394)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/list.tcc:182
182                  if (*__first == __value)
(gdb) bt
#0  0x08053437 in std::list<Thread*, std::allocator<Thread*> >::remove (this=0x82ff0c0, __value=@0xb2540394)
    at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/list.tcc:182
#1  0x080532ed in ThreadPool::RemoveThread (this=0x82ff008, thread=0x83023a0) at threadpool.cpp:307
#2  0x080533b9 in ThreadPool::WapperFun (arg=0x83023a0) at threadpool.cpp:239
#3  0x006fb2db in start_thread () from /lib/libpthread.so.0
#4  0x0065514e in clone () from /lib/libc.so.6
Current language:  auto; currently c++
作者: hellioncu    时间: 2015-03-18 16:05
就给这点信息让猜原因么?我猜线程安全问题
作者: zhangruichao88    时间: 2015-03-18 16:14
回复 2# hellioncu

求高手解答,出现这种错误,直接原因,是因为list 里指针改变了吗


   
作者: hellioncu    时间: 2015-03-18 16:24
zhangruichao88 发表于 2015-03-18 16:14
回复 2# hellioncu

求高手解答,出现这种错误,直接原因,是因为list 里指针改变了吗


你这个错就是指针失效了,指向无效的内存地址,还去访问就错了
作者: littledick    时间: 2015-03-18 17:58
我猜是哪个成员变量保存了迭代器地址,之后其他函数调用变动过迭代器没有通知修改变量,然后把失效的迭代器拿来操作。
作者: sundae333    时间: 2015-03-19 12:11
迭代器失效吧  我之前也出现这种原因 是因为多线程操作同一个list 锁没有加好导致的




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2