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

后端 未结 6 373
不知归路
不知归路 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 08:07

    Try to push your code into bad situations.

    If you're writing a parser, throw BMPs, JPGs, random text at it, and see what happens. If you're writing a RPC protocol server, overload it with plenty of concurrent requests, write garbage into it, disconnect the client in the middle of nowhere...

    Don't be subtle at first, throw whatever possible, but then try to trick your code.

提交回复
热议问题