Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.1
    • Component/s: Collections
    • Labels:
      None

      Description

      List.foldRight is not tail recursive, so it throws StackOverflowError when called on a large list.

      Example:

      scala> (List.range(1, 1000000) :\ 0) (_ + _)
      java.lang.StackOverflowError
              at scala.List.foldRight(List.scala:1079)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRight(List.scala:1081)
              at scala.List.foldRig...
      scala>
      

      In fact, 10000 is enough on my system.

        Issue Links

          Activity

          Hide
          Paolo G. Giarrusso added a comment -

          Sean, I've marked this ticket as due for 2.10.1-RC1 to hopefully get new attention to it. But I'd recommend to submit a pull request, it seems this time it's going to be accepted. But you (somebody) needs to:

          • add some test case (you have a minimal one, if that fails now that's good)
          • possibly, check other variations of the same bug (like reduceRight). And what about LinearSeqOptimized.fold/reduceRight? I see your point on not touching Stream, but LinearSeqOptimized is implemented by other classes, so it should also be addressed.
            If some broken use cases are left, please comment on SI-6922 so that they're documented.
          Show
          Paolo G. Giarrusso added a comment - Sean, I've marked this ticket as due for 2.10.1-RC1 to hopefully get new attention to it. But I'd recommend to submit a pull request, it seems this time it's going to be accepted. But you (somebody) needs to: add some test case (you have a minimal one, if that fails now that's good) possibly, check other variations of the same bug (like reduceRight). And what about LinearSeqOptimized.fold/reduceRight? I see your point on not touching Stream, but LinearSeqOptimized is implemented by other classes, so it should also be addressed. If some broken use cases are left, please comment on SI-6922 so that they're documented.
          Hide
          Adriaan Moors added a comment -

          without further activity on this ticket this week, I'm afraid it'll have to slip to 2.10.2

          Show
          Adriaan Moors added a comment - without further activity on this ticket this week, I'm afraid it'll have to slip to 2.10.2
          Show
          James Iry added a comment - https://github.com/scala/scala/pull/2026
          Hide
          Seth Tisue added a comment -

          there is further discussion in SI-3295

          Show
          Seth Tisue added a comment - there is further discussion in SI-3295
          Hide
          Paolo G. Giarrusso added a comment -

          I just marked SI-3295 as duplicate .

          Show
          Paolo G. Giarrusso added a comment - I just marked SI-3295 as duplicate .

            People

            • Assignee:
              James Iry
              Reporter:
              NagMacFeegle
              TracCC:
              Johannes Rudolph
            • Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development