Closed shaop closed 5 years ago
on iOS 9 the base class object.superclass
is named _TtCs12_SwiftObject
.
Maybe it should be changed like this ?
public struct Metadata {
...
// name
let name = String(describing: type)
if name == "Swift._SwiftObject" || name == "NSObject" || name == "_TtCs12_SwiftObject" { return nil }
...
我也遇到了这个问题,我和同事的环境都是macOS 10.15,同样的代码,我的不会崩溃,而他的就会崩溃。
@shaop 你加上name == "_TtCs12_SwiftObject"判断之后是否有效?
@shaop 你加上name == "_TtCs12_SwiftObject"判断之后是否有效?
我尝试了一下,确实有效避免了崩溃。
@CoderMJLee 是的,可以避免奔溃。
@CoderMJLee 并且多线程的时候经常在第 18 行奔溃,是否应该在将锁放在第 18 行前?
public static func type(_ type: Any.Type) -> BaseType? {
// get from cache
let key = typeKey(type)
typeLock.lock()
defer { typeLock.unlock() }
if let mt = types[key] { return mt }
.....
// judge after lock
if let mt = types[key] { return mt }
SwiftObject.h 这里有表明 _TtCs12_SwiftObject
, 但是注释中也写了
// Real class name: mangled "Swift._SwiftObject"
目前不太清楚为什么一些低版本的系统上出现了问题
@shaop @huhaosanxiong 1.1.1版本已经修复
thanks 👍
crash at
Thread 1: EXC_BAD_ACCESS (code=1, address=0x100000003) (Type.swift line 47)
use
description.pointee
on iOS 9