Re: [Gc] implement GC_get_stack_base by thr_stksegment in solaris
ivmai at mail.ru
Sat Apr 10 06:16:53 PDT 2010
Fri, 9 Apr 2010 15:33:05 +0000 (UTC) Louis Zhuang <louis.zhuang at acm.org>:
> Hi, I think solaris specific thr_stksegment is the better API to implement
> GC_get_stack_base, which avoids worrying SIGSEV from find_limit(). Please review
> following patch.
The idea looks good. But the implementation is not so easy. Due to the thr_stksegment bug, it shouldn't be called more than once for the main thread (note that GC_get_stack_base is an API function). Next, thr_stksegment() returned value should be checked (non-zero means error, it is ok to abort in that case). And, add, please, a GC_ASSERT on the returned ss_sp value to be greater than the current stack frame).
Also, thr_stksegment() may be not available (e.g. in case of strict ANSI), so it's good to add a macro turning off thr_stksegment usage (e.g., NO_THR_STKSEGMENT).
It would be also good to submit the patch against the recent CVS (and use GC_get_stack_base() proto definition decorated with GC_API/GC_CALL).
> Cheers, Louis
> Index: os_dep.c
> --- os_dep.c (revision 23713)
> +++ os_dep.c (revision 23718)
> @@ -1230,6 +1230,22 @@
> #endif /* GC_LINUX_THREADS */
> +#if defined(GC_SOLARIS_THREADS)
> +#include <thread.h>
> +#include <signal.h>
> +int GC_get_stack_base(struct GC_stack_base *b)
> + stack_t s;
> + thr_stksegment(&s);
> + b -> mem_base = s.ss_sp;
> + return GC_SUCCESS;
> +#define HAVE_GET_STACK_BASE
> +#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