Bug 17908 - Mono's stack limit is too tight
Summary: Mono's stack limit is too tight
Alias: None
Product: Runtime
Classification: Mono
Component: io-layer ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-02-20 10:09 UTC by Yuta Sato (lambdalice)
Modified: 2014-02-20 15:05 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Yuta Sato (lambdalice) 2014-02-20 10:09:06 UTC
Hello, I'm lambdalice, 16 years old Japanese student.
I'm from Nemerle Forum and we have a problem.

In conclusion, we hope that [these lines in the corlib]( https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Threading/Thread.cs#L829-832 ) be removed.

We can't compile Nemerle on Mono, because of Mono's too tight stack limit.
Compiling Nemerle sources make many recursions, and always cause StackOverflow and fail to compile, so we can't be accepted the package by Debian.

We started to research the history of Mono's stack limit.

Please see the old [wthreads.c]( https://gitorious.org/mono/mono/source/4bb580d93174a4b683ddc1616009805bbdbb7944:mono/io-layer/wthreads.c#L377-381 ).

First, it was 2MB on x32 and 4MB on x64 and it was reduced to half.
The comment says:

> temporarily changed to use 1 MB: this allows more threads
> to be used, as well as using less virtual memory and so
> more is available for the GC heap.

And now, these lines are removed and moved to [mono-threads-posix.c]( https://github.com/mono/mono/blob/master/mono/utils/mono-threads-posix.c#L123-132 ).

Then we tried to remove https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Threading/Thread.cs#L829-832 and build it.
By using the modified Mono make it possible to compile Nemerle successfully, even though we didn't change any lines in mono-threads-posix.c.
This is quite strange.

Of course, we tried to rewrite Nemerle Compiler, and we found it very diffifult.
Because there is many recursion and corecursion, and we have to rewrite them in a imperative style.

And we've found some projects that can be compiled on Windows and Mono on Windows, but can't do on Mono on Linux.
In this point Mono (on Linux) is no longer not .NET compatible, and we hope to eliminate the stack size limitation (or make it bigger).


Please see also a discussion in Nemerle Forum: https://groups.google.com/forum/#!topic/nemerle-en/xNrjBBqtoYE

Best Regards, lambdalice
Comment 1 Yuta Sato (lambdalice) 2014-02-20 10:45:26 UTC
Sorry for my misspelling;

- In this point Mono (on Linux) is no longer not .NET compatible
+ In this point Mono (on Linux) is no longer .NET compatible
Comment 2 Zoltan Varga 2014-02-20 12:13:19 UTC
Fixed in mono master 6d95657a21434fc46b5fa1b02d76781f5d53846c. This change will not make mono 3.2.7/3.2.8.
Comment 3 Zoltan Varga 2014-02-20 12:23:05 UTC
Comment 4 Rodrigo Kumpera 2014-02-20 15:05:51 UTC
Reverted Zoltan's fix.

We should keep the old behavior when possible. Now we're using getrlimit to get the max thread stack size.