What's your method for finding the cause of a segfault?

后端 未结 6 369
不知归路
不知归路 2021-01-14 07:51

Or just debugging in general, how do you like to go about finding bugs in code. Specifically for C/C++, but all languages in general. I\'ve been trying to find the cause of

6条回答
  •  走了就别回头了
    2021-01-14 07:55

    I usually run in the debugger... generally there are enough clues to go on to track it down... call stack, current state of variables, etc. If the stack is trashed or it's heap corruption, it can be more difficult. If I have a repeatable scenario, I'll run it in valgrind (Linux) which bounds-checks everything and can often pinpoint the issue.

提交回复
热议问题