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
A scala 2.13 Vector can be constructed with an invalid internal state (regression from 2.12.8) #11636
Comments
Might be interesting -- breaks at 2466 elements. scala> (a ++ b ++ c).map(_ => 0).size
res5: Int = 2465
scala> (a ++ b ++ c ++ d).map(_ => 0).size
java.lang.NullPointerException
at scala.collection.immutable.VectorIterator.next(Vector.scala:801)
at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100)
at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87)
at scala.collection.immutable.Vector.map(Vector.scala:113)
... 28 elided
scala> d.size
res7: Int = 2
scala> (a ++ b ++ c ++ Vector(1, 2)).map(_ => 0).size
java.lang.NullPointerException
at scala.collection.immutable.VectorIterator.next(Vector.scala:801)
at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100)
at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87)
at scala.collection.immutable.Vector.map(Vector.scala:113)
... 28 elided
scala> (a ++ b ++ c ++ Vector(1)).map(_ => 0).size
java.lang.NullPointerException
at scala.collection.immutable.VectorIterator.next(Vector.scala:801)
at scala.collection.StrictOptimizedIterableOps.map(StrictOptimizedIterableOps.scala:100)
at scala.collection.StrictOptimizedIterableOps.map$(StrictOptimizedIterableOps.scala:87)
at scala.collection.immutable.Vector.map(Vector.scala:113)
... 28 elided
scala> (a ++ b ++ c ++ Vector.empty).map(_ => 0).size
res10: Int = 2465 |
Thanks for the minimal/self-contained reproducer! |
Could you opine on whether this bug could leave a Vector in a state where your code might silently do the wrong thing? A particular concern would be one which dropped elements either upon insertion or iteration. If this is the case, it's potentially extremely serious and might warrant a community notification |
This reverts commit 18224fd. # Conflicts: # src/library/scala/collection/immutable/Vector.scala Reverts scala#7588 which caused scala/bug#11636.
This reverts commit 18224fd. # Conflicts: # src/library/scala/collection/immutable/Vector.scala Reverts most of scala#7588 which caused scala/bug#11636.
This reverts commit 18224fd. # Conflicts: # src/library/scala/collection/immutable/Vector.scala Reverts most of scala#7588 which caused scala/bug#11636.
This reverts commit 18224fd. # Conflicts: # src/library/scala/collection/immutable/Vector.scala Reverts most of scala#7588 which caused scala/bug#11636.
This reverts commit 18224fd. # Conflicts: # src/library/scala/collection/immutable/Vector.scala Reverts most of scala#7588 which caused scala/bug#11636.
Fixed by scala/scala#8410 for now, including a regression test for when we try to add the optimization again. |
obviated by scala/scala#8534 |
I have managed to construct a Vector in an application which is in an invalid state. It has taken me some time to reproduce this, because the resultant vector cannot be iterated over, serialized, and my IDE cannot inspect it. The following code works in 2.12.8:
However, in scala 2.13.0:
The text was updated successfully, but these errors were encountered: