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

Louis Zhuang louis.zhuang at acm.org
Wed Apr 14 09:31:07 PDT 2010


Ivan Maidanski <ivmai at ...> writes:
> I meant HotSpot bug 4352906. It's unclear how ss_sp value is trashed (and who
really does this) after the
> first call. See:
>
http://www.google.com/codesearch/p?hl=en#aRIt9pqzOVI/src/os/solaris/vm/os_solaris.hpp&q=thr_stksegment&sa=N&cd=2&ct=rc
> 
> On the other hand, implementing the workaround complicates the code - it would
require LOCK and
> GC_lookup_thread() which could return null (since get_main_stack_base is
called before GC_thr_init).

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


--- os_dep.c.orig       2010-04-14 17:21:55.000000000 +0100
+++ os_dep.c    2010-04-14 17:21:57.000000000 +0100
@@ -1306,6 +1306,30 @@

 #endif /* GC_OPENBSD_THREADS */

+#ifdef GC_SOLARIS_THREADS
+
+# 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