Re: [Mono-dev] News about Bug 623477

2010-12-10 Thread Paolo Molaro
On 12/08/10 Rodrigo Kumpera wrote:
> Well, the most appropriate behavior would be to expose a new runtime
> function
> that returns the smallest allowed stack size.
> 
> Something like:
> 
> --in metadata/theads.c
> 
> int
> mono_thread_get_stack_min_size ()
> {
> #if defined (PTHREAD_STACK_MIN)
>return PTHREAD_STACK_MIN;
> #else /*FIXME add more cases. Not sure WINAPI exposes such a thing*/
>   return mono_pagesize (); /*A sane default*/
> #endif

Both PTHREAD_STACK_MIN and the page size are not sane defaults at all.
We should just ignore it if the user asks for a smaller size than the
minimum and raise an exception only on < 0.

lupus

-- 
-
lu...@debian.org debian/rules
lu...@ximian.com Monkeys do it better
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477

2010-12-08 Thread Rodrigo Kumpera
Well, the most appropriate behavior would be to expose a new runtime
function
that returns the smallest allowed stack size.

Something like:

--in metadata/theads.c

int
mono_thread_get_stack_min_size ()
{
#if defined (PTHREAD_STACK_MIN)
   return PTHREAD_STACK_MIN;
#else /*FIXME add more cases. Not sure WINAPI exposes such a thing*/
  return mono_pagesize (); /*A sane default*/
#endif
}


Then export it in icalls-def.h to a System.Threading.Thread static method.


And finally use this on managed code to properly check for minimum size.
Such change would be the appropriate way to go.

Torrelo, can you cook up such a patch? Either post it on bugzilla or make a
pull request.

Thanks,
Rodrigo



On Mon, Dec 6, 2010 at 9:00 AM, Torello Querci  wrote:

> Hi Rodrigo,
>
> this is true but with this sample code:
>
> using System;
> using System.Threading;
>
> namespace testThread
> {
>class Program
>{
>static void Main(string[] args)
>{
>Program p = new Program();
>
>Thread t = new Thread(p.ThreadEntryPoint, Int32.Parse(args[0]));
>t.Start();
>Console.WriteLine("T0 - Chk1");
>Thread.Sleep(5000);
>Console.WriteLine("T0 - Exit");
>}
>
>public void ThreadEntryPoint(Object obj)
>{
>Console.WriteLine("T1 - Enter");
>Thread.Sleep(5000);
>Console.WriteLine("T1 - Exit");
>}
>}
> }
>
> if you run:
>
> Thread.exe 64000
>
> after compile it on VS this work while I get exception on Mono and for
> me is a bug.
> Ok, I compile with 3.5 profile, but also on 2.0 profile works so I
> suppose that the original MS specification was not implements by MS :)
>
> Best Regards.
>
>
>
> 2010/12/6 Rodrigo Kumpera :
> > This behavior is OS/target dependant, so it's not very useful to try to
> > match MS behavior on it.
> >
> > On Thu, Dec 2, 2010 at 11:09 AM, Torello Querci 
> wrote:
> >>
> >> Hi guy,
> >>
> >> no news about bug 623477?
> >>
> >>
> >>
> >> Best Regards, Torello
> >> ___
> >> Mono-devel-list mailing list
> >> Mono-devel-list@lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
> >
>
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477

2010-12-06 Thread Torello Querci
Hi Rodrigo,

this is true but with this sample code:

using System;
using System.Threading;

namespace testThread
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();

Thread t = new Thread(p.ThreadEntryPoint, Int32.Parse(args[0]));
t.Start();
Console.WriteLine("T0 - Chk1");
Thread.Sleep(5000);
Console.WriteLine("T0 - Exit");
}

public void ThreadEntryPoint(Object obj)
{
Console.WriteLine("T1 - Enter");
Thread.Sleep(5000);
Console.WriteLine("T1 - Exit");
}
}
}

if you run:

Thread.exe 64000

after compile it on VS this work while I get exception on Mono and for
me is a bug.
Ok, I compile with 3.5 profile, but also on 2.0 profile works so I
suppose that the original MS specification was not implements by MS :)

Best Regards.



2010/12/6 Rodrigo Kumpera :
> This behavior is OS/target dependant, so it's not very useful to try to
> match MS behavior on it.
>
> On Thu, Dec 2, 2010 at 11:09 AM, Torello Querci  wrote:
>>
>> Hi guy,
>>
>> no news about bug 623477?
>>
>>
>>
>> Best Regards, Torello
>> ___
>> Mono-devel-list mailing list
>> Mono-devel-list@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477

2010-12-05 Thread Rodrigo Kumpera
This behavior is OS/target dependant, so it's not very useful to try to
match MS behavior on it.

On Thu, Dec 2, 2010 at 11:09 AM, Torello Querci  wrote:

> Hi guy,
>
> no news about bug 623477?
>
>
>
> Best Regards, Torello
> ___
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477?

2010-08-16 Thread Torello Querci
New patch with the fixes.

Index: class/corlib/System.Threading/Thread.cs
===
--- class/corlib/System.Threading/Thread.cs (revisione 160737)
+++ 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 & 0x) != 0)
+maxStackSize = (maxStackSize & 0x)+0x1;

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 & 0x) != 0)
+maxStackSize = (maxStackSize & 0x)+0x1;

threadstart = start;
Internal.stack_size = maxStackSize;
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477?

2010-08-16 Thread Torello Querci
Hi Tobias,

2010/8/16 Tobias Käs :
> Torello Querci  gmail.com> writes:
>>
>> [...]
>>
>> +            if ((maxStackSize | 0x) != 0)
>> +                maxStackSize = (maxStackSize | 0x)+0x;
>>
>> [...]
>>
>> +            if ((maxStackSize | 0x) != 0)
>> +                maxStackSize = (maxStackSize | 0x)+0x;
>>
>> [...]
>>
>
> This doesn't look right to me, (maxStackSize | 0x) is always nonzero and
> thus the branch will always be taken. From the bug entry it looks like it is
> supposed to round up to a multiple of 64K but that's not what the code is 
> doing.
>
> Probably should be something like this: (not tested!)
>
>  if ((maxStackSize & 0x) != 0)
>    maxStackSize = (maxStackSize & ~0x) + 0x1;
>
> or rounding up without branch:
>
>  maxStackSize = ((maxStackSize + 0x) / 0x1) * 0x1;
>

You are right.
I prefer the first solution because is more clean.

> Just my 2c
> Regards
> Tobias Käs
>

Best Regards, Torello
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] News about Bug 623477?

2010-08-16 Thread Tobias Käs
Torello Querci  gmail.com> writes:
>
> [...]
> 
> +if ((maxStackSize | 0x) != 0)
> +maxStackSize = (maxStackSize | 0x)+0x;
>
> [...]
>
> +if ((maxStackSize | 0x) != 0)
> +maxStackSize = (maxStackSize | 0x)+0x;
> 
> [...]
> 

This doesn't look right to me, (maxStackSize | 0x) is always nonzero and
thus the branch will always be taken. From the bug entry it looks like it is
supposed to round up to a multiple of 64K but that's not what the code is doing.

Probably should be something like this: (not tested!)

  if ((maxStackSize & 0x) != 0)
maxStackSize = (maxStackSize & ~0x) + 0x1;

or rounding up without branch:

  maxStackSize = ((maxStackSize + 0x) / 0x1) * 0x1;

Just my 2c
Regards
Tobias Käs

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list