admin 管理员组文章数量: 887016
Linux下free释放内存死锁问题
#0 0x00007f6267789d2b in pthread_once () from /lib64/libpthread.so.0
#1 0x00007f626689ec54 in backtrace () from /lib64/libc.so.6
#2 0x00007f626681084b in __libc_message () from /lib64/libc.so.6
#3 0x00007f6266816166 in malloc_printerr () from /lib64/libc.so.6
#4 0x00007f6266819be4 in _int_malloc () from /lib64/libc.so.6
#5 0x00007f626681a626 in calloc () from /lib64/libc.so.6
#6 0x00007f62679a4d2f in _dl_new_object () from /lib64/ld-linux-x86-64.so.2
#7 0x00007f62679a11be in _dl_map_object_from_fd () from /lib64/ld-linux-x86-64.so.2
#8 0x00007f62679a237a in _dl_map_object () from /lib64/ld-linux-x86-64.so.2
#9 0x00007f62679aca44 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#10 0x00007f62679a81b6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#11 0x00007f62679ac4fa in _dl_open () from /lib64/ld-linux-x86-64.so.2
#12 0x00007f62668c6e10 in do_dlopen () from /lib64/libc.so.6
#13 0x00007f62679a81b6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#14 0x00007f62668c6f67 in __libc_dlopen_mode () from /lib64/libc.so.6
#15 0x00007f626689eb25 in init () from /lib64/libc.so.6
#16 0x00007f6267789d33 in pthread_once () from /lib64/libpthread.so.0
#17 0x00007f626689ec54 in backtrace () from /lib64/libc.so.6
#18 0x00007f626681084b in __libc_message () from /lib64/libc.so.6
#19 0x00007f6266816166 in malloc_printerr () from /lib64/libc.so.6
#20 0x00007f6266818c93 in _int_free () from /lib64/libc.so.6
#21 0x000000000046c6d6 in cpool_release_pool ()
我的内存池释放内存时最后会卡在pthread_once函数中出不来,用pstack命令查看如上堆栈信息。请各位大侠帮忙分析下。
代码没法贴,太多了。
这个问题太纠结了,总共出现过三次。都毫无头绪,如果是内存非法释放,越界,重复释放应该是挂掉的。
账号分不多了,只能放80
------解决思路----------------------
为什么只有一个线程的信息,楼主的程序是单线程的?
看楼主这个堆栈信息怎么好像是有很多递归调用,在释放内存的后面(_int_free)还有申请内存(_int_malloc)
这个内存池是自己写的吧
------解决思路----------------------
引用:#0 0x00007f6267789d2b in pthread_once () from /lib64/libpthread.so.0
#1 0x00007f626689ec54 in backtrace () from /lib64/libc.so.6
#2 0x00007f626681084b in __libc_message () from /lib64/libc.so.6
#3 0x00007f6266816166 in malloc_printerr () from /lib64/libc.so.6
#4 0x00007f6266819be4 in _int_malloc () from /lib64/libc.so.6
#5 0x00007f626681a626 in calloc () from /lib64/libc.so.6
#6 0x00007f62679a4d2f in _dl_new_object () from /lib64/ld-linux-x86-64.so.2
#7 0x00007f62679a11be in _dl_map_object_from_fd () from /lib64/ld-linux-x86-64.so.2
#8 0x00007f62679a237a in _dl_map_object () from /lib64/ld-linux-x86-64.so.2
#9 0x00007f62679aca44 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
#10 0x00007f62679a81b6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#11 0x00007f62679ac4fa in _dl_open () from /lib64/ld-linux-x86-64.so.2
#12 0x00007f62668c6e10 in do_dlopen () from /lib64/libc.so.6
#13 0x00007f62679a81b6 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
#14 0x00007f62668c6f67 in __libc_dlopen_mode () from /lib64/libc.so.6
#15 0x00007f626689eb25 in init () from /lib64/libc.so.6
#16 0x00007f6267789d33 in pthread_once () from /lib64/libpthread.so.0
#17 0x00007f626689ec54 in backtrace () from /lib64/libc.so.6
#18 0x00007f626681084b in __libc_message () from /lib64/libc.so.6
#19 0x00007f6266816166 in malloc_printerr () from /lib64/libc.so.6
#20 0x00007f6266818c93 in _int_free () from /lib64/libc.so.6
#21 0x000000000046c6d6 in cpool_release_pool ()
我的内存池释放内存时最后会卡在pthread_once函数中出不来,用pstack命令查看如上堆栈信息。请各位大侠帮忙分析下。
代码没法贴,太多了。
这个问题太纠结了,总共出现过三次。都毫无头绪,如果是内存非法释放,越界,重复释放应该是挂掉的。
账号分不多了,只能放80
看看你free的指针是不是你malloc的指针。
------解决思路----------------------
仅供参考//将c:\\tmp文件夹下的所有文件的内容全部放到用malloc分配的内存中
#include
#include
#include
#include
struct FB {
char fn[256];
size_t fl;
char *b;
struct FB *next;
struct FB *prev;
} *fh,*fb,*ft;
char ln[256];
char fpn[256];
FILE *af;
FILE *f;
int L,n;
int main() {
system("dir /b /a-d c:\\tmp\\*.* >c:\\allfn.txt");
af=fopen("c:\\allfn.txt","r");
if (NULL==af) {
printf("Can not open file c:\\allfn.txt!\n");
return 1;
}
fh=NULL;
fb=NULL;
n=0;
while (1) { </
版权声明:本文标题:Linux线程释放 内存没释放,Linux下free释放内存死锁有关问题 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1729867349h1363209.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论