Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negate find_object GetConservativeGC logic. #39905

Merged
merged 3 commits into from
Jul 28, 2020

Conversation

yowl
Copy link
Contributor

@yowl yowl commented Jul 24, 2020

This PR implements the suggested fix at dotnet/corert#8205 that solves an assert that is hit when testing the Wasm backend of CoreRT and is required to fix the related issue dotnet/corert#8210.

Fixes: dotnet/corert#8210
Closes: dotnet/corert#8205

@ghost
Copy link

ghost commented Jul 24, 2020

Tagging subscribers to this area: @dotnet/gc
See info in area-owners.md if you want to be subscribed.

@@ -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.

Comment on lines 18096 to 18097
#else
assert (interior < heap_segment_allocated (seg));
Copy link
Member

@jkotas jkotas Jul 28, 2020

Choose a reason for hiding this comment

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

Suggested change
#else
assert (interior < heap_segment_allocated (seg));

The exact same assert is repeated unconditionally a few lines below. I would delete it here.

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, removed.

@jkotas jkotas merged commit 227757a into dotnet:master Jul 28, 2020
@jkotas
Copy link
Member

jkotas commented Jul 28, 2020

@yowl Thank you!

Jacksondr5 pushed a commit to Jacksondr5/runtime that referenced this pull request Aug 10, 2020
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wasm: Generics test fails if run in a loop Wasm: Question: conservative gc and heap_segment_allocated
5 participants