在Xamarin.iOS应用程序中查找SIGSEGV的原因

时间:2013-07-31 08:27:23

标签: debugging xamarin.ios xamarin

我正在使用Xamarin.IOS开发我的第一个真正的应用程序。大多数时候,应用程序运行良好,但每天几次崩溃与下面的堆栈跟踪:

mono-rt: Stacktrace:
mono-rt:   at <unknown> <0xffffffff>
mono-rt:   at (wrapper managed-to-native) MonoTouch.Foundation.NSObject.monotouch_release_managed_ref (intptr) <IL 0x00023, 0xffffffff>
mono-rt:   at MonoTouch.Foundation.NSObject.ReleaseManagedRef () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:98
mono-rt:   at MonoTouch.Foundation.NSObject/NSObject_Disposer.Drain (MonoTouch.Foundation.NSObject) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSObject2.cs:545
mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
mono-rt:   at <unknown> <0xffffffff>
mono-rt:   at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
mono-rt:   at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
mono-rt:   at Diet52App.Application.Main (string[]) [0x00008] in /Users/danielnordmark/Projects/Diet52App/Diet52App/Main.cs:16
mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

mono-rt: 
Native stacktrace:


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

我的猜测是,在我尝试使用它之前,某些对象会被垃圾收集。但是我觉得有点失落如何找出我的代码中发生的时间和地点。

我怎样才能找出问题所在?非常感谢任何帮助!

1 个答案:

答案 0 :(得分:4)

问题似乎与我的UITableViewController有关,我有一个基类和两个不同的实例。这两者之间的冲突导致了SIGSEGV错误。

由于这个答案https://stackoverflow.com/a/6769885/248905

,我设法跟踪了问题

我必须做的唯一修改是用这样的InvokeOnMainThread包装代码,

<强>更新 我在Xamarin与Rolf联系后更新了我的解决方案,正确的解决方法是将代码放在ViewDidDissapear而不是Dispose。

public override void ViewDidDisappear (bool animated)
{
    searchController.SearchResultsSource = null;
    searchController.Delegate = null;
    base.ViewDidDisappear (animated);
}