[Mono-dev] [patch] Fix crash for invalid stack size on os x

Jb Evain jbevain at gmail.com
Sun Apr 24 05:40:35 EDT 2011


Hi,

On OS X, the following test crashes mono:

using System;
using System.Threading;

class Program {

	static void Main ()
	{
		const int system_page_size = 4096;
		const int large_stacksize = system_page_size * 400;
		const int undivisible_stacksize = 1048573;

		var t1 = new Thread (new ThreadStart (delegate { Console.WriteLine
("t1"); }), undivisible_stacksize);
		var t2 = new Thread (new ThreadStart (delegate { Console.WriteLine
("t2"); }), large_stacksize);

		t1.Start ();
		t2.Start ();
		
		t1.Join ();
		t2.Join ();
	}
}
<<<<<<

The issue being the invalid stacksize we eventually pass to
pthread_attr_setstacksize.

The attached patch fixes the issue and implements the behavior
described in the MSDN for Thread::.ctor.

Comments?

Jb
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stack_size.patch
Type: application/octet-stream
Size: 1975 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110424/0163f40f/attachment.obj 


More information about the Mono-devel-list mailing list