仅限设备上的EXC_BAD_ACCESS

时间:2015-10-26 18:32:30

标签: xcode swift2 exc-bad-access

所以在今天早上将xCode更新到版本7.1后,我的项目突然崩溃并抛出" EXC_BAD_ACCESS(CODE = 1)"任何时候我访问子模块中的对象的任何部分,但只有当我在iOS设备上构建时。在模拟器中,我无法重现这个问题。我已经检查了仪器中的僵尸物体,应用程序崩溃时没有在仪器中发出任何警告,就像发现僵尸时一样。我已经克隆了我的repo的新版本并重新添加了子模块,认为它可能与xCode本身有关,但问题仍然存在。我决定尝试访问appDelegate中的对象,即使在那里,我也得到相同的结果。这是最初提出问题的地方: enter image description here

正如您所看到的,绝对没有关于导致它的原因的信息。我向上移动堆栈跟踪,一切都在装配中。 Abstract User是子模块的一部分,但在上次更新之前从未提出任何问题。这是堆栈跟踪:

  • 线程#1:tid = 0x14d13,0x00000001011f5ad8 libswiftCore.dylib swift_initStructMetadata_UniversalStrategy + 56, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x91) frame #0: 0x00000001011f5ad8 libswiftCore.dylib swift_initStructMetadata_UniversalStrategy + 56 帧#1:0x0000000101162d14 libswiftCore.dylib ___lldb_unnamed_function201$$libswiftCore.dylib + 84 frame #2: 0x00000001011f712c libswiftCore.dylib(匿名命名空间):: GenericCacheEntry * llvm :: function_ref&lt;(匿名命名空间):: GenericCacheEntry *()&gt; :: callback_fn(long)+ 36 第3帧:0x00000001011f6fdc libswiftCore.dylib swift::MetadataCache<(anonymous namespace)::GenericCacheEntry>::addMetadataEntry(swift::EntryRef<(anonymous namespace)::GenericCacheEntry>, ConcurrentList<swift::MetadataCache<(anonymous namespace)::GenericCacheEntry>::EntryPair>&, llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>) + 156 frame #4: 0x00000001011f3c50 libswiftCore.dylib swift_getGenericMetadata + 416 帧#5:0x00000001011f3ccc libswiftCore.dylib swift_getGenericMetadata2 + 24 frame #6: 0x00000001010b1538 libswiftCore.dylib Swift._NativeDictionaryStorage.maybeGet(Swift._NativeDictionaryStorage)(A) - &gt; Swift.Optional + 76 第7帧:0x000000010109f4e8 libswiftCore.dylib Swift._VariantDictionaryStorage.maybeGet <A, B where A: Swift.Hashable> (Swift._VariantDictionaryStorage<A, B>)(A) -> Swift.Optional<B> + 92 frame #8: 0x000000010109f440 libswiftCore.dylib Swift.Dictionary.subscript.getter:(A) - &gt; Swift.Optional + 168 frame#9:0x0000000100e3d2ec ServiceKit ServiceKit.ServiceModel.init (dictionary=<unavailable>, self=<unavailable>)(dictionary : Swift.Dictionary<Swift.String, Swift.AnyObject>) -> ServiceKit.ServiceModel + 316 at ServiceModel.swift:88 frame #10: 0x0000000100e1e438 ServiceKit ServiceKit.AbstractUser.init(dictionary =,self =)(字典:Swift.Dictionary) - &gt; UserKwift上的ServiceKit.AbstractUser + 180:36 frame#11:0x0000000100e205fc ServiceKit ServiceKit.User.init (dictionary=<unavailable>, self=<unavailable>)(dictionary : Swift.Dictionary<Swift.String, Swift.AnyObject>) -> ServiceKit.User + 344 at User.swift:744 frame #12: 0x0000000100e26f48 ServiceKit ServiceKit.ConsumerUser.init(dictionary =,self =)(字典:Swift.Dictionary) - &gt; ServiceKw上的ServiceKit.ConsumerUser + 264:351 frame#13:0x0000000100e26e34 ServiceKit`ServiceKit.ConsumerUser .__ allocating_init(dictionary =,$ metatype =)(字典:Swift.Dictionary) - &gt; UserKwift上的ServiceKit.ConsumerUser + 88:0
    • 第14帧:0x000000010027910c Service.com Service_com.SignInViewController.signUserIn (sender=0x0000000158576b70, self=0x000000015865a760)(Service_com.MKButton) -> () + 1416 at SignInViewController.swift:62 frame #15: 0x0000000100279310 Service.com @ objc Service_com.SignInViewController.signUserIn(Service_com.SignInViewController)(Service_com.MKButton) - &gt; SignInViewController.swift上的()+ 68:0 帧#16:0x0000000189403cfc UIKit -[UIApplication sendAction:to:from:forEvent:] + 100 frame #17: 0x0000000189403c78 UIKit - [UIControl sendAction:to:forEvent:] + 80 帧#18:0x00000001893eb930 UIKit -[UIControl _sendActionsForEvents:withEvent:] + 416 frame #19: 0x0000000189403590 UIKit - [UIControl touchesEnded:withEvent:] + 572 帧#20:0x00000001894031c0 UIKit -[UIWindow _sendTouchesForEvent:] + 804 frame #21: 0x00000001893fbcdc UIKit - [UIWindow sendEvent:] + 784 帧#22:0x00000001893cc4a4 UIKit -[UIApplication sendEvent:] + 248 frame #23: 0x00000001893ca76c UIKit _ UIApplicationHandleEventQueue + 5528 帧#24:0x0000000183df0544 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 frame #25: 0x0000000183deffd8 CoreFoundation __ CFRunLoopDoSources0 + 540 帧#26:0x0000000183dedcd8 CoreFoundation __CFRunLoopRun + 724 frame #27: 0x0000000183d1cca0 CoreFoundation CFRunLoopRunSpecific + 384 帧#28:0x000000018ef58088 GraphicsServices GSEventRunModal + 180 frame #29: 0x0000000189434ffc UIKit UIApplicationMain + 204 第30帧:0x000000010029d09c Service.com main + 136 at AppDelegate.swift:45 frame #31: 0x000000019923a8b8 libdyld.dylib开始+ 4

