Duplicates in constructor result in an infinite loop
Opened this issue · 0 comments
stewSquared commented
Perm(3,4,5,3)
result in an infinite loop that eventually consumes all memory.
We should probably filter duplicates or throw an IllegalArgumentException
.
Stack trace for the above:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at scala.collection.immutable.List.$colon$colon(List.scala:112)
at net.alasc.perms.Cycle$.rec$1(Cycle.scala:96)
at net.alasc.perms.Cycle$.orbit(Cycle.scala:98)
at net.alasc.perms.Cycles$.rec$1(Cycles.scala:103)
at net.alasc.perms.Cycles$.fromSupportAndImageFun(Cycles.scala:108)
at net.alasc.perms.internal.GenPrmOps$.toCycles$extension(GenPrmOps.scala:52)
at net.alasc.perms.Perm.toString(Perm.scala:17)
at scala.runtime.ScalaRunTime$.inner$1(ScalaRunTime.scala:250)
at scala.runtime.ScalaRunTime$.stringOf(ScalaRunTime.scala:255)
at scala.runtime.ScalaRunTime$.replStringOf(ScalaRunTime.scala:263)
at .$print$lzycompute(<console>:10)
at .$print(<console>:6)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:735)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:999)
at scala.tools.nsc.interpreter.IMain.$anonfun$interpret$1(IMain.scala:567)
at scala.tools.nsc.interpreter.IMain$$Lambda$4658/2087216452.apply(Unknown Source)
at scala.reflect.internal.util.ScalaClassLoader.asContext(ScalaClassLoader.scala:34)
at scala.reflect.internal.util.ScalaClassLoader.asContext$(ScalaClassLoader.scala:30)
at scala.reflect.internal.util.AbstractFileClassLoader.asContext(AbstractFileClassLoader.scala:33)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:566)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:593)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:563)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:886)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:754)
at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:456)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:477)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:1069)