什么是你的查找段错误的原因的方法? [英] What's your method for finding the cause of a segfault?

查看:270
本文介绍了什么是你的查找段错误的原因的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或者只是一般的调试,你喜欢如何去在code查找错误。特别是对于C / C ++,但一般所有的语言。我一直试图找到这个讨厌的段错误的原因,但我想找到它自己,而不是在网上张贴的挑战。你有一个学徒任何建议像我这样的?

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 this nasty segfault, but I'd like the challenge of finding it myself, not posting it online. Do you have any advice for a padawan such as myself?

推荐答案

尝试把你的code到坏的情况。

Try to push your code into bad situations.

如果你正在写一个解析器,扔骨形成蛋白,JPG格式,它随机文本,看看会发生什么。
如果你正在写一个RPC协议服务器,用大量的并发请求的超负荷,写垃圾进去,断开客户端中间的地方...

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...

不要微妙起初,抛出一切可能,但随后试图欺骗你的code。

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

这篇关于什么是你的查找段错误的原因的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