我已经尝试了我能想到的一切,并遵循了许多教程和调试Bad Access错误,没有任何帮助。我几乎觉得这是一个Xcode问题,但我不知道。如果它有帮助,这是AbstractUser类:

public class AbstractUser: ServiceModel {

/// Date of last login
private(set) var lastLogin = NSDate()
/// Password (please, don't use this field stupidly...)
private(set) var password = String.empty

public struct SerializationKeys {
    public static let lastLogin = "last_login"
    public static let password = "password"
}


// MARK: - Copyable
public required init(source: Copyable) {
    super.init(source: source)

    let u = source as! AbstractUser
    lastLogin = u.lastLogin
    password = u.password
}


// MARK: - JSONSerializable
public required init(dictionary: [String : AnyObject]) {
    super.init(dictionary: dictionary)

    lastLogin = lastLogin <|? dictionary[SerializationKeys.lastLogin]
    password = password <|? dictionary[SerializationKeys.password]
}

public override func toDictionary() -> [String : AnyObject] {
    var dictionary = super.toDictionary()

    dictionary[SerializationKeys.lastLogin] = lastLogin.toString()
    dictionary[SerializationKeys.password] = password

    return dictionary
}


// MARK: - ModelType
public override func updateObject(newVersion: ModelType) {
    super.updateObject(newVersion)

    let u = newVersion as! AbstractUser
    lastLogin = u.lastLogin
    password = u.password
}


// MARK: - NSCoding
@objc public required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)

    lastLogin = lastLogin <|? aDecoder.decodeObjectForKey(SerializationKeys.lastLogin)
    password = password <|? aDecoder.decodeObjectForKey(SerializationKeys.password)
}

@objc public override func encodeWithCoder(aCoder: NSCoder) {
    super.encodeWithCoder(aCoder)

    aCoder.encodeObject(lastLogin, forKey: SerializationKeys.lastLogin)
    aCoder.encodeObject(password, forKey: SerializationKeys.password)
}
}

User对象也是AbstractUser的子类,并不是问题的原因。它会产生相同的错误,但只需在&#34之后放置打印(键);让键= ...&#34;会导致错误一样。问题似乎是当我尝试访问该子模块中任何类的任何属性或方法时。

0 个答案:

没有答案