*** glibc detected ***
来源:互联网 发布:玻璃砖知乎 编辑:程序博客网 时间:2024/06/05 21:17
* glibc detected *
其实看到上述字眼大家都很烦,我也很烦,今天闲着没事,写写Bug,混个眼熟,下回见面可以打个招呼把它送走~
extern void *realloc(void *mem_address, unsigned int newsize);
先判断当前的指针是否有足够的连续空间,如果有,扩大mem_address指向的地址,并且将mem_address返回,如果空间不够,先按照 newsize指定的大小分配空间,将原有数据从头到尾拷贝到新分配的内存区域,而后释放原来mem_address所指内存区域,同时返回新分配的内存 区域的首地址。即重新分配存储器块的地址。
1.double free
这说的是一个地址被free了两次,很容易查出来。
代码:
int a = (int)malloc(sizeof(int)*1);
free(a);
free(a);//这里就报错了
- invalid pointer
这里是说,a+1不是连续地址的头部。
* glibc detected ./main_test-g: realloc(): invalid pointer: 0x09e30fb4 **
int a = (int)malloc(sizeof(int)*4);
a = (int*)realloc(a+1,sizeof(int)*2);
同样,我在后面加一句
free(a+1);
他就会报错如下:
* glibc detected ./main_test-g: free(): invalid pointer: 0x09fc8fb4 **
在往下进行之前,我们先来一段小插曲。
int a = (int)malloc(sizeof(int*)*1);
int b = (int)malloc(sizeof(int*)*1);
cout<
int *a = (int*)malloc(sizeof(int*)*4);a[5] = 1;cout<<&a[5]<<endl;int *b = (int*)malloc(sizeof(int*)*4);*** glibc detected *** ./main_test-g: realloc(): invalid next size: 0x086b5fb0 ***int *a = (int*)malloc(sizeof(int*)*4);a[5] = 1;cout<<&a[5]<<endl;a = (int*)realloc(a,sizeof(int*)*10);
0 0
- glibc detected
- glibc detected
- *** glibc detected ***
- .glibc detected ERROR
- *** glibc detected *** double free ....
- *** glibc detected *** double free ....
- *** glibc detected *** double free ....
- *** glibc detected *** free(): invalid pointer: *** glibc detected *** malloc(): memory corruption:
- *** glibc detected *** malloc(): memory corruption
- NS2之 glibc detected 事出有因
- *** glibc detected *** malloc(): memory corruption
- *** glibc detected *** malloc(): memory corruption
- *** glibc detected *** free(): invalid pointer:解决方法
- 内存泄露之 glibc detected错误
- *** glibc detected *** double free or corruption (out) ***
- “glibc detected”, free(), invalid pointer解决方法
- g++ 编译出现glibc detected 错误
- *** glibc detected *** double free or corruption (fasttop)
- 大数阶乘
- 1123: 【C语言训练】列出最简真分数序列*
- 深入理解java异常处理机制
- hdu 5656 CA Loves GCD(dp+gcd)(Bestcoder #78 1002)
- Markdown格式小计
- *** glibc detected ***
- leetcode 236. Lowest Common Ancestor of a Binary Tree
- Java上传文件到MongoDB GirdFS
- 解读为毛我的iPhone5老是升级不了iOS9.3新系统
- JS调用微信API实现微信支付
- 最全最强解析:支付宝钱包系统架构内部剖析(架构图)
- Dijkstra最短路径算法
- IAP15L2K61S2仿真出错的原因和解决办法
- java IO 之文件的复制