From: Ivan Maidanski Date: Fri, 27 Jan 2012 05:40:15 +0000 (+0400) Subject: Fix GC_init_linux_data_start to set GC_data_start to valid address X-Git-Tag: gc7_3alpha2~175 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f1c9620836ac249e28b3e35af377c6bc329f86b;p=gc Fix GC_init_linux_data_start to set GC_data_start to valid address even if GC_no_dls (fix commit db0da19) * os_dep.c (GC_init_linux_data_start): Test GC_no_dls only to avoid GC_find_limit call; initialize GC_data_start to DATAEND in case of GC_no_dls to make data root empty (to prevent incorrect argument passed to GC_add_roots_inner call in GC_register_data_segments). * os_dep.c (GC_register_data_segments): Do not invoke GC_add_roots_inner if upper bound (obtained from sbrk) is not upper than DATASTART (e.g., if the latter is set to DATAEND on GC_no_dls). --- diff --git a/os_dep.c b/os_dep.c index c495ff0d..5f44f722 100644 --- a/os_dep.c +++ b/os_dep.c @@ -461,12 +461,6 @@ GC_INNER char * GC_get_maps(void) GC_INNER void GC_init_linux_data_start(void) { - if (GC_no_dls) { - /* Not needed, avoids the SIGSEGV caused by */ - /* GC_find_limit which complicates debugging. */ - return; - } - # if defined(LINUX) || defined(HURD) /* Try the easy approaches first: */ if ((ptr_t)__data_start != 0) { @@ -478,6 +472,14 @@ GC_INNER char * GC_get_maps(void) return; } # endif /* LINUX */ + + if (GC_no_dls) { + /* Not needed, avoids the SIGSEGV caused by */ + /* GC_find_limit which complicates debugging. */ + GC_data_start = (ptr_t)_end; /* set data root size to 0 */ + return; + } + GC_data_start = GC_find_limit((ptr_t)(_end), FALSE); } #endif /* SEARCH_FOR_DATA_START */ @@ -1951,7 +1953,11 @@ void GC_register_data_segments(void) extern caddr_t sbrk(int); GC_ASSERT(DATASTART); - GC_add_roots_inner(DATASTART, (ptr_t)sbrk(0), FALSE); + { + ptr_t p = (ptr_t)sbrk(0); + if (DATASTART < p) + GC_add_roots_inner(DATASTART, p, FALSE); + } # else GC_ASSERT(DATASTART); GC_add_roots_inner(DATASTART, (ptr_t)(DATAEND), FALSE);