Skip to content
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

ParTrieMap iteration fails with ClassCastException #7498

Closed
scabug opened this issue May 20, 2013 · 7 comments
Closed

ParTrieMap iteration fails with ClassCastException #7498

scabug opened this issue May 20, 2013 · 7 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented May 20, 2013

Performing a foreach on a ParTrieMap instance sometimes causes the following ClassCastException to be thrown:

java.lang.ClassCastException: scala.collection.LinearSeqLike$$anon$1 cannot be cast to scala.collection.parallel.IterableSplitter
        at scala.collection.parallel.IterableSplitter$$anonfun$splitWithSignalling$1.apply(RemainsIterator.scala:398)
        at scala.collection.immutable.List.foreach(List.scala:309)
        at scala.collection.parallel.IterableSplitter$class.splitWithSignalling(RemainsIterator.scala:398)
        at scala.collection.parallel.mutable.ParTrieMapSplitter.splitWithSignalling(ParTrieMap.scala:123)
        at scala.collection.parallel.ParIterableLike$Accessor$class.split(ParIterableLike.scala:905)
        at scala.collection.parallel.ParIterableLike$Foreach.split(ParIterableLike.scala:972)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.split(Tasks.scala:516)
        at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.spawnSubtasks(Tasks.scala:197)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.spawnSubtasks(Tasks.scala:514)
        at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.internal(Tasks.scala:170)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.internal(Tasks.scala:514)
        at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.compute(Tasks.scala:162)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.compute(Tasks.scala:514)
        at scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:160)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runSubtask(ForkJoinPool.java:994)
        at scala.concurrent.forkjoin.ForkJoinPool.tryHelpStealer(ForkJoinPool.java:1702)
        at scala.concurrent.forkjoin.ForkJoinPool.awaitJoin(ForkJoinPool.java:1830)
        at scala.concurrent.forkjoin.ForkJoinTask.doJoin(ForkJoinTask.java:344)
        at scala.concurrent.forkjoin.ForkJoinTask.join(ForkJoinTask.java:648)
        at scala.collection.parallel.ForkJoinTasks$WrappedTask$class.sync(Tasks.scala:444)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.sync(Tasks.scala:514)
        at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.internal(Tasks.scala:187)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.internal(Tasks.scala:514)
        at scala.collection.parallel.AdaptiveWorkStealingTasks$WrappedTask$class.compute(Tasks.scala:162)
        at scala.collection.parallel.AdaptiveWorkStealingForkJoinTasks$WrappedTask.compute(Tasks.scala:514)
        at scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:160)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262)
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1478)
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
@scabug
Copy link
Author

@scabug scabug commented May 20, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7498?orig=1
Reporter: William Robertson (nullptr)
Affected Versions: 2.10.1
Other Milestones: 2.11.0-M4

@scabug
Copy link
Author

@scabug scabug commented May 22, 2013

William Robertson (nullptr) said:
I did some instrumentation of the code for ParTrieMap, and it looks like subiter can refer to a TrieMap iterator rather than a ParTrieMap iterator (see around TrieMap.scala:1018 in 2.10.1). A possible fix would be to make sure that subiter is always assigned the result of newIterator which is overloaded in ParTrieMap, although I'm not familiar enough with the codebase to know whether that's the right solution.

@scabug
Copy link
Author

@scabug scabug commented May 30, 2013

@retronym said:
Alex: could you please take a look at this one?

@scabug
Copy link
Author

@scabug scabug commented May 30, 2013

@axel22 said:
Sure. William's analysis is correct - this is due to a cast in the ParTrieMap of the return value of subdivide from TrieMap, that internally does not call newIterator when it deals with LNodes. I will fix this.

@scabug
Copy link
Author

@scabug scabug commented May 30, 2013

@axel22 said:
Should do the trick:

scala/scala#2610

@scabug
Copy link
Author

@scabug scabug commented May 30, 2013

@JamesIry said:
Pull request hasn't been merged. We'll close when it has.

@scabug
Copy link
Author

@scabug scabug commented Jun 9, 2013

@retronym said:
Reopening for the backport for 2.10.3

scala/scala#2644

@scabug scabug closed this Jul 10, 2013
@scabug scabug added the blocker label Apr 7, 2017
@scabug scabug added this to the 2.10.3-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants