From 8eb6f8d93fe7cb922969e47ec343e8dafb5cbb2b Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 23 Jun 2018 00:42:30 +0300 Subject: Add GC_reachable_here after GC_dirty in GC source (fix of commits 73d30d2b4, e5fb574cf) * README.md (Incremental Collection): Add note about bugs caused by a missing GC_reachable_here call. * doc/gcdescr.md (Generational Collection): Mention GC_reachable_here for MANUAL_VDB mode. * finalize.c (GC_register_disappearing_link_inner, GC_register_finalizer_inner): Move GC_dirty(new_dl) call to be before unlocking (so that to ensure no collection occurs between initialization of new_dl and GC_dirty() call). * finalize.c (GC_finalize): Call GC_dirty() immediately after updating GC_fnlz_roots.fo_head (instead of setting needs_barrier) if GC_object_finalized_proc is set. * gcj_mlc.c (GC_gcj_malloc, GC_debug_gcj_malloc, GC_gcj_malloc_ignore_off_page): Call REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr) after GC_dirty(op). * include/gc.h (GC_end_stubborn_change): Mention GC_reachable_here in comment. * include/gc_inline.h (GC_FAST_MALLOC_GRANS): Call GC_reachable_here(next) after GC_end_stubborn_change(my_fl); remove GC_end_stubborn_change() call when a non-pointer is stored to my_fl; remove GC_end_stubborn_change() after GC_generic_malloc_many() call. * include/gc_inline.h (GC_CONS): Call GC_reachable_here for the stored pointers after GC_end_stubborn_change call. * include/private/gc_priv.h (REACHABLE_AFTER_DIRTY): New macro. * mallocx.c [MANUAL_VDB] (GC_generic_malloc_many): If GC_is_heap_ptr(result) then call GC_dirty(result) and REACHABLE_AFTER_DIRTY(op) after storing op pointer. * typd_mlc.c (GC_make_sequence_descriptor): Call REACHABLE_AFTER_DIRTY for the stored pointers after GC_dirty(result). * typd_mlc.c (GC_malloc_explicitly_typed, GC_malloc_explicitly_typed_ignore_off_page, GC_calloc_explicitly_typed): Call REACHABLE_AFTER_DIRTY(d) after GC_dirty(op). * win32_threads.c (GC_CreateThread, GC_beginthreadex, GC_pthread_create): Call REACHABLE_AFTER_DIRTY for the stored pointer after GC_dirty. --- gcj_mlc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcj_mlc.c') diff --git a/gcj_mlc.c b/gcj_mlc.c index 14d3813d..56d940fe 100644 --- a/gcj_mlc.c +++ b/gcj_mlc.c @@ -194,7 +194,8 @@ static void maybe_finalize(void) *(void **)op = ptr_to_struct_containing_descr; UNLOCK(); GC_dirty(op); - return((void *) op); + REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr); + return (void *)op; } /* Similar to GC_gcj_malloc, but add debug info. This is allocated */ @@ -226,6 +227,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_debug_gcj_malloc(size_t lb, result = GC_store_debug_info_inner(result, (word)lb, s, i); UNLOCK(); GC_dirty(result); + REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr); return result; } @@ -268,7 +270,8 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_gcj_malloc_ignore_off_page(size_t lb, *(void **)op = ptr_to_struct_containing_descr; UNLOCK(); GC_dirty(op); - return((void *) op); + REACHABLE_AFTER_DIRTY(ptr_to_struct_containing_descr); + return (void *)op; } #endif /* GC_GCJ_SUPPORT */ -- cgit v1.2.1