当前位置:网站首页>Code debugging core step memory
Code debugging core step memory
2022-07-07 02:41:00 【Handsome drop point C】
Location method :
- gdb:
- adopt gdb For memory break points (watch) , See who illegally accessed the memory area . Then gradually narrow the scope . Until the corresponding function segment is found , such as :
- For example, discovery 0x800 The address is trampled .
- First, judge whether the address is legal , That is to say 0x800 Whether it should exist , If it should not exist , Then you can watch This address , You can also keep the code running , During this period, the address is continuously printed , See which code has been modified .
- For example, discovery 0x800 The address is trampled .
- limited
- The problem occurs in the startup phase , There is no time to set a breakpoint , Bad positioning ,
- Some systems do not support gdb
- Trampled address is not fixed
- adopt gdb For memory break points (watch) , See who illegally accessed the memory area . Then gradually narrow the scope . Until the corresponding function segment is found , such as :
- Problems like memory leaks , Predetermination , Post positioning , Through memory proc Information (meminfo/media-mem) Judgment is a specific module , Memory segment . It can also be used. MMU(linux You can use mrotect) Protect specific areas
- limited
- MMU The smallest unit of protection is a memory page , The area that may be trampled is small , No use mmu To protect
- limited
- Subtraction reduces the range , Clipping module , Modify the application , Find the smallest scene
- Add print , Print out the abnormal and suspicious address ; It's fine too dump Output the data of the trampled address , View data characteristics , Analyze where it comes from according to data characteristics .
- valgrind+effence+ksan Tools such as
Common questions
- Type conversion error
- For example, small to large , Including common char and int, And custom structures
- Including formal parameters
- Use the address that has been released
- such as malloc Or use without applying for control
- The requested memory is too small , Not enough use , Similar and cross-border
How to avoid
- Function nesting should not be too deep
- Code should be symmetrical ,malloc The corresponding position must be released
- Pay attention to the size of the array
边栏推荐
- [node learning notes] the chokidar module realizes file monitoring
- 电气工程及其自动化
- The cities research center of New York University recruits master of science and postdoctoral students
- 本周 火火火火 的开源项目!
- Unity custom webgl packaging template
- C#/VB.NET 删除Word文档中的水印
- Remember the problem analysis of oom caused by a Jap query
- Lombok makes the pit of ⽤ @data and @builder at the same time
- C # / vb. Net supprime le filigrane d'un document word
- MySQL
猜你喜欢
进程管理基础
哈希表及完整注释
Lombok makes the pit of ⽤ @data and @builder at the same time
Apifox,你的API接口文档卷成这样了吗?
What management points should be paid attention to when implementing MES management system
Douban average 9 x. Five God books in the distributed field!
Unity custom webgl packaging template
wireshark安装
This week's hot open source project!
用全连接+softmax对图片的feature进行分类
随机推荐
MetaForce原力元宇宙佛萨奇2.0智能合约系统开发(源码部署)
MMDetection3D加载毫米波雷达数据
[server data recovery] data recovery case of a Dell server crash caused by raid damage
What management points should be paid attention to when implementing MES management system
Five reasons for clothing enterprises to deploy MES management system
【森城市】GIS数据漫谈(二)
Have fun | latest progress of "spacecraft program" activities
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?
AWS学习笔记(一)
真实项目,用微信小程序开门编码实现(完结)
Niuke programming problem -- double pointer of 101 must be brushed
MySQL
代码调试core-踩内存
[leetcode]Search for a Range
【Node学习笔记】chokidar模块实现文件监听
PostgreSQL图形化界面工具之pgAdmin4
Overall query process of PostgreSQL
[leetcode]Search for a Range
Web3的先锋兵:虚拟人
CSDN summer camp course project analysis