This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Kill a static constructor in boehm-gc
- To: "Boehm, Hans" <hans_boehm at hp dot com>
- Subject: Re: Kill a static constructor in boehm-gc
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- Date: Tue, 23 Oct 2001 13:30:09 +1300
- CC: java-patches at gcc dot gnu dot org
- References: <40700B4C02ABD5119F000090278766443BECD1@hplex1.hpl.hp.com>
Boehm, Hans wrote:
>>Hans, what do you think of this patch?
>>
>I'm not sure I understand the original problem well enough.
>
I don't really understand the details either, but basically, how can the
GC initialize - eg find the applications static data section, when that
data may not have even been loaded yet? This crash occurs even with
GC6.1a1 and glibc 2.2.4, so I dont think its a problem neccessarily
related to shared library registration.
>My impression
>is that it's fine for gcj, but causes a problem if you use the collector in
>other contexts.
>
>Perhaps the right thing is to go ahead and apply your patch, and to change
>the documentation to suggest that GC_init should be called somehow, e.g.
>from a constructor, if you use GC_local_malloc.
>
OK. Here's the patch which I'm checking in.
regards
Bryce.
2001-10-22 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
* linux_threads.c (GC_init_parallel): Do not declare as a static
constructor.
* include/gc.h (GC_init): Declare here. Add description.
* include/private/gc_priv.h (GC_init): Remove declaration.
Index: linux_threads.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/linux_threads.c,v
retrieving revision 1.15
diff -u -r1.15 linux_threads.c
--- linux_threads.c 2001/10/17 04:55:27 1.15
+++ linux_threads.c 2001/10/23 00:16:50
@@ -204,11 +204,7 @@
static GC_bool parallel_initialized = FALSE;
-# if defined(__GNUC__)
- void GC_init_parallel() __attribute__ ((constructor));
-# else
- void GC_init_parallel();
-# endif
+void GC_init_parallel();
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
Index: include/gc.h
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/include/gc.h,v
retrieving revision 1.4
diff -u -r1.4 gc.h
--- gc.h 2001/10/16 09:01:38 1.4
+++ gc.h 2001/10/23 00:16:51
@@ -297,6 +297,14 @@
/* Wizards only. */
/* Public procedures */
+
+/* Initialize the collector. This is only required when using thread-local
+ * allocation, since unlike the regular allocation routines, GC_local_malloc
+ * is not self-initializing. If you use GC_local_malloc you should arrange
+ * to call this somehow (e.g. from a constructor) before doing any allocation.
+ */
+GC_API void GC_init GC_PROTO((void));
+
/*
* general purpose allocation routines, with roughly malloc calling conv.
* The atomic versions promise that no relevant pointers are contained
Index: include/private/gc_priv.h
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/include/private/gc_priv.h,v
retrieving revision 1.4
diff -u -r1.4 gc_priv.h
--- gc_priv.h 2001/10/16 09:01:39 1.4
+++ gc_priv.h 2001/10/23 00:16:51
@@ -1629,7 +1629,6 @@
/* blocks available. Should be called */
/* until the blocks are available or */
/* until it fails by returning FALSE. */
-GC_API void GC_init GC_PROTO((void)); /* Initialize collector. */
#if defined(MSWIN32) || defined(MSWINCE)
void GC_deinit GC_PROTO((void));