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

[SR-5310] unowned object crashes in noescape closures #47885

Closed
swift-ci opened this issue Jun 26, 2017 · 4 comments
Closed

[SR-5310] unowned object crashes in noescape closures #47885

swift-ci opened this issue Jun 26, 2017 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself runtime The Swift Runtime

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5310
Radar rdar://problem/32985963
Original Reporter Igor (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Xcode 9 beta 2

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Runtime
Assignee None
Priority Medium

md5: 88de78b708b4297dec25aca25a48ab75

is duplicated by:

  • SR-5395 Memory management issue in nonescaping block with unowned self in ObjC subclasses

relates to:

  • SR-5289 unowned NSObject property is crashing with EXC_BAD_ACCESS

Issue Description:

Written by mistake unowned worked fine before, but in Xcode 9 beta 2 crashes. Object points to incorrect memory

import Foundation
import UIKit

extension NSObject {
   final func calculate<T>(_ operation: () -> T) -> T {
      return operation()
   }
}

extension UIButton {
   var calculatedTitle: String {
      return self.calculate { [unowned self] in
         return self.currentTitle!
      }
   }
}

let button = UIButton()
button.setTitle("Hello", for: .normal)

print(button.calculatedTitle)
@belkadan
Copy link
Contributor

@gparker42, there's a dup of this already, right?

@belkadan
Copy link
Contributor

@swift-ci create

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jun 30, 2017

Reproduced with beta 2 but not with TOT. Might already be fixed.

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jul 10, 2017

This should be fixed in Xcode 9 beta 3. Thanks for the bug report.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

2 participants