typelevel / typelevel/scalacheck
Stack overflow caused by retryUntil
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2k
- Forks
- 393
- Avg merge
- 6h 42m
- Merged PRs (30d)
- 4
Description
The following generator causes a stack overflow error:
`import org.scalacheck.Arbitrary.arbBigInt
arbBigInt.arbitrary.retryUntil(x => x >= BigInt(200) && x <= BigInt(300)).sample`
will cause
java.lang.StackOverflowError at scala.collection.immutable.RedBlackTree$.doFrom(scratch_34:250) at scala.collection.immutable.RedBlackTree$.doFrom(scratch_34:249) at scala.collection.immutable.RedBlackTree$.doFrom(scratch_34:249) at scala.collection.immutable.RedBlackTree$.from(scratch_34:71) at scala.collection.immutable.TreeMap.from(scratch_34:59) at org.scalacheck.Gen$$anonfun$frequency$1.apply(scratch_34:390) at org.scalacheck.Gen$$anonfun$frequency$1.apply(scratch_34:390) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$R$class.flatMap(scratch_34:171) at org.scalacheck.Gen$R$$anon$4.flatMap(scratch_34:157) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:48) at org.scalacheck.Gen$$anon$6.doApply(scratch_34:182) at org.scalacheck.Gen$$anon$2.doApply(scratch_34:74) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:48) at org.scalacheck.Gen$$anon$6.doApply(scratch_34:182) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$R$class.flatMap(scratch_34:171) at org.scalacheck.Gen$R$$anon$4.flatMap(scratch_34:157) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:48) at org.scalacheck.Gen$$anon$6.doApply(scratch_34:182) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$R$class.flatMap(scratch_34:171) at org.scalacheck.Gen$R$$anon$4.flatMap(scratch_34:157) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1.apply(scratch_34:48) at org.scalacheck.Gen$$anon$6.doApply(scratch_34:182) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) at org.scalacheck.Gen$$anonfun$flatMap$1$$anonfun$apply$1.apply(scratch_34:49) Output exceeds cutoff limit.
It seems to be very dependent on lower and upper limit parameters and the usage of retryUntil. For example with lower = 100 and upper = 200 it doesn't crash, nor if using suchThat.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example using arbBigInt.arbitrary.retryUntil(...).sample, comparing it with the lower and upper limits that do not crash and with suchThat. Trace retryUntil and the generator calls shown in the stack trace; done means the failing range no longer causes a StackOverflowError while the generator still samples values meeting the predicate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100