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.
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);
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);
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. */