summaryrefslogtreecommitdiff
path: root/mark_rts.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-05-07 11:05:15 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-05-07 11:05:15 +0300
commit38d194a365e2e0cbb88601f380df9b8dbf6b0b1d (patch)
tree4e45b0c0783e7bd1a43ba67e12cb74b7648f980e /mark_rts.c
parent7924905759fe3b259b04ac8f66ee54c9a6498f4f (diff)
downloadbdwgc-38d194a365e2e0cbb88601f380df9b8dbf6b0b1d.tar.gz
Fix infinite restarting of mark_some when a static root disappeared (Linux)
Issue #218 (bdwgc). * dyn_load.c [USE_PROC_FOR_LIBRARIES] (GC_register_map_entries): Call GC_remove_roots_subregion for each region which has prot starting with "---"; add comment. * include/private/gc_priv.h [USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Declare function. * mark_rts.c[USE_PROC_FOR_LIBRARIES] (GC_remove_roots_subregion): Implement.
Diffstat (limited to 'mark_rts.c')
-rw-r--r--mark_rts.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/mark_rts.c b/mark_rts.c
index 1499e457..a179effb 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -372,6 +372,49 @@ STATIC void GC_remove_tmp_roots(void)
}
#endif /* !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) */
+#ifdef USE_PROC_FOR_LIBRARIES
+ /* If there is a static root containing [b,e) then replace this root */
+ /* [r_start,r_end) with roots [r_start,b) and [e,r_end). */
+ /* It is assumed that GC_remove_tmp_roots() is called before this */
+ /* function is called repeatedly by GC_register_map_entries(). */
+ GC_INNER void GC_remove_roots_subregion(ptr_t b, ptr_t e)
+ {
+ int i;
+
+ GC_ASSERT(I_HOLD_LOCK());
+ for (i = 0; i < n_root_sets; i++) {
+ ptr_t r_start, r_end;
+
+ if (GC_static_roots[i].r_tmp) {
+ /* The remaining roots are skipped as they are all temporary. */
+# ifdef GC_ASSERTIONS
+ int j;
+ for (j = i + 1; j < n_root_sets; j++) {
+ GC_ASSERT(GC_static_roots[j].r_tmp);
+ }
+# endif
+ break;
+ }
+ r_start = GC_static_roots[i].r_start;
+ r_end = GC_static_roots[i].r_end;
+ if (EXPECT((word)r_start <= (word)b && (word)e <= (word)r_end, FALSE)) {
+# ifdef DEBUG_ADD_DEL_ROOTS
+ GC_log_printf("Removing %p .. %p from root section %d (%p .. %p)\n",
+ (void *)b, (void *)e,
+ i, (void *)r_start, (void *)r_end);
+# endif
+ GC_remove_root_at_pos(i);
+ GC_rebuild_root_index();
+ if ((word)r_start < (word)b)
+ GC_add_roots_inner(r_start, b, FALSE);
+ if ((word)e < (word)r_end)
+ GC_add_roots_inner(e, r_end, FALSE);
+ break;
+ }
+ }
+ }
+#endif /* USE_PROC_FOR_LIBRARIES */
+
#if !defined(NO_DEBUGGING)
/* For the debugging purpose only. */
/* Workaround for the OS mapping and unmapping behind our back: */