Skip to content

immutable map crashes on stackoverflow (recursive ListMap) #3989

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

Closed
scabug opened this issue Nov 10, 2010 · 3 comments
Closed

immutable map crashes on stackoverflow (recursive ListMap) #3989

scabug opened this issue Nov 10, 2010 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 10, 2010

scala> class Foo{ override def equals(o: Any) = false; override def hashCode = 1}
defined class Foo


scala> var m = Map[Foo, Int]()
m: scala.collection.immutable.Map[Foo,Int] = Map()

scala> for (i <- 1 to 8000) m += (new Foo) -> i
java.lang.StackOverflowError
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable.ListMap$$Node.get(ListMap.scala:148)
        at scala.collection.immutable....

The issue is that ListMap.Node#get is recursive instead of iterative. ListMap is used by HashMapCollision1.

@scabug
Copy link
Author

scabug commented Nov 10, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3989?orig=1
Reporter: Ittay Dror (ittayd)

@scabug
Copy link
Author

scabug commented Nov 17, 2010

@axel22 said:
(In r23534) Fixes #3989, adding test cases for #3989 and #3996.

No review.

@scabug
Copy link
Author

scabug commented Nov 17, 2010

@axel22 said:
(In r23535) Fixes #3989.

No review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants