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
[SR-5289] unowned NSObject property is crashing with EXC_BAD_ACCESS #47864
Comments
I'm not seeing this with Xcode 9 beta 1. Mind checking if it's still showing up for you? |
Comment by Grzegorz Leszek (JIRA) Tested with Playground: |
Hm. Maybe it only happens in playgrounds, or maybe it's target-dependent. Is this a macOS, iOS, or tvOS playground? |
@swift-ci create |
Yes, it's a playground-only crash. Looks like the mirror machinery is not correctly handling the special cases in unowned variables. |
Comment by Grzegorz Leszek (JIRA) It is not playground only. It is target-dependent. I've managed to add example project. Tested on Xcode 8.3.2 and Xcode 9 beta 1. Crash happens after accessing the property.
|
Grzegorz, are you seeing this on iOS/tvOS device or simulator or both? |
Comment by Grzegorz Leszek (JIRA) Both iOS device (10.3.2) and iOS simulator (10.3). |
Thanks, that reproduces everywhere else. The final print() is required when not running in a playground; a playground implicitly prints the result which causes the same crash. This is a bug in loadSpecialReferenceStorage() in swift_ClassMirror_subscript(). It assumes that any variable that is not weak is strong. This is incorrect for unowned variables. The crash occurs because an unowned variable pointing to an ObjC object does not simply store a pointer to the object. |
I believe this is fixed by PR #28368 |
PR#28368 should have resolved this. Please let me know if it's still happening for you. |
Comment by Grzegorz Leszek (JIRA) Hi @tbkka, It is PARTIALLY fixed. It does not work in the playgrounds. ✅ iOS device and iOS simulator ❌ playground macOS Catalina, Xcode 11 Error Message: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation. Nevertheless, current fix is great and really helpful in iOS development, where I still need to work with Obj-C objects. |
Attachment: Download
Additional Detail from JIRA
md5: 6ad2d49f295da6aa8bb9e1ee602bb0dd
relates to:
Issue Description:
A concise description of the problem:
EXC_BAD_ACCESS when unowned property is NSObject
A reproducible test case:
A description of the environment that reproduces the problem:
Consistent crash on Xcode 8.3.2 (Swift 3.1) – MacOS Sierra 10.12.4
Tested also with Swift Toolchain 4.0 (Snapshot 2017-05-23 a)
Reproducible with playground
Possible similar issue: SR-1006
The text was updated successfully, but these errors were encountered: