Re[2]: [Gc] race? leads to segfault in GC_suspend_all's call to pthread_kill

Ivan Maidanski ivmai at mail.ru
Tue May 10 03:03:38 PDT 2011


Hi. 

Ok. I've added a note to GC_register_my_thread. 

>Andy Wingo wrote:
>
>> On Fri 06 May 2011 16:00, Jim Meyering <jim at meyering.net> writes:
>>
>>> I had had to explicitly GC_register two threads, but had not arranged
>>> for them to be unregistered:
>>>
>>>   http://thread.gmane.org/gmane.comp.lib.iwhd.devel/552
>>>
>>> Unregistering, as required, solved the problem.
>>
>> Whoa, good one! Thanks for the note, that was interesting.
>
>Thanks. I wondered if I missed something obvious
>in the documentation for GC_register_my_thread, went back
>and read its comment and didn't see anything. Considering
>the penalty I incurred for not reading about the companion
>function (GC_unregister_my_thread), I suggest this note of warning:
>
>2011-05-10 Jim Meyering <meyering at redhat.com>
>
>* include/gc.h (GC_register_my_thread): Add a note of warning:
>if you use GC_register_my_thread to register a thread, you must
>be sure to unregister it with GC_unregister_my_thread.
>Otherwise, your application will fail in a hard-to-diagnose manner.
>E.g., http://thread.gmane.org/gmane.comp.lib.iwhd.devel/552
>
>
>Index: include/gc.h
>===================================================================
>RCS file: /cvsroot/bdwgc/bdwgc/include/gc.h,v
>retrieving revision 1.86
>diff -u -p -r1.86 gc.h
>--- include/gc.h7 Apr 2011 20:35:46 -00001.86
>    include/gc.h10 May 2011 06:42:38 -0000
>@@ -1051,6  1051,9 @@ GC_API void * GC_CALL GC_call_with_stack
>/* GC_use_threads_discovery() is called at start-up. Except for the */
>/* latter case, the explicit call is normally required for threads  */
>/* created by third-party libraries.                 */
>  /* CAUTION: if you call GC_register_my_thread from a thread, T,    */
>  /* you must ensure that T calls GC_unregister_my_thread before    */
>  /* termination.                            */
>GC_API int GC_CALL GC_register_my_thread(const struct GC_stack_base *);
>
>/* Unregister the current thread. Only an explicitly registered   */
>_______________________________________________
>Gc mailing list
>Gc at linux.hpl.hp.com
>http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>
>


More information about the Gc mailing list