[英]Segmentation Fault in a multi-threaded server
I have been developing a multi-threaded server (using Pthreads) for a network for about 2 months now, under Linux (Ubuntu 11.04 64-bit kernel 2.6.38). 在Linux(Ubuntu 11.04 64位内核2.6.38)下,我已经为网络开发了多线程服务器(使用Pthreads)大约2个月了。
The code is about 7000 lines of C
at the moment. 目前,该代码约为7000行
C
I have been using it in the network where multiple clients connect to it and get served. 我已经在多个客户端连接到它并得到服务的网络中使用它。 It has been running quite smoothly.
运行一直很顺利。
Suddenly I am facing a bit of strange problem. 突然我遇到了一个奇怪的问题。 Every now and then (about 1 out of 10 times) the server crashes due to segmentation fault.
由于分段错误,服务器偶尔会崩溃(大约十分之一)。 I have looked all over the code but can not seem to find the actual reason behind this.
我遍历了所有代码,但似乎找不到背后的实际原因。 Can anyone guide me on this as to what may be going wrong here or what things I should try to find the actual bug?
谁能在这方面指导我有关这里可能出什么问题或者我应该尝试查找实际错误的哪些事情?
100% coverage isn't realistic, but 85%-95% can reasonably happen with diligence. 100%的覆盖率是不现实的,但是尽职调查可以合理地达到85%-95%。
About why weird errors happen: http://stromberg.dnsalias.org/~strombrg/checking-early.html 关于为什么会发生奇怪的错误: http : //stromberg.dnsalias.org/~strombrg/checking-early.html
You said this started happening suddenly. 您说这开始突然发生。 Hopefully you've been using a source code control system like Mercurial or Git or SVN.
希望您一直在使用诸如Mercurial或Git或SVN之类的源代码控制系统。 If you have (or perhaps you have nightly backups?), you probably should look back at the changes made at about the time the problems started, trying to find the error, which is likely an undefined memory reference.
如果有(或者您是否有每晚备份?),则可能应该回顾一下问题开始时所做的更改,以尝试查找错误,这很可能是未定义的内存引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.