Uploaded image for project: 'Swift'
  1. Swift
  2. SR-774

Array of Range can cause an infinite loop while compiling

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

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

      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.

        Attachments

          Activity

          Hide
          MPow Alex Manzella added a comment -

          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

          Show
          MPow Alex Manzella added a comment - 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

            People

            • Assignee:
              Unassigned
              Reporter:
              MPow Alex Manzella
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: