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-11208] Runaway memory use by the constraint solver when using some dictionary literal, starting XCode 10.2 #53605

Open
swift-ci opened this issue Jul 25, 2019 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 5.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11208
Radar rdar://53589951
Original Reporter balastudor (JIRA User)
Type Bug

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression
Assignee slazarus (JIRA)
Priority Medium

md5: f5ed3265db37c1c63a05a1abef5d0e5e

Issue Description:

Since XCode 10.2, when entering a Swift file from a large project, it starts indexing forever.

In Xcode 10.1 the indexing ends after a while.

@belkadan
Copy link
Contributor

cc @akyrtzi

@akyrtzi
Copy link
Member

akyrtzi commented Jul 25, 2019

That's the constraint solver allocating memory for normal typechecking. \cc @xedin

@swift-ci
Copy link
Collaborator Author

Comment by Tudor-Dan Balas (JIRA)

Found the issue. @belkadan @akyrtzi @xedin

Create a new project, type the following => memory leak:

private static let asd: [UInt8: UIColor] = [
        0x01: UIColor(r: 3, g: 72, b: 14, a: 48),
        0x02: UIColor(r: 0, g: 240, b: 64, a: 77),
        0x03: UIColor(r: 0, g: 255, b: 0, a: 160),
        0x04: UIColor(r: 0, g: 168, b: 0, a: 255),
        0x05: UIColor(r: 0, g: 140, b: 0, a: 255),
        0x06: UIColor(r: 0, g: 112, b: 0, a: 255),
        0x07: UIColor(r: 255, g: 255, b: 0, a: 255),
        0x08: UIColor(r: 184, g: 184, b: 0, a: 255),
        0x09: UIColor(r: 224, g: 112, b: 0, a: 255),
        0x0A: UIColor(r: 255, g: 0, b: 0, a: 255),
        0x0B: UIColor(r: 184, g: 0, b: 0, a: 255),
        0x0C: UIColor(r: 112, g: 0, b: 0, a: 255),
        0x0D: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x0E: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x0F: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x10: UIColor(r: 0, g: 0, b: 0, a: 0),
    ]

@akyrtzi
Copy link
Member

akyrtzi commented Jul 26, 2019

Thank you so much for the test case!

@akyrtzi
Copy link
Member

akyrtzi commented Jul 26, 2019

To clarify, this runaway memory use test case reproduces by just invoking the compiler, so it also cannot be built, it's not specific to editing.

@xedin
Copy link
Member

xedin commented Jul 29, 2019

Thank you, balastudor (JIRA User)! I can reproduce this problem without involving UIKit:

import Foundation

class UIColor : NSObject {
  init(white: CGFloat, alpha: CGFloat) {}
  init(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat) {}
  init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {}
  init(displayP3Red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat) {}
  init?(named: String) {}
}

struct Test {
    static let _: [UInt8: UIColor] = [
        0x01: UIColor(r: 3, g: 72, b: 14, a: 48),
        0x02: UIColor(r: 0, g: 240, b: 64, a: 77),
        0x03: UIColor(r: 0, g: 255, b: 0, a: 160),
        0x04: UIColor(r: 0, g: 168, b: 0, a: 255),
        0x05: UIColor(r: 0, g: 140, b: 0, a: 255),
        0x06: UIColor(r: 0, g: 112, b: 0, a: 255),
        0x07: UIColor(r: 255, g: 255, b: 0, a: 255),
        0x08: UIColor(r: 184, g: 184, b: 0, a: 255),
        0x09: UIColor(r: 224, g: 112, b: 0, a: 255),
        0x0A: UIColor(r: 255, g: 0, b: 0, a: 255),
        0x0B: UIColor(r: 184, g: 0, b: 0, a: 255),
        0x0C: UIColor(r: 112, g: 0, b: 0, a: 255),
        0x0D: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x0E: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x0F: UIColor(r: 255, g: 0, b: 255, a: 255),
        0x10: UIColor(r: 0, g: 0, b: 0, a: 0),
    ]
}

It appears from the log that attempt to compose a solution with fixes which suggests relabeling

@swift-ci
Copy link
Collaborator Author

Comment by Tudor-Dan Balas (JIRA)

Any news regarding this issue?
@xedin slazarus (JIRA User)

@xedin
Copy link
Member

xedin commented Jan 15, 2020

balastudor (JIRA User) Sorry we didn't yet have to time to address this issue but it's in the queue and going to be fixed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 regression swift 5.0
Projects
None yet
Development

No branches or pull requests

5 participants