19

I have a .NET 4.0 application that makes heavy use of tail recursion (programmed in F#). It runs fine on the .NET VM, but it runs out of stack on Mono-3.0.1.

I've tried running with mono --optimize=tailc but that doesn't seem to change anything.

Is there some way to force mono to eliminate tail calls? Is there some way to increase the maximum stack size in mono?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Nikhil Swamy
  • 199
  • 2
  • 1
    https://bugzilla.novell.com/show_bug.cgi?id=476785 -- [This page](http://www.mono-project.com/Runtime_Projects) says it's being worked on, but no projected completion date. – Robert Harvey Nov 29 '12 at 01:02
  • [This page](http://www.mono-project.com/Mono_Project_Roadmap) says that Tail Calls in F# were fixed in Version 2.12 – Robert Harvey Nov 29 '12 at 01:06
  • 2.12 was renamed to 3.0; and anyway it says "optimizations", not "all optimizations", so I guess the one that Nikhil is hitting is not fixed yet – knocte Nov 29 '12 at 08:01
  • 1
    Thanks for these responses. Any ideas about my second question: I.e., how can I increase the max stack size in mono? – Nikhil Swamy Nov 30 '12 at 00:57
  • To change the stack size, see [my answer here](http://stackoverflow.com/a/19909421/1822514) for one way. – chue x Nov 14 '13 at 22:39

1 Answers1

1

There is a very similar more recent question with helpful answers: Stack size under Mono

As Robert Harvey already pointed out in the comments, Mono has broken/incomplete tail call support for F# (bug 476785: Tail call support in F#). Fix for this problem is on Mono's runtime ongoing projects list.

Stack size can be increased either using System.Threading.Thread constructor or in the PE header. The System.Threading.Thread way does not work in Mono, though. For changing the PE, you'll probably need MS Visual Studio, since there may be no alternative to its editbin.exe /stack.

Community
  • 1
  • 1
Palec
  • 12,743
  • 8
  • 69
  • 138