2011-07-05 Ivan Maidanski <ivmai@mail.ru>
authorivmai <ivmai>
Tue, 5 Jul 2011 16:35:22 +0000 (16:35 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:07:00 +0000 (21:07 +0400)
* malloc.c (GC_init_lib_bounds): Call GC_init (to ensure GC is
initialized before doing GC_text_mapping).
* misc.c (GC_init): Add a check for GC_init recursion in case of
malloc is redirected (abort with the corresponding message).
* pthread.c (GC_thr_init): Place GC_add_roots_inner call into
"else" branch to prevent "local variable might be uninitialized"
compiler warning; add comment.

ChangeLog
malloc.c
misc.c
pthread_support.c

index 3408500..5370f51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-07-05  Ivan Maidanski <ivmai@mail.ru>
 
+       * malloc.c (GC_init_lib_bounds): Call GC_init (to ensure GC is
+       initialized before doing GC_text_mapping).
+       * misc.c (GC_init): Add a check for GC_init recursion in case of
+       malloc is redirected (abort with the corresponding message).
+       * pthread.c (GC_thr_init): Place GC_add_roots_inner call into
+       "else" branch to prevent "local variable might be uninitialized"
+       compiler warning; add comment.
+
+2011-07-05  Ivan Maidanski <ivmai@mail.ru>
+
        * dyn_load.c (GC_register_dynamic_libraries): Remove duplicate
        call of GC_FirstDLOpenedLinkMap (twice).
        * dyn_load.c (GC_register_main_static_data): Add comment.
index 80ef18d..aeda693 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -354,6 +354,7 @@ void * malloc(size_t lb)
   STATIC void GC_init_lib_bounds(void)
   {
     if (GC_libpthread_start != 0) return;
+    GC_init(); /* if not called yet */
     if (!GC_text_mapping("libpthread-",
                          &GC_libpthread_start, &GC_libpthread_end)) {
         WARN("Failed to find libpthread.so text mapping: Expect crash\n", 0);
diff --git a/misc.c b/misc.c
index 34bb570..c2d5cab 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -663,6 +663,14 @@ GC_API void GC_CALL GC_init(void)
     IF_CANCEL(int cancel_state;)
 
     if (GC_is_initialized) return;
+#   ifdef REDIRECT_MALLOC
+      {
+        static GC_bool init_started = FALSE;
+        if (init_started)
+          ABORT("Redirected malloc() called during GC init");
+        init_started = TRUE;
+      }
+#   endif
 
 #   ifdef GC_INITIAL_HEAP_SIZE
       initial_heap_sz = divHBLKSZ(GC_INITIAL_HEAP_SIZE);
index f9af302..7e7e291 100644 (file)
@@ -906,8 +906,10 @@ GC_INNER void GC_thr_init(void)
       if (!GC_enclosing_mapping(thread_local_addr, &main_thread_start,
                                 &main_thread_end)) {
         ABORT("Failed to find mapping for main thread thread locals");
+      } else {
+        /* main_thread_start and main_thread_end are initialized.       */
+        GC_add_roots_inner(main_thread_start, main_thread_end, FALSE);
       }
-      GC_add_roots_inner(main_thread_start, main_thread_end, FALSE);
     }
 # endif
   /* Add the initial thread, so we can stop it. */