From: ivmai Date: Tue, 5 Jul 2011 16:35:22 +0000 (+0000) Subject: 2011-07-05 Ivan Maidanski X-Git-Tag: gc7_3alpha2~413 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0f043893c60075690a974e41901fb7a878cad3d;p=gc 2011-07-05 Ivan Maidanski * 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. --- diff --git a/ChangeLog b/ChangeLog index 34085005..5370f518 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-07-05 Ivan Maidanski + + * 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 * dyn_load.c (GC_register_dynamic_libraries): Remove duplicate diff --git a/malloc.c b/malloc.c index 80ef18d9..aeda6936 100644 --- 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 34bb570e..c2d5cab3 100644 --- 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); diff --git a/pthread_support.c b/pthread_support.c index f9af3029..7e7e2914 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -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. */