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

Ivan Maidanski ivmai at mail.ru
Wed Apr 14 23:36:57 PDT 2010


Wed, 14 Apr 2010 17:27:43 +0000 (UTC) Louis Zhuang <louis.zhuang at acm.org>:

> > It seems a Solaris JDK specific bug. In such situation, 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

This is a public function so we can't assume it is never called by the user for the main thread. (I can't make a decision myself whether it's ok to ignore the bug or add a workaround (caching+locking) for it.)

> > 
> Pls apply following patch with ANSI C guard the same as solaris header.
> Rgds, Louis

Is the whole bdwgc really compilable with -D _STRICT_STDC on Solaris? (If not then there is no need for testing _STRICT_STDC/__EXTENSIONS__).

> 
> --- 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__))

I think it's better to have a macro to fall back to the default strategy
(e.g. NO_THR_STKSEGMENT).

> +
> +# 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)) {

According to the spec, 0 means no error.

> +        GC_abort("thr_stksegment error");
> +    }
> +    GC_ASSERT(s.ss_sp > (&s));

It's "nicer" to write: GC_ASSERT(&s HOTTER_THAN s.ss_sp);

> +    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