-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix GC holes in array marshallers in the field scenario #27562
Fix GC holes in array marshallers in the field scenario #27562
Conversation
…ed by IL marshalers in the field scenarios. Use RuntimeHelpers.GetRawData to simplify layout class marshalling.
|
@jkoritzinsky Is there a test we can add that would have caught this issue when running under GC stress? |
|
Well the two fixed-array marshalling test projects did catch this under GCStress. That's what #27496 and #27491 are from. This might not show up on tier0 code since (at least the specific failure in #27496) only shows up when the gcinfo for an object is as strict (shortest lifetime) as possible. |
|
I initially missed this since I copied the pattern of the array marshalers from the ones already in the code base and didn't realize that the differences in the scenario (param/retval vs field) were enough to possibly cause GC holes. |
|
@trylek I can't run the GCStress pipeline to validate this in CI. I'm getting the error:
Looks like your recent changes to the pipeline may have broken the jobs that don't include an OSX leg. |
|
Hmm, that's unfortunate, apologies about that. I think this should be fixable by tweaking the conditions in platform-matrix - it's true that with my change any Linux test execution looks for managed tests components built on OSX. I have a meeting in 5 minutes, I'll look into fixing that right after we finish. Is this the gcstress-extra pipeline where you're hitting this? I definitely need to know how to test the fix. |
|
@trylek It's the gcstress_0x3_0xc pipeline. |
|
|
I'll take a look when I get into the office tomorrow. |
…tect-fixed-array-marshaler
|
Failures in the GCStress pipeline are due to the following issues:
|
Correctly protect references to objects in manually-managed code called by the array IL marshalers in the field scenarios. Unlike the non-field scenarios where the "managed home" address is a local variable on the stack, the "managed home" address for field scenarios is a byref into the managed object. If the managed object is a layout-class, it can be relocated/collected.
Also, use RuntimeHelpers.GetRawData to simplify layout class marshalling and reduce weird IL patterns in the marshalers when there are C# methods with better readability that we can reuse.
Fixes #27496
Fixes #27491
Fixes dotnet/corefx#42201