[Mono-bugs] [Bug 74608][Nor] New - FreeBSD requires larger stack than PTHREAD_STACK_MIN

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 14 Apr 2005 13:15:47 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by flashdict@gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=74608

--- shadow/74608	2005-04-14 13:15:47.000000000 -0400
+++ shadow/74608.tmp.6970	2005-04-14 13:15:47.000000000 -0400
@@ -0,0 +1,61 @@
+Bug#: 74608
+Product: Mono: Runtime
+Version: 1.1
+OS: other
+OS Details: FreeBSD (All)
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: io-layer
+AssignedTo: dick@ximian.com                            
+ReportedBy: flashdict@gmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: FreeBSD requires larger stack than PTHREAD_STACK_MIN
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+The collection thread's init routine sets its stacksize to
+PTHREAD_STACK_MIN.  This makes perfect sense, but unfortunately, on FreeBSD
+(all versions except LATEST), this wont work.  I've corresponded with David
+Xu, the FreeBSD kernel/threads lead developer, and he's fixed the problem
+for LATEST, which will eventually become FreeBSD 6.0.  For current versions
+of FreeBSD however, the stack size must be increased to avoid "Temporarily
+out of resources" (EAGAIN) errors from the kernel when Mono starts up.
+
+According to David:
+
+"This is a known problem, the PTHREAD_MINI_STACK is too small
+for makecontext(), and makecontext refuses to make a usefull context,
+and in pthread_create, kernel also refuses to load an uninitialized
+context, it has being forgotten ,I will fix it, thanks!"
+
+And later:
+
+"... for example 64K as we ever did in old version, the default stack size
+now is 1M on 32bits and 2M on 64bits platform, so setting it to 64K will
+bring you back to old days. :-)"
+
+The following patch fixes the problem without uglyfying the code too much,
+I hope.
+
+Index: collection.h
+===================================================================
+--- collection.h        (revision 43003)
++++ collection.h        (working copy)
+@@ -12,6 +12,10 @@
+
+ #include <glib.h>
+
++#ifdef __FreeBSD__
++#define PTHREAD_STACK_MIN 65536
++#endif
++
+ #define _WAPI_HANDLE_COLLECTION_UNSAFE                         \
+        {                                                       \
+                guint32 _wapi_save_start;                       \