Fixing Segmentation faults in C++

前端 未结 6 1833
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 09:44

I am writing a cross-platform C++ program for Windows and Unix. On the Window side, the code will compile and execute no problem. On the Unix side, it will compile however w

6条回答
  •  鱼传尺愫
    2020-11-27 10:47

    On Unix you can use valgrind to find issues. It's free and powerful. If you'd rather do it yourself you can overload the new and delete operators to set up a configuration where you have 1 byte with 0xDEADBEEF before and after each new object. Then track what happens at each iteration. This can fail to catch everything (you aren't guaranteed to even touch those bytes) but it has worked for me in the past on a Windows platform.

提交回复
热议问题