diff --git a/vm/bump_allocator.hpp b/vm/bump_allocator.hpp index 12c4453b63..5e8f3544df 100644 --- a/vm/bump_allocator.hpp +++ b/vm/bump_allocator.hpp @@ -36,6 +36,16 @@ template struct bump_allocator { else return 0; } + + void flush() { + here = start; +#ifdef FACTOR_DEBUG + /* In case of bugs, there may be bogus references pointing to the + memory space after the gc has run. Filling it with a pattern + makes accesses to such shadow data fail hard. */ + memset_cell((void*)start, 0xbaadbaad, size); +#endif + } }; } diff --git a/vm/data_heap.cpp b/vm/data_heap.cpp index 5a5af548fa..89d1c4c8d0 100644 --- a/vm/data_heap.cpp +++ b/vm/data_heap.cpp @@ -68,10 +68,12 @@ template void data_heap::clear_decks(Generation* gen) { memset(&decks[first_deck], 0, last_deck - first_deck); } -void data_heap::reset_generation(nursery_space* gen) { gen->here = gen->start; } +void data_heap::reset_generation(nursery_space* gen) { + gen->flush(); +} void data_heap::reset_generation(aging_space* gen) { - gen->here = gen->start; + gen->flush(); clear_cards(gen); clear_decks(gen); gen->starts.clear_object_start_offsets();