[Mono-bugs] [Bug 623477] Different behavior on Thread(ThreadEntryPoint, maxStackSize) on .net and mono

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jul 20 02:55:59 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=623477

http://bugzilla.novell.com/show_bug.cgi?id=623477#c4


--- Comment #4 from Torello Querci <tquerci at gmail.com> 2010-07-20 06:55:58 UTC ---
Moreover,

on windows platform there is a minimum value of Stack Size that it's assigned
even if the application ask for less memory.

In the official documentation there is write:
"If maxStackSize is less than the minimum stack size, the minimum stack size is
used. If maxStackSize is not a multiple of the page size, it is rounded to the
next larger multiple of the page size. For example, if you are using the .NET
Framework version 2.0 on Microsoft Windows Vista, 256KB (262144 bytes) is the
minimum stack size, and the page size is 64KB (65536 bytes).
"

So to have the same behavior on mono that we have on .net we can assume to have
the same stack size.
Personally I not like this solution because I prefer to have the exact memory
that I ask but in this case some assembly can not able to run, so the patch can
became something like this one:

Index: class/corlib/System.Threading/Thread.cs
===================================================================
--- class/corlib/System.Threading/Thread.cs    (revisione 159957)
+++ class/corlib/System.Threading/Thread.cs    (copia locale)
@@ -976,8 +976,12 @@
         {
             if (start == null)
                 throw new ArgumentNullException ("start");
-            if (maxStackSize < 131072)
-                throw new ArgumentException ("< 128 kb", "maxStackSize");
+            if (maxStackSize < 0)
+                throw new ArgumentException ("< 0 kb", "maxStackSize");
+            if (maxStackSize < 262144)
+                maxStackSize = 262144;
+            if ((maxStackSize | 0xffff) != 0)
+                maxStackSize = (maxStackSize | 0xffff)+0xffff;

             threadstart = start;
             Internal.stack_size = maxStackSize;
@@ -995,8 +999,12 @@
         {
             if (start == null)
                 throw new ArgumentNullException ("start");
-            if (maxStackSize < 131072)
-                throw new ArgumentException ("< 128 kb", "maxStackSize");
+            if (maxStackSize < 0)
+                throw new ArgumentException ("< 0 kb", "maxStackSize");
+            if (maxStackSize < 262144)
+                maxStackSize = 262144;
+            if ((maxStackSize | 0xffff) != 0)
+                maxStackSize = (maxStackSize | 0xffff)+0xffff;

             threadstart = start;
             Internal.stack_size = maxStackSize;

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list