Re: [Gc] Bug: GC_get_stack_base does not acquire allocator lock

Ivan Maidanski ivmai at mail.ru
Thu Mar 4 09:22:35 PST 2010


Thu, 4 Mar 2010 17:55:25 +0100 Burkhard Linke  <blinke at cebitec.uni-bielefeld.de> wrote:
> HI,
> GC_get_stack_base under Solaris (and probably every other OS that uses the 
> GC_find_limit() based implementation) does not acquire the allocator lock. If 
> libgc is built with assertions enabled applications fail if they start a 
> thread using the GC start wrapper or call GC_get_stack_base on their own 
> (e.g. mono).
>
> The attached patch adds the missing LOCK() and UNLOCK() statements to the 
> function in question.

I'm not commenting the functionality here, just minor notes about the patch style (and the previous one):

1. move LOCK() to be after IF_CANCEL(int ...;) (recall this is not a C++ so all statements should be after locals declarations.

2. if you add LOCK() then add  "DCL_LOCK_STATE;" (after "IF_CANCEL(int ...;)").

3. use "f(void)" instead of "f()" when declaring a no-arg func.

4. each pre-processor directive adds an indentation level, e.g.

+    if (sigismember(&pending_signals, SIG_SUSPEND)) {
+      /* we have a pending suspend signal that is likely not to be processed */
+#if   defined(DEBUG_THREADS)
+      GC_log_printf("pending suspend signal in thread %d\n",pthread_self());
+#endif

should be:

+    if (sigismember(&pending_signals, SIG_SUSPEND)) {
+      /* we have a pending suspend signal that is likely not to be processed */
+#     if defined(DEBUG_THREADS)
+        GC_log_printf("pending suspend signal in thread %d\n",pthread_self());
+#     endif

(Of course, it's not hard to me to do these code reformatting myself but... at least you should know this for the future)

Also, in the submitted backtrace:

-----------------  lwp# 3 / thread# 3  --------------------
 fffffd7fff285966 GC_typed_mark_proc () + de
......

Which code line stands for "0xde" offset?

Bye.


More information about the Gc mailing list