Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Negate find_object GetConservativeGC logic.
  • Loading branch information
yowl committed Jul 24, 2020
commit 0817d28826614e31ec3bb2fe3bb2a2262c4f08c7
2 changes: 1 addition & 1 deletion src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18090,7 +18090,7 @@ uint8_t* gc_heap::find_object (uint8_t* interior)
heap_segment* seg = find_segment (interior, FALSE);
if (seg
#ifdef FEATURE_CONSERVATIVE_GC
&& (GCConfig::GetConservativeGC() || interior <= heap_segment_allocated(seg))
&& (!GCConfig::GetConservativeGC() || interior <= heap_segment_allocated(seg))
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.

#endif
)
{
Expand Down