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-774] Array of Range can cause an infinite loop while compiling #43386

Closed
swift-ci opened this issue Feb 19, 2016 · 3 comments · Fixed by #59931
Closed

[SR-774] Array of Range can cause an infinite loop while compiling #43386

swift-ci opened this issue Feb 19, 2016 · 3 comments · Fixed by #59931
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-774
Radar None
Original Reporter MPow (JIRA User)
Type Bug
Environment

OSX 10.11.3 (15D21), (Swift master/f560f3caac06723, llvm stable/0d07a5d3d55078) also tested with Xcode 7.2.1

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

md5: d4e70bd6e65567f702c38104d33c7bd0

Issue Description:

I experienced an infinite loop in the compiler while working with `Range`s. I tried to checkout the current version (Swift master/f560f3caac06723, llvm stable/0d07a5d3d55078) and tried to understand more about it.

Disclaimer: It's the first time I try to go deeper in this land, I'm just trying to be a bit more helpful than just reporting the bug but I might be completely wrong 🙂

Looks like the infinite loop happens at `CSSolver.cpp:1310`and `CSSolver.cpp:1739` where `ConstraintSystem::solveRec` is calling `ConstraintSystem::solveSimplified`that again calls `ConstraintSystem::solveRec`.

I will try to understand more but ATM I'm not experienced enough with this codebase to have proper fixes.

@swift-ci
Copy link
Collaborator Author

Comment by Alex Manzella (JIRA)

Looks like array of Range(s) cause the type checking to be very slow, the more you add Ranges to the array the more it slow down... 1 range okay, 2 ranges slower, .... 8 ranges VERY slow, 9 ranges infinite loop (? or just extremely slow ?).
Still investigating but looks like happening only for literal Ranges, also trying an array of ClosedInterval ranges (let c = [1...2,1...2,1...2,1...2,1...2,1...2,1...2,1...2,1...2,1...2,1...2,1...2] ) is slow but works, replacing the last entry with `1..<2` breaks it.
I'm wondering if all this is just something that should fall into expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions because I actually got that result also for this kind of expression

@swift-ci
Copy link
Collaborator Author

Comment by Alex Manzella (JIRA)

I saw SR-305 and this is actually the same issue. Using type annotation `let someRanges: [Range<Int>] = [1..<4, 1..<8, 1..<16, 1..<32, 1..<64, 1..<128, 1..<256, 1..<512, 1..<1024]` compiles immediately. I will check if [this commit ](2cdd7d64e1e2add7bcfd5452d36e7f5fc6c86a03) also fixes this issue

@Dante-Broggi
Copy link
Contributor

Is this resolved? If so, this should be closed.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this issue Jul 6, 2022
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this issue Jul 7, 2022
AnthonyLatsis added a commit to AnthonyLatsis/swift that referenced this issue Jul 9, 2022
hborla pushed a commit to hborla/swift that referenced this issue Jul 21, 2022
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this issue Jul 28, 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 performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants