Skip to content

Fix the gc layout algorithm to not double count byref #814

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

Merged
merged 2 commits into from
Dec 13, 2019

Conversation

cshung
Copy link
Contributor

@cshung cshung commented Dec 12, 2019

This pull request is intended to fix the crossgen2 compilation crash of SlowTailCallArgs.csproj.

The compilation failure was found by @janvorli by running all the CoreCLR Pri 1 test on Linux under crossgen2 using SuperIlc.

This bug repro consistently on both debug and release compilation using crossgen2 on Linux only.

The symptom is that when we generate code that put an instance of TestByRefStruct on the stack, we hit an assertion in the code generator here:

assert(numGCSlotsCopied == layout->GetGCPtrCount());

With some digging, I figured there is a bug in the GC layout algorithm. If a struct happens to contain two instances of ByReferenceOfT or TypedReference placed in the same location using ExplicitLayout, the existing code would have double-counted it.

The obvious fix is to avoid double-counting, and that is what the code change does.

@dotnet/crossgen-contrib

@cshung cshung force-pushed the dev/andrewau/fix-gc-layout-algorithm branch from b6612bf to ae588eb Compare December 12, 2019 23:34
@cshung cshung force-pushed the dev/andrewau/fix-gc-layout-algorithm branch from ae588eb to a092ae9 Compare December 12, 2019 23:35
@cshung cshung changed the title [WIP] Fix the gc layout algorithm to not double count byref Fix the gc layout algorithm to not double count byref Dec 12, 2019
@cshung cshung merged commit 6662a0f into dotnet:master Dec 13, 2019
@cshung cshung deleted the dev/andrewau/fix-gc-layout-algorithm branch December 13, 2019 03:22
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 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.

3 participants