-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
SOE in Eval.defer #1703
Comments
Oh no! I'll definitely be waiting to see if we can a semi-minimized case. @mpilquist if you have ideas about the shape I can try to help trigger this bug. Worst-case we can always replace |
This is our test that exposes the issue: "staging stack safety" in {
val N = 100000
val s = (0 until N).foldLeft(Segment.singleton(0))((s,i) => s map (_ + i))
s.sum(0).run shouldBe (0 until N).sum
} (A
(0 until 1000000).foldLeft(Eval.later(0))((acc, i) => Eval.defer(acc.map(_ + i))).value I'll keep playing with it. If you want to try yourself, clone private def evalDefer[A](e: => Eval[A]): Eval[A] = Eval.defer(e)
// private def evalDefer[A](e: => Eval[A]): Eval[A] = Eval.now(()) flatMap { _ => e } Then run |
can this be something we can fix before cats 1.0? cc @kailuowang |
I am under the impression that #1888 didn’t fix this issue but I will try latest with fs2 and report back. |
@mpilquist if it doesn't, why didn't the test prove safety? |
it's true that the system closed this one automatically by mistake. I am reopening it pending @mpilquist's report. |
@johnynek Still broken with cats 1.0.0-SNAPSHOT. Take a look here: mpilquist/fs2@375bec2 Running
Last I talked to @non about this, we weren't sure if the issue lies in FS2 or in Cats. I've been assuming the issue is Cats because everything works fine when using the commented out definition of the private |
Those line numbers don't seem to line up with the latest. For one, Compute was renamed FlatMap. Are you sure you are trying the latest? I agree that if you get SOE when you rewrite In fact, I'd love to see us have consistent evidence that the defer strategy we have is faster since it is certainly more complex to verify to be correct. |
@johnynek Thanks for spotting that. Coursier was evicting the SNAPSHOT dependency in favor of 1.0.0-MF. Once I got that straightened out, I had to upgrade cats-effect to 1.0.0-SNAPSHOT and deal with various breakages since the MF release. Anyway, good news is that the FS2 tests pass now. Closing this issue as fixed... |
We encountered a stack overflow when using
Eval.defer
in FS2 with cats 0.9:Changing all uses of
Eval.defer(c)
toEval.now(()).flatMap(_ => c)
fixes. I haven't been able to minimize yet.The text was updated successfully, but these errors were encountered: