moonshawdo / checkgoogleip

主要是用来检查哪些IP可以用在goagent上面
Apache License 2.0
584 stars 241 forks source link

Segmentation fault (core dumped) #1

Closed ghost closed 10 years ago

ghost commented 10 years ago

https://github.com/moonshawdo/checkgoogleip/commit/c179dd6299f8197720748c508c799c2006cf2669 后运行,开始connect一个ip段后出错:

segmentation falt (core dumped)

再次运行时出错:

[Thread-140]try connect to 1.179.249.147 
Exception in thread Thread-167:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "checkgoogleip-master/checkip.py", line 267, in run
    self.runJob()
  File "checkgoogleip-master/checkip.py", line 254, in runJob
    (ssldomain, costtime) = ssl_obj.getssldomain(self.getName(), ipaddr)
  File "checkgoogleip-master/checkip.py", line 168, in getssldomain
    c.do_handshake()
  File "/usr/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1076, in do_handshake
    self._raise_ssl_error(self._ssl, result)
  File "/usr/lib/python2.7/site-packages/OpenSSL/SSL.py", line 871, in _raise_ssl_error
    _raise_current_error()
  File "/usr/lib/python2.7/site-packages/OpenSSL/_util.py", line 22, in exception_from_error_queue
    raise exceptionType(errors)
Error: [('memory buffer routines', 'BUF_MEM_grow', 'malloc failure')]

[Thread-34]ip: 1.179.248.95,CN: *.googlevideo.com 
[Thread-278]ip: 1.179.248.81,CN: *.googlevideo.com 
[Thread-34]try connect to 1.179.249.148 
[Thread-278]try connect to 1.179.249.149 
[Thread-152]ip: 1.179.248.57,CN: *.googlevideo.com 
[Thread-152]try connect to 1.179.249.150 
Segmentation fault (core dumped)

调低到128条线程依然如此,是不是内存泄漏了? 本机系统archlinux,内存1G,support pyopenssl

第一版256x3条线程依然能正常运行完,注释掉超级多的connect和timeout提示后,我也注意到了某些ip段会出现eof的握手错误,不过估计是受gfw干扰所致。

ghost commented 10 years ago

第一版,我可能找到握手失败的原因了: _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 原因:http://stackoverflow.com/questions/10667960/python-requests-throwing-up-sslerror 解决:加入verify=False参数 _ssl.c:507: EOF occurred in violation of protocol 原因:http://code.google.com/p/goagent/issues/detail?id=12596 解决:挂vpn(估计就是被干扰了,其实这类ip无vpn不可用,可忽略掉)

ghost commented 10 years ago

这种错误就不知何解了:

SSL Exception(74.125.248.81): [Errno 1] _ssl.c:507: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure, times:2403 ms

是ssl版本问题吗?

moonshawdo commented 10 years ago

connect出错段错误的问题,可以试一下新版程序,不过只是简单设置了一下线程的stack大小。

sslv3 alert handshake failure

可能是ssl版本问题吧,暂时不清楚

gshmu commented 10 years ago

我想说你为什么不把ping放在前面,ping通过再握手啊。 ssl看着是比较高端,可是ping不通我就不信你握手能成功。

ghost commented 10 years ago

谢谢改进,cpu和内存占用大幅度降低,可引进新的问题: 测试两个ip段,共13万多个ip,线程已经调低到256个 1.出现大量类似 [Error 113] No route to host, times : 5 ms 错误,之前测试这两个ip段没有该错误,要差不多四个小时,找到200多个ip,现在只要十几分钟,只找到20几个,程序问题,还是我系统的route设置问题,还是路由器的限制呢? 2.运行期间,几乎无法打开网页,是线程太多,网络堵塞了吗?

补充:可能确定原因 重新运行加入队列前后版本,可以确定是出现网络堵塞问题,问题不在于队列,也不在于线程,而在于用了新的openssl,将

附本机openssl版本: $ pacman -Qs openssl local/openssl 1.0.1.g-1 The Open Source toolkit for Secure Sockets Layer and Transport Layer Security local/python2-pyopenssl 0.14-3 Python2 wrapper module around the OpenSSL library

ps:支持作者,github是自由的平台,某些人不喜欢作者的思路和做法,可以fork走自己开发。

On 6/7/14, moonshawdo notifications@github.com wrote:

connect出错段错误的问题,可以试一下新版程序,不过只是简单设置了一下线程的stack大小。

sslv3 alert handshake failure

可能是ssl版本问题吧,暂时不清楚


Reply to this email directly or view it on GitHub: https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45404548

moonshawdo commented 10 years ago

这个的话,当时这是这样想的,既然ping也是要去连接服务器再通讯的,因为我需要获取服务器证书,这时也需要去connect,因此就打算直接就用connect,当connect失败时,也可以间接说明ip不通

现在也发现一个问题,就是有一些ip是ping不能,但是可以连接服务器的443端口的。

例子: rtan@rtan-virtual-machine:~$ ping -w 5 218.253.0.86 PING 218.253.0.86 (218.253.0.86) 56(84) bytes of data. 218.253.0.86 ping statistics 5 packets transmitted, 0 received, 100% packet loss, time 4001ms

rtan@rtan-virtual-machine:~$ curl https://218.253.0.86 curl: (51) SSL: certificate subject name 'google.com' does not match target host name '218.253.0.86'

2014-06-07 19:23 GMT+08:00 gshmu notifications@github.com:

我想说你为什么不把ping放在前面,ping通过再握手啊。 ssl看着是比较高端,可是ping不同我就不信你握手能成功。

— Reply to this email directly or view it on GitHub https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45407701 .

moonshawdo commented 10 years ago

关于第一个问题,今天修改的cpu和内存使用情况,其实只是单纯地改了一下创建线程时的stack大小,如果出现这个错的话,可能是系统或路由器限制吧。我不知道你之前运行的版本是否已经是使用pyOpenSSL的版本了。 第二个问题的话,可能因为出现" No route to host, times : 5 ms",所以就有可能导致正常使用网络时也会出现问题吧。

不过因为我在测试中没有出现这两个问题,所以很难确定原因

另外:今天测试了一下13万多个ip的情况,发现查询比较快,可能是因为都要connect,然后大量的ip超时是7秒,所以就会导致程序运行很慢。

在 2014年6月7日 下午8:25,westmin notifications@github.com写道:

谢谢改进,cpu和内存占用大幅度降低,可引进新的问题: 测试两个ip段,共13万多个ip,线程已经调低到256个 1.出现大量类似 [Error 113] No route to host, times : 5 ms 错误,之前测试这两个ip段没有该错误,要差不多四个小时,找到200多个ip,现在只要十几分钟,只找到20几个,程序问题,还是我系统的route设置问题,还是路由器的限制呢?

2.运行期间,几乎无法打开网页,是线程太多,网络堵塞了吗?

补充:可能确定原因 重新运行加入队列前后版本,可以确定是出现网络堵塞问题,问题不在于队列,也不在于线程,而在于用了新的openssl,将

  • g_useOpenSSL = 1
  • g_useOpenSSL = 0 改为使用python内置openssl,变正常,可cpu依然高企,内存减半。

附本机openssl版本: $ pacman -Qs openssl local/openssl 1.0.1.g-1 The Open Source toolkit for Secure Sockets Layer and Transport Layer Security local/python2-pyopenssl 0.14-3 Python2 wrapper module around the OpenSSL library

ps:支持作者,github是自由的平台,某些人不喜欢作者的思路和做法,可以fork走自己开发。

On 6/7/14, moonshawdo notifications@github.com wrote:

connect出错段错误的问题,可以试一下新版程序,不过只是简单设置了一下线程的stack大小。

sslv3 alert handshake failure

可能是ssl版本问题吧,暂时不清楚


Reply to this email directly or view it on GitHub:

https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45404548

— Reply to this email directly or view it on GitHub https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45408779 .

ghost commented 10 years ago

1.出现Segmentation fault (core dumped) 错误是加入队列,而没有修改stack大小是出现的,修改后能运行。 2.出现[Error 113] No route to host, times : 5 ms 错误是在 https://github.com/moonshawdo/checkgoogleip/commit/4fd264de396f5d0a5c89450f5cc091cfb637bec2 之后,本机系统、路由和外置路由器都没有作更改。g_useOpenSSL改为0后也没有这个错误。

On 6/7/14, moonshawdo notifications@github.com wrote:

关于第一个问题,今天修改的cpu和内存使用情况,其实只是单纯地改了一下创建线程时的stack大小,如果出现这个错的话,可能是系统或路由器限制吧。我不知道你之前运行的版本是否已经是使用pyOpenSSL的版本了。 第二个问题的话,可能因为出现" No route to host, times : 5 ms",所以就有可能导致正常使用网络时也会出现问题吧。

不过因为我在测试中没有出现这两个问题,所以很难确定原因

另外:今天测试了一下13万多个ip的情况,发现查询比较快,可能是因为都要connect,然后大量的ip超时是7秒,所以就会导致程序运行很慢。

在 2014年6月7日 下午8:25,westmin notifications@github.com写道:

谢谢改进,cpu和内存占用大幅度降低,可引进新的问题: 测试两个ip段,共13万多个ip,线程已经调低到256个 1.出现大量类似 [Error 113] No route to host, times : 5 ms 错误,之前测试这两个ip段没有该错误,要差不多四个小时,找到200多个ip,现在只要十几分钟,只找到20几个,程序问题,还是我系统的route设置问题,还是路由器的限制呢?

2.运行期间,几乎无法打开网页,是线程太多,网络堵塞了吗?

补充:可能确定原因 重新运行加入队列前后版本,可以确定是出现网络堵塞问题,问题不在于队列,也不在于线程,而在于用了新的openssl,将

  • g_useOpenSSL = 1
  • g_useOpenSSL = 0 改为使用python内置openssl,变正常,可cpu依然高企,内存减半。

附本机openssl版本: $ pacman -Qs openssl local/openssl 1.0.1.g-1 The Open Source toolkit for Secure Sockets Layer and Transport Layer Security local/python2-pyopenssl 0.14-3 Python2 wrapper module around the OpenSSL library

ps:支持作者,github是自由的平台,某些人不喜欢作者的思路和做法,可以fork走自己开发。

On 6/7/14, moonshawdo notifications@github.com wrote:

connect出错段错误的问题,可以试一下新版程序,不过只是简单设置了一下线程的stack大小。

sslv3 alert handshake failure

可能是ssl版本问题吧,暂时不清楚


Reply to this email directly or view it on GitHub:

https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45404548

— Reply to this email directly or view it on GitHub https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45408779 .


Reply to this email directly or view it on GitHub: https://github.com/moonshawdo/checkgoogleip/issues/1#issuecomment-45409814