You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SR-11285] EXC_BAD_ACCESS when self in convenience override init of an NSObject subclass is type-casted to a non-class protocol or passed to a generic func
#53686
Open
swift-ci opened this issue
Aug 9, 2019
· 0 comments
Note: Crash doesn't happen if swift version is set to 4.2 on Xcode 10.2.1, or on the latest Xcode 11 beta5 (swift 5.1 compiler, swift language version = 5).
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: e771a51601b0da55f6cd9deae8f4316e
Issue Description:
When self is (1) type-casted to a non-class protocol (which it conforms to), or (2) passed to a generic func, in a convenience override initializer (after self.init(..)) of an NSObject subclass, it causes a crash on swift_getObjectType call. The stacktrace looks the same for both cases (see below).
This doesn't happen if it doesn't inherit NSObject, or if the convenience override init is annotated with @nonobjc, or if the class is final, or if I call the generic func (or func accepting a protocol arg) after convenience override init is returned.
If the protocol is a class protocol, the crash doesn't happen for the case (1), but still happens for the case (2) above.
This is seen on Xcode 10.2.1 with swift language version set to 5.0. Note that the crash doesn't happen if swift version is set to 4.2 on Xcode 10.2.1, or on the latest Xcode 11 beta5 (swift 5.1 compiler, swift language version = 5).
Can you elaborate on what the bug was on this version and the fix for it? Sil produced by both Xcode versions (with swift lang version = 5) look the same. Also is there any other workaround besides the ones mentioned above? We need to be on this version for another couple of months.
Environment
Repro Env:
Xcode 10.2.1 (swift language version = 5.0)
Mac OS: 10.14.5
Note: Crash doesn't happen if swift version is set to 4.2 on Xcode 10.2.1, or on the latest Xcode 11 beta5 (swift 5.1 compiler, swift language version = 5).
Additional Detail from JIRA
md5: e771a51601b0da55f6cd9deae8f4316e
Issue Description:
When self is (1) type-casted to a non-class protocol (which it conforms to), or (2) passed to a generic func, in a convenience override initializer (after self.init(..)) of an NSObject subclass, it causes a crash on
swift_getObjectType call
. The stacktrace looks the same for both cases (see below).This doesn't happen if it doesn't inherit NSObject, or if the convenience override init is annotated with @nonobjc, or if the class is final, or if I call the generic func (or func accepting a protocol arg) after convenience override init is returned.
If the protocol is a class protocol, the crash doesn't happen for the case (1), but still happens for the case (2) above.
This is seen on Xcode 10.2.1 with swift language version set to 5.0. Note that the crash doesn't happen if swift version is set to 4.2 on Xcode 10.2.1, or on the latest Xcode 11 beta5 (swift 5.1 compiler, swift language version = 5).
Can you elaborate on what the bug was on this version and the fix for it? Sil produced by both Xcode versions (with swift lang version = 5) look the same. Also is there any other workaround besides the ones mentioned above? We need to be on this version for another couple of months.
Code example
Stacktrace
The text was updated successfully, but these errors were encountered: