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

Gen.list is not stack safe #47

Open
charleso opened this issue Oct 26, 2018 · 3 comments
Open

Gen.list is not stack safe #47

charleso opened this issue Oct 26, 2018 · 3 comments
Labels

Comments

@charleso
Copy link
Collaborator

We're only using a call-by-need Identity, which is lazy but not stack-safe. That means, among other things, that generating large lists will never work. We should use a stack-safe traverse instead.

https://github.com/scalaz/scalaz/blob/v7.1.5/core/src/main/scala/scalaz/Traverse.scala#L80

@charleso charleso added the bug label Oct 26, 2018
@steinybot
Copy link
Contributor

This also means that it blows up for Gen.string with a length of around 2680 with a default stack size of 1M.

@charleso
Copy link
Collaborator Author

This also means that it blows up for Gen.string with a length of around 2680 with a default stack size of 1M.

Yeah I'm sorry. :( In theory it shouldn't be that hard to fix, but I was in a rush last time I tried and got lost in the types.

@pjan
Copy link

pjan commented Sep 14, 2020

Running into this as well for Byte Arrays of some length

java.lang.StackOverflowError
  at hedgehog.core.GenT.$anonfun$mapTree$1(GenT.scala:20)
  at hedgehog.core.GenT.$anonfun$flatMap$1(GenT.scala:15)
  at hedgehog.core.GenImplicits2$$anon$2.$anonfun$ap$1(GenT.scala:146)
  at hedgehog.core.GenImplicits2$$anon$2.$anonfun$ap$1(GenT.scala:145)
  at hedgehog.core.GenImplicits2$$anon$2.$anonfun$ap$1(GenT.scala:146)
  at hedgehog.core.GenImplicits2$$anon$2.$anonfun$ap$1(GenT.scala:146)
  ...

Spent some time creating tailRecM's for the different Monads (still need PropertyT and Tree), but seems there's more work to do, and mine is limited. Happy to collaborate with others though, if people are keen.

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

No branches or pull requests

3 participants