Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18088,12 +18088,12 @@ uint8_t* gc_heap::find_object (uint8_t* interior)
{
// this is a pointer to a UOH object
heap_segment* seg = find_segment (interior, FALSE);
if (seg
if (seg)
{
#ifdef FEATURE_CONSERVATIVE_GC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this effects the path we take here in the default CoreCLR config. CoreCLR has FEATURE_CONSERVATIVE_GC defined and GCConfig::GetConservativeGC defaults to false.

It means that this was effectively if (seg && interior <= heap_segment_allocated(seg)) before this change in the default CoreCLR config, and it is just if (seg) after this change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these checks for GetConservativeGC seem suspicious to me - I dunno who added them but the impl seems questionable... the idea, if I had to guess, was probably that if we are in conservative mode (ie the config is set), we can tolerate an interior pointer that's > heap_segment_allocated but all we do is we return 0 there - the only case where we could return a non zero value is if an interior pointer is >= heap_segment_mem and < heap_segment_allocated, regardless of whether the conservative config is set. so the code should just be

        if (seg && (interior < heap_segment_allocated(seg))
        {

and the assert can be deleted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to be more complete, we could do

#ifdef FEATURE_CONSERVATIVE_GC
            if (interior >= heap_segment_allocated (seg))
                return 0;
#else
            assert (interior < heap_segment_allocated (seg));
#endif

meaning that if we find a valid seg for it, we tolerate it if conservative config is set and inteiror is > heap_segment_allocated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments. I believe I have updated as per the last comment. I tried the Wasm Generics test in a loop 100 times and it completed without errors, so this fix looks good for CoreRT/Wasm. I'm sure you experts will advise if I have it wrong.

&& (GCConfig::GetConservativeGC() || interior <= heap_segment_allocated(seg))
if (interior >= heap_segment_allocated(seg))
return 0;
#endif
)
{
// If interior falls within the first free object at the beginning of a generation,
// we don't have brick entry for it, and we may incorrectly treat it as on large object heap.
int align_const = get_alignment_constant (heap_segment_read_only_p (seg)
Expand Down