Doubly linked freelist fixes (#43636)
authorPeter Sollich <petersol@microsoft.com>
Wed, 4 Nov 2020 09:02:04 +0000 (10:02 +0100)
committerGitHub <noreply@github.com>
Wed, 4 Nov 2020 09:02:04 +0000 (10:02 +0100)
commit86f14a294a05effd84b560c4fabff7a86f34ca81
treeae4a9d9b5bc1005d66e03079da6a18d4aac5160b
parentfd78d434d22efeb52e6c03711b0fd7127d95fb3f
Doubly linked freelist fixes (#43636)

* Fix bugs in the doubly linked free list logic and enable it.

Details:

 - #define DOUBLY_LINKED_FL to enable

 - Fix issue in adjust_limit with accidentally setting MAKE_FREE_OBJ_IN_COMPACT bit in the plug_and_gap structure that gets put before a pinned plug - this overwrites any object that used to be there (after it has been saved elsewhere), so added logic to detect the situation and set MAKE_FREE_OBJ_IN_COMPACT in the saved object instead. To make this work, added new field "saved_pinned_plug_index" to remember which pinned plug to look at.

- In connection with the previous issue in adjust_limit, fix case of a 3 pointer size plug in from of a pinned plug - for this we need a range test to catch the case, plus add this offset to the beginning of saved_pre_plug_reloc. On the other hand, 3 pointers is the minimum size object, so added an assert to that effect as suggested in code review.

- Changed several comparisons because an object <= min_free_item_no_prev cannot be on the free list.

- Fixed issue in should_set_bgc_mark_bit where an assert fired because current_sweep_seg was null because the background gc thread was about to sweep, but hadn't set current_sweep_seg just yet. Fix is to set current_sweep_seg and current_sweep_pos early.
src/coreclr/src/gc/gc.cpp
src/coreclr/src/gc/gcpriv.h