当前位置:网站首页>C: free(): 无效指针中止(核心转储)的思考
C: free(): 无效指针中止(核心转储)的思考
2022-07-15 23:18:00 【雾_里】
目录
在运行程序的时候,报错(如图):

free(): invalid pointer Aborted
使用valgrind筛查错误
valgrind使用方法及其命令在另一篇博客:http://t.csdn.cn/tAsfN
读取到以下信息:

部分错误出现及其解决方法
Use of uninitialised value of size 4
//使用了未初始化的的地址, 这时候应该查看一下程序是否使用了未初始化的指针
Address 0x0 is not stack’d, malloc’d or (recently) free’d
//这个错误原因是往错误的地址写入值, 这时候我们也应该查看一下程序用未初始化的指针赋值, 或者指针未被赋值. Conditional jump or move depends on uninitialised value(s)
//这个错误原因是使用的变量未被初始化Invalid free() / delete / delete[] / realloc()
//这个错误原因是free掉了不属于自己的空间, 错误原因有可能是指针指向的内存不再属于它了
HEAP SUMMARY:
in use at exit: 412 bytes in 1 blocks
total heap usage: 2 allocs, 1 frees, 924 bytes allocated
//最后一个是堆内存分析, 如上面的提示所示, 程序在退出时, 仍有412字节的空间未被free
但是我的程序中并没有使用malloc分配内存,那么我接着筛查错误原因:
可能是缺少libtcmalloc-minimal4库
sudo apt-get install libtcmalloc-minimal4 //安装vim ~/.bashrc //修改配置文件export LD_PRELOAD="/usr/lib/libtcmalloc_minimal.so.4" //在配置文件里添加库路径source ~/.bashrc //执行配置文件
查看文件路径:ldconfig -p |grep libtcmalloc_minimal.so.4
边栏推荐
- JVM 问题定位工具
- 第17章 OAuth2LoginAuthenticationWebFilter 源码解析
- Transport layer ----- UDP
- [MySQL must know and know] conditional statement
- Ethernet development and testing, have you done this step right (3)
- JUST k
- 【MySQL必知必会】条件语句
- Application of singleton mode
- If you want to learn hardware, what should you learn?
- Experiment 1 basic image transformation
猜你喜欢

Chapter 3 business function development (import market activities, Apache POI)

Experiment 4 image restoration and geometric correction

The best time to buy and sell stocks
![class path resource [xxx.properties] cannot be opened because it does not exist](/img/e3/5e5a568dbf2fcceae8b2d4a7249763.png)
class path resource [xxx.properties] cannot be opened because it does not exist

npm ERR! cb() never called 处理办法

Do you want to be an engineer or a product manager?

Original error was: DLL load failed while importing _ multiarray_ Umath: the specified module cannot be found

基于51单片机的花样流水灯设计

Application of generator mode

实验五 图像分割与描述
随机推荐
[MySQL must know and know] conditional statement
架构师进阶,微服务设计与治理的 16 条常用原则
codeforces每日5题(均1500)-第十六天
卢卡斯定理
P1088 [noip2004 popularity group question 4] Martians ← next_ permutation
Reinforcement learning (I)
MGRE及GRE综合实验
基于Fitnesse的验收测试实验
Super easy to use screenshot software snipaste (including installation package), how to set snipaste to start automatically
The Institute of standardization issued the requirements for cloud migration related capabilities, and Wanbo Intelligent Cloud participated in the requirements and white paper preparation
可落地的DDD(7)-战术设计上的一些误区
【vulnhub】FIVE86: 1
超声波测距OLED显示
Fastadmin custom drag sort
Repent of greed stonk
漫谈软件缺陷管理的价值
Question v: hannnnah_ j’s Biological Test
Buckle exercise - and the shortest subarray of at least k
2022-07-15: there are 21 balls at the beginning. A and B take turns to take the ball. A first and B second. Everyone must take no more than 3 balls in their own round. In the end, whoever has an even
Written at the end of the recruitment of Huazhong University of science and technology