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

Fibonacci benchmark fails with Stack Overflow on NET Core, but not on Framework #193

Open
ArbilGit opened this issue Feb 4, 2019 · 4 comments

Comments

@ArbilGit
Copy link

ArbilGit commented Feb 4, 2019

The following fails with Stack Overflow on NET Core, but runs fine on Framework:

 let rec fib n = job {
      if n < 2L then
        return n
      else
        let! x = fib (n-2L)
        let! y = fib (n-1L)
        return x + y
 }
 fib 30L |> run

The call stack full of four functions repeated over again suggests a tail call problem:

image

Possibly related to #192 which I've just tested , similarly works fine on Framework but fails on Core. Which seems strange to me: if Core and Framework share the compiler to IL, and the JIT compiler (RyuJIT), shouldn't the tail call optimization succeed on both, or fail on both simultaneously?

Tested on Windows 10 x64, NET Core 3.0 Preview 2

@haf
Copy link
Member

haf commented Feb 5, 2019

@ArbilGit You're welcome to look into it. Otherwise, thanks for reporting it.

@ArbilGit
Copy link
Author

ArbilGit commented Feb 5, 2019

@haf I've been trying, but without success thus far. Workaround discovered: compile with CoreRT. It's a JIT issue, then.

@haf
Copy link
Member

haf commented Feb 5, 2019

@ArbilGit Perhaps it would be prudent to file and issue with the .net/coreclr team, then.

@haf
Copy link
Member

haf commented Feb 17, 2019

@ArbilGit Filed a F# lang suggestion, see link above.

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

No branches or pull requests

2 participants