An experience of fixing a memory-corruption bug (2)

(4) Asking for help from other geeks

I began to ask for help from other geeks. I put this question on the stackoverflow: How to debug the memory is changed randomly issue, and received a very good and comprehensive answer. I recommended every one should read this post. I also sent emails to other geeks, most of them replied and gave some suggestions, such as exchange some variables definition sequences, etc. I also wanted to get the root cause from the core dump file directly: Can I know which thread change the global variable's value from core dump file?, but at the end, I am failed.

Until one day, I found anarticle (Aha, written in Chinese!)by accident, this article describes the bug is very similar to mine except his programming language is C++ and mine is C. I began to follow the steps he provided to find the root cause.


(5) Porting the program on Linux and use valgrind

I wanted to use valgrind to help find the bug, but my program runs on Solaris, and valgrind can't be used on Solaris, so another colleague helped to ported it on Linux. After running valgrind, I did find some memory-related bugs, but these bugs can't explain the cause of this issue. I still can't find the root cause.


(6) Using electric-fence

I tried to use electric-fence, but thehome page of electric-fence was closed. I found some packages and source codes from the internet, and tried to integrated them into my program. But this time, I also failed.  


你可能感兴趣的:(c,debug,System)