解决dnu restore时的“Cannot handle address family”问题

前几天在使用基于 mono 的 dnx 中的 dnu restore 命令安装 nuget 包包时,遇到了 “Cannot handle address family” 错误,错误详情如下:

Cannot handle address family 61712
Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) System.Net.Dns.GetHostByName_internal (string,string&,string[]&,string[]&) <0xffffffff>
  at System.Net.Dns.GetHostByName (string) <0x00054>
  at System.Net.ServicePoint.get_HostEntry () <0x00219>
  at System.Net.WebConnection.Connect (System.Net.HttpWebRequest) <0x001d4>
  at System.Net.WebConnection.InitConnection (object) <0x002ea>
  at System.Net.WebConnection.<WebConnection>m__0 (object) <0x00024>
  at System.Runtime.Remoting.Messaging.AsyncResult.WaitCallback_Context (object) <0x00058>
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) <0x001c6>
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) <0x00020>
  at System.Runtime.Remoting.Messaging.AsyncResult.<AsyncResult>m__0 (object) <0x00022>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

	mono() [0x4a1ce8]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7f96c8e7e340]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x39) [0x7f96c8adfcc9]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x148) [0x7f96c8ae30d8]
	mono() [0x6318c6]
	mono() [0x6316b3]
	mono() [0x631769]
	mono() [0x62b0b5]
	mono() [0x57a5e6]
	[0x40bb793e]

Debug info from gdb:


=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

在 github 上提交 issue 之后,从回复中得知这是 mono 的一个 bug,有人已经向 mono 提交了这个 bug ,详见 Use "Dns.GetHostEntry" or "Dns.GetHostByName",sometime throw error "Cannot handle address family xxxxx" 。

当时错误一直存在,怎么也无法完成 dnu restore 。后来,过了一段时间再操作,突然就好了。

后来,遇到了好几次这个问题,都是出现错误后,过一段时间就好了。

今天再次遇到,突然想到,是不是 dns 缓存的原因,清一下 dns 缓存试试。

service nscd restart

重启 nscd 之后,错误立马消失。

为了进一步确认真的是这个原因,后来找到了一个方法重现问题 —— 删除 ~/.dnx/packages 文件夹,然后重新编译 dnx 。

在 dnx 编译过程中 dnu restore 时,多次出现“Cannot handle address family”的问题,每次都能通过 service nscd restart 解决。

posted @ 2015-06-30 16:34  dudu  阅读(1188)  评论(0编辑  收藏  举报