[Gc] Re: Re[2]: implement GC_get_stack_base by thr_stksegment in solaris

Louis Zhuang louis.zhuang at acm.org
Wed Apr 14 10:27:43 PDT 2010


> It seems a Solaris JDK specific bug. In such situaion, we've cached main stack
> base in GC_stackbottom @ misc:845, is it safe to assume we only call
> GC_get_stack_base once in primordial thread? Following patch is generated
> against latest CVS version. Thanks, Louis
> 
Pls apply following patch with ANSI C guard the same as solaris header.
Rgds, Louis

--- os_dep.c.orig       2010-04-14 18:25:50.000000000 +0100
+++ os_dep.c    2010-04-14 18:25:55.000000000 +0100
@@ -1306,6 +1306,31 @@

 #endif /* GC_OPENBSD_THREADS */

+#if defined(GC_SOLARIS_THREADS) \
+    && (!defined(_STRICT_STDC) || defined(__EXTENSIONS__))
+
+# define HAVE_GET_STACK_BASE
+
+#include <thread.h>
+#include <signal.h>
+
+/* from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4352906 */
+/* thr_stksegment is not reliable for primordial thread under JDK  */
+/* However we already cache primordial thread's stack base in      */
+/* GC_stackbottom so we are sort of safe                           */
+GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *b)
+{
+    stack_t s;
+    if (!thr_stksegment(&s)) {
+        GC_abort("thr_stksegment error");
+    }
+    GC_ASSERT(s.ss_sp > (&s));
+    b -> mem_base = s.ss_sp;
+    return GC_SUCCESS;
+}
+
+#endif /* GC_SOLARIS_THREADS */
+
 #ifndef HAVE_GET_STACK_BASE
 /* Retrieve stack base.                                         */
 /* Using the GC_find_limit version is risky.                    */




More information about the Gc mailing list