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

Unowned self reference crashed on iOS 13 #2008

Merged
merged 1 commit into from
Mar 24, 2020
Merged

Conversation

mats-claassen
Copy link
Member

This code should be equivalent but somehow using unowned crashes the app in iOS 13.

Also when building for release the compiler crashes with a segmentation fault.

Fixes #1987
Fixes #1999
Fixes #1988

@mats-claassen mats-claassen merged commit 41bbb0a into master Mar 24, 2020
@dneykov
Copy link
Contributor

dneykov commented Mar 25, 2020

@mats-claassen when these fixed will be released? I apply them manually and can confirm my app is not crashing anymore.

@LeoAiolia
Copy link

when these fixed will be released? please release as soon as possible

@mats-claassen mats-claassen deleted the fix/unowned_crash branch March 25, 2020 12:23
@mats-claassen
Copy link
Member Author

Release is on its way #2011

@mdekkernet
Copy link

Somehow, this fix was not enough for xcode 11.4 & iOS 13.4 GM. Still experienced a BAD_ADDRESS
@mats-claassen did you try this on the latest xcode & ios?

Added the self. reference in BaseRow and the error disappeared, should I create a PR?

public internal(set) var validationErrors = [ValidationError]() {
        didSet {
            guard validationErrors != oldValue else { return }
            RowDefaults.onRowValidationChanged["\(type(of: self))"]?(baseCell, self)
            self.callbackOnRowValidationChanged?()
            self.updateCell()
        }
    }

@mats-claassen
Copy link
Member Author

@mffryslan Did you experience that in the Examples? Or can you provide code to reproduce it? I tested it on Xcode 11.4 and iOS 13.4

@vinczebalazs
Copy link

vinczebalazs commented Apr 4, 2020

Hi!

I am not sure if it's the same issue, but getting EXC_BAD_ACCESS when trying to print the value in onChange

Here is an example:

final class TestRow: Row<LabelCell>, RowType  {}
form
    ++ TestRow("test") {
        $0.title = "Title"
    }.onChange {
        print($0.value)
    }

(form.rowBy(tag: "test") as! TestRow).value = "test"

The crash occurs on print($0.value).

  • Eureka 5.2.1
  • Xcode 11.4 (11E146)
  • iOS 13.4

EDIT:

Renaming _value in RowOf<T> fixes the issue, not sure what's causing it though!

@mats-claassen
Copy link
Member Author

Hey @vinczebalazs I tried your code in the Example project and I am not getting any crash running on the simulator. Did you get that crash in the Example project?

Have you done a clean and build?

@ghost
Copy link

ghost commented Apr 11, 2020

Still experiencing EXC_BAD_ACCESS with Eureka 5.2.1.

  • iPhone XS Max (13.4)
  • Xcode Version 11.4 beta 3 (11N132i)
  • MacOS 10.15.3 (19D76)
    截屏2020-04-11下午8 41 10
    截屏2020-04-11下午9 04 13

@@ -202,7 +202,7 @@ extension RowType where Self: BaseRow {
*/
@discardableResult
public func onChange(_ callback: @escaping (Self) -> Void) -> Self {
callbackOnChange = { [unowned self] in callback(self) }
callbackOnChange = { [weak self] in callback(self!) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force unwrawpping a weak self is just as bad as unowned self. My suggestion is test the optional properly.

[weak self] in guard let self = self else { return }; callback(self)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants