An experience of fixing a memory-corruption bug (1)
来源:互联网 发布:手机网络电视 安卓 编辑:程序博客网 时间:2024/04/28 17:23
During the last 4 months, I was disturbed by a memory-corruption bug, and this bug will cause program crash. Until last Monday, I found the root cause and fixed it. This debug process is a difficult but memorable experience, so I will share it in this article.
My program works as a SMS Hub. When it receives a SMS, it will allocate a structure in heap memory like this:
After processing the SMS, the program will free the memory, and send the SMS to the next Hub or Operator.
Since last November, the program will crash sometimes, and the cause is the second element in array a (a[1]) will be changed from a valid value to NULL.
(1) Checking the logs and reproduced the bug
Firstly, I checked the commercial logs, but there were no clues can be found. And the SMS which killed program also seemed no different than others. I also tried to use this SMS to reproduce the bug in testbed, but also failed.
(2) Using libumem
Because our program runs in Solaris, I linked the libumem and hoped it can help me. After a few days, the program crashed again. But the tags before and after the corrupted memory are all OK, so it is not a memory off-bound bug. I also checked the memory before and after the corrupted memory, but nothing valuable can be found.
(3) Adding more logs
Until then, the only thing I can think is adding more logs. After adding enough logs, I found the variable is modified between functions in the same thread: when leaving the last function, the variable is OK, but entering the next function, the variable is changed. So I can make sure the variable is destroyed by another thread. But how can I find the murderer?
- An experience of fixing a memory-corruption bug (1)
- An experience of fixing a memory-corruption bug (2)
- An experience of fixing a memory-corruption bug (3)
- 实习@ms——procedure of fixing a bug 2010-11-15 11:55
- Change Log for Bug-Fixing of Joomsport
- An Experience of Windows server 8
- memory corruption
- memory corruption
- Fixing the Java Memory Model, Part 1
- Experience of writing a network framework
- An Analysis of Data Corruption in the Storage Stack
- 使用libumem定位memory leak和memory corruption(1)
- This may be due to a corruption of the heap, which indicates a bug in *.exe or any of the DLLs it has loaded.
- this may be due to a corruption of the heap, which indicates a bug in ... or any of the DLLs it has
- Caffe bug fixing List
- windbg memory corruption
- Android memory corruption debugger
- Experience of Study Introduction to Algorithm(1)
- 人均月收入两千就比70%的人富了
- 第二章 Java语言基础笔记
- http协议与SMTP协议的区别?
- socket原理讲解
- Spring+iBatis多数据源的动态配置方案
- An experience of fixing a memory-corruption bug (1)
- 学习make(六)
- 常量与变量
- 谁以微笑,淡了流年
- win7系统组件中无法安装IIS和FTP服务的解决办法
- Ubuntu 12.04 wpa/wpa2无线上网手动配置
- UML常用图例详解
- 第三周项目三-时间类
- 匿名内部类笔记