Heap corruption: What could the cause be?

后端 未结 13 1548
时光取名叫无心
时光取名叫无心 2020-12-25 12:56

I am investigating a crash due to heap corruption. As this issue is non-trivial and involves analyzing the stack and dump results, I have decided to do a code review of file

13条回答
  •  抹茶落季
    2020-12-25 13:39

    Welcome to hell. There is no easy solution so I will only provide some pointers.

    Try to reproduce the bug in a debug environement. Debuggers can pad your heap allocations with bound checks and will tell you if you wrote in those bound checks. Also, it will consistently allocate memory using the same virtual addresses, making reproductibility easier.

    In that case, you can try an analyser tool such as Purify. They will detect pretty much anything nasty that your code is doing but will also run VERY slowly. Such a tool will detect out of bound memory access, freed memory access, trying to free twice the same block, using the wrong allocator/deallocators, etc... Those are all kind of conditions that can stay latent for very long and only crash at the most inopportune moment.

提交回复
热议问题