Scala Programming Language
  1. Scala Programming Language
  2. SI-6853

StackOverflowError when using mutable.ListMap.+= method

    Details

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

      Description

      The implementation of the += method uses remove(key: A, elems: List[(A, B)]): List[(A, B)], which is not tail recursive.

      A quick way to reproduce it in the REPL:

      scala> val m = collection.mutable.ListMap[String, Int]()
      m: scala.collection.mutable.ListMap[String,Int] = Map()

      scala> var i = 0
      i: Int = 0

      scala> while(i < 80000)

      { m += ("foo" + i) -> i; i = i+1}

      java.lang.StackOverflowError
      at scala.collection.mutable.ListMap.remove(ListMap.scala:56)
      at scala.collection.mutable.ListMap.remove(ListMap.scala:56)
      at scala.collection.mutable.ListMap.remove(ListMap.scala:56)
      ...

        Activity

        Hide
        Vinicius Miana Bezerra added a comment - - edited
        Show
        Vinicius Miana Bezerra added a comment - - edited Fix in https://github.com/scala/scala/pull/1960

          People

          • Assignee:
            Vinicius Miana Bezerra
            Reporter:
            Stephane Godbillon
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development