在NSArray绑定中偶尔出现SIGSEGV

时间:2013-04-11 19:50:17

标签: objective-c xamarin.ios monodevelop xamarin

我有以下属性我绑定:

@property (nonatomic, readwrite, retain) NSArray* activeTasks;

我使用以下代码绑定:

[Export("activeTasks", ArgumentSemantic.Retain)]
NSDictionary[] ActiveTasks { get; } 

我经常使用这个属性。然而,每访问一次,我就会在get_activeTasks上获得一个SIGSEGV(选择器的绑定)。我想知道我做错了什么以及为什么这种情况很少发生而不是系统地发生。

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend (intptr,intptr) <IL 0x00024, 0xffffffff>
  at MonoTouch.Foundation.NSObject.InitializeObject (bool) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:136
  at MonoTouch.Foundation.NSObject..ctor (intptr,bool) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:62
  at MonoTouch.Foundation.NSObject..ctor (intptr) <IL 0x00003, 0x0002b>
  at MonoTouch.Foundation.NSDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at MonoTouch.Foundation.NSMutableDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___intptr (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x00030, 0xffffffff>
  at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00109] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:536
  at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:551
  at System.Activator.CreateInstance (System.Type,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[]) [0x00174] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:299
  at System.Activator.CreateInstance (System.Type,object[],object[]) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234
  at System.Activator.CreateInstance (System.Type,object[]) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (intptr,intptr) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:210
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (intptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:259
  at MonoTouch.Foundation.NSArray.ArrayFromHandle<T> (intptr) [0x0003a] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:172
  at TouchDBBinding.CouchServer.get_ActiveTasks () <IL 0x0001b, 0x00073>

编辑:

以下是使用新框架的更新堆栈跟踪,我不知道它是否可以提供更多帮助:

堆栈跟踪:

 at (wrapper managed-to-native) MonoTouch.Foundation.NSObject.monotouch_create_managed_ref (intptr,intptr,bool) <IL 0x0002d, 0xffffffff>
  at MonoTouch.Foundation.NSObject.CreateManagedRef (bool) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:93
  at MonoTouch.Foundation.NSObject.InitializeObject (bool) [0x000cc] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:88
  at MonoTouch.Foundation.NSObject..ctor (intptr,bool) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSObject2.cs:85
  at MonoTouch.Foundation.NSObject..ctor (intptr) <IL 0x00003, 0x0002b>
  at MonoTouch.Foundation.NSDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at MonoTouch.Foundation.NSMutableDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___intptr (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x00030, 0xffffffff>
  at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00109] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:530
  at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:545
  at System.Reflection.ConstructorInfo.Invoke (object[]) [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (intptr,intptr) [0x00051] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:269
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (intptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:328
  at MonoTouch.Foundation.NSArray.ArrayFromHandle<T> (intptr) [0x00044] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:188
  at TouchDBBinding.CouchServer.get_ActiveTasks () <IL 0x0001b, 0x00073>

当带有retain的NSArray *绑定到NSDictionary []并且该属性为null时,MonoTouch的内部工作中是否有可能出现问题?或者它可能是因为它有空内容?

谢谢, 保罗

1 个答案:

答案 0 :(得分:1)

堆栈跟踪指示当MonoTouch尝试保留NSArray的其中一个元素时发生崩溃。

一个可能的原因是特定元素已被释放(或以其他方式被破坏)。特别是它不是因为元素为null(这种情况的处理方式不同)。