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-7561] Release Scheme : Swift dealloc Bug : EXC_BAD_ACCESS : EXC_I386_INVOP #50103

Open
swift-ci opened this issue Apr 28, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation run-time crash Bug → crash: Swift code crashed during execution

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7561
Radar https://bugreport.apple.com/web/?problemID=39735886
Original Reporter antony.newman (JIRA User)
Type Bug

Attachment: Download

Environment

swift 4.1 / Xcode 9.3 / iOS 11.3 / any iDevice

Compiled a nMP

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

md5: fe8e820e91dd27418a99c6ac1f6ac393

Issue Description:

+++) The following code Crashes with a RELEASE scheme, but is OK on a DEBUG scheme.

+) To reproduce : Run in Xcode Simulator -> Click three times on the RED Box and it crashes.

+) Any of the following three changes to RELEASE scheme seem to fix this crash (and also fix much larger projects that crash with the same fault)

1) Change 'Enable Testability' -> Yes

2) Change 'Compilation Mode' -> Single File

3) Change 'Swift Compiler - Code Generation : Optimization Level' -> Either No optimization or Optimize for Size.

import UIKit

var g_but = MY_UIButton(frame: CGRect(x: 100, y: 100,width: 200,height: 200))
let g_false = false
let opt_zero : Int? = 0
class EMPTY_CLASS {}
let g_empty_arr : [EMPTY_CLASS] = []

class ViewController: UIViewController
{
    override func viewDidAppear(_ animated: Bool)
    {
        super.viewDidAppear(animated)
        g_but.backgroundColor = UIColor.red
        view.addSubview(g_but)
        g_but.addTarget(g_but,action: #selector(MY_UIButton.touchDown(_:)), for:.touchDown)
    }
}
 
class MY_UIButton : UIButton
{
    @objc func touchDown(_: MY_UIButton?)
    {
        if (opt_zero! >= g_empty_arr.count) {}
        let zero_str = (opt_zero == nil) ? "" : "\(opt_zero!)"
        if (g_false) {  print(zero_str) }
        if (opt_zero! >= g_empty_arr.count) {}
    }
}
@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented May 1, 2018

cc @eeckstein

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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 crash Bug: A crash, i.e., an abnormal termination of software optimized only Flag: An issue whose reproduction requires optimized compilation run-time crash Bug → crash: Swift code crashed during execution
Projects
None yet
Development

No branches or pull requests

2 participants