[Gc] On cancellation, GC_thread_exit_proc is never called
gniibe at fsij.org
Tue Mar 30 17:02:58 PST 2010
Ivan Maidanski wrote:
> Tue, 30 Mar 2010 13:48:08 +0900 NIIBE Yutaka <gniibe at fsij.org>:
> If this is a GCC-specific issue then, I think, "&& defined(__GNUC__)" should be added to the patch.
>> In case of -fexceptions, __cleanup__ attribute is used and it is
>> recorded in the .eh_frame section.
>> Without option of -fexceptions, it is registered by
Yes, this is a GCC specific issue. In pthread.h, we see:
#if defined __GNUC__ && defined __EXCEPTIONS
for pthread_cleanup_push with __cleanup__ attribute.
That is, the problem of never called GC_thread_exit_proc occurs
only if gcc -fexceptions is used.
So, here is second try which has better ifdef condition with __GNUC__.
RCS file: /cvsroot/bdwgc/bdwgc/include/gc_config_macros.h,v
retrieving revision 1.22
diff -u -r1.22 gc_config_macros.h
--- include/gc_config_macros.h 20 Oct 2009 21:27:26 -0000 1.22
+++ include/gc_config_macros.h 31 Mar 2010 00:57:58 -0000
@@ -139,6 +139,20 @@
# define _REENTRANT
+# if defined(__GNUC__) && defined(GC_LINUX_THREADS)
+ /* We undefine __EXCEPTIONS to avoid using __cleanup__ attribute of GCC. */
+ /* */
+ /* NPTL implementation of pthread_cleanup_push uses __cleanup__ attribute */
+ /* when __EXCEPTIONS is defined (-fexceptions). */
+ /* Stack unwinding and cleanup with __cleanup__ attributes works correctly */
+ /* when everything is compiled with -fexceptions, but it is not the */
+ /* requirement for this library users to use -fexceptions everywhere. */
+ /* */
+ /* With __EXCEPTIONS undefined, cleanup routines are registered with */
+ /* __pthread_register_cancel, which works any cases. */
+# undef __EXCEPTIONS
#if !defined(_WIN32_WCE) || defined(__GNUC__)
# include <stddef.h>
More information about the Gc