Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 9 Crash #31

Closed
shaop opened this issue Nov 1, 2019 · 9 comments
Closed

iOS 9 Crash #31

shaop opened this issue Nov 1, 2019 · 9 comments

Comments

@shaop
Copy link

shaop commented Nov 1, 2019

crash at

Thread 1: EXC_BAD_ACCESS (code=1, address=0x100000003) (Type.swift line 47)

use description.pointee on iOS 9

@shaop
Copy link
Author

shaop commented Nov 1, 2019

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 }
        ...

@huhaosanxiong
Copy link

我也遇到了这个问题,我和同事的环境都是macOS 10.15,同样的代码,我的不会崩溃,而他的就会崩溃。

@CoderMJLee
Copy link
Collaborator

@shaop 你加上name == "_TtCs12_SwiftObject"判断之后是否有效?

@huhaosanxiong
Copy link

@shaop 你加上name == "_TtCs12_SwiftObject"判断之后是否有效?

我尝试了一下,确实有效避免了崩溃。

@shaop
Copy link
Author

shaop commented Nov 4, 2019

@CoderMJLee 是的,可以避免奔溃。

@shaop
Copy link
Author

shaop commented Nov 4, 2019

@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 }
        

@shaop
Copy link
Author

shaop commented Nov 4, 2019

SwiftObject.h 这里有表明 _TtCs12_SwiftObject , 但是注释中也写了

// Real class name: mangled "Swift._SwiftObject"

目前不太清楚为什么一些低版本的系统上出现了问题

@CoderMJLee
Copy link
Collaborator

@shaop @huhaosanxiong 1.1.1版本已经修复

@shaop
Copy link
Author

shaop commented Nov 4, 2019

thanks 👍

@shaop shaop closed this as completed Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants