Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix IsBlittableType #27436

Merged
merged 2 commits into from
Oct 28, 2019
Merged

Conversation

MichalStrehovsky
Copy link
Member

The implementation of IsBlittableType was an incomplete temporary crutch. It only did the right thing for the straightforward cases.

  • Implement similar logic to what CoreCLR does (iterate over fields and check how they're marshalled)
  • MetadataType::GetFieldMarshalAsDescriptors() was a weird API (the returned array was including static fields, making this awkward to use). Every single use of this API on the CoreRT side is wrong because of that. Deleting that and replacing with an API on the field.
  • Do not throw from GetMarshallerKind since we're using it from places that don't want to deal with that.
  • Move MarshalUtils to the project that can access GetMarshallerKind.

The implementation of `IsBlittableType` was an incomplete temporary crutch. It only did the right thing for the straightforward cases.

* Implement similar logic to what CoreCLR does (iterate over fields and check how they're marshalled)
* `MetadataType::GetFieldMarshalAsDescriptors()` was a weird API (the returned array was including static fields, making this awkward to use). Every single use of this API on the CoreRT side is wrong because of that. Deleting that and replacing with an API on the field.
* Do not throw from `GetMarshallerKind` since we're using it from places that don't want to deal with that.
* Move `MarshalUtils` to the project that can access `GetMarshallerKind`.
@MichalStrehovsky
Copy link
Member Author

Cc @sergiy-k

@jkotas
Copy link
Member

jkotas commented Oct 26, 2019

Infrastructure problems:

F:/workspace/_work/1/s/src/dlls/mscoree/mscorwks_ntdef.src : fatal error C1083: Cannot open compiler generated file: 'F:/workspace/_work/1/s/bin/obj/Windows_NT.x86.Debug/src/dlls/mscoree/coreclr/coreclr.def': Permission denied [F:\workspace\_work\1\s\bin\obj\Windows_NT.x86.Debug\src\dlls\mscoree\coreclr\coreclr_static.vcxproj]

@jkotas
Copy link
Member

jkotas commented Oct 26, 2019

/azp run coreclr-ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member

jkotas commented Oct 26, 2019

CoreFX test failures look like some infrastructure problem with the single-exe branch.

@MichalStrehovsky
Copy link
Member Author

CoreFX test failures look like some infrastructure problem with the single-exe branch.

Yeah, I've been ignoring them in my pull requests. Crossgen2 is not involved in what CoreFX tests are testing and I'm pretty close to moving my stuff into master ("no IL stubs" is the last thing that I'm working on now).

@MichalStrehovsky MichalStrehovsky merged commit 3354eeb into dotnet:single-exe Oct 28, 2019
@MichalStrehovsky MichalStrehovsky deleted the blittable branch October 28, 2019 11:40
janvorli added a commit to janvorli/coreclr that referenced this pull request Nov 7, 2019
* Enable precompilation of marshalling IL stubs in crossgen2 dotnet#26767
* P/invoke pregeneration fixes dotnet#27389
* Fixes to array marshalling pregeneration dotnet#27425
* Fix IsBlittableType dotnet#27436
janvorli added a commit that referenced this pull request Nov 7, 2019
* Port set of changes from single-exe branch

* Enable precompilation of marshalling IL stubs in crossgen2 #26767
* P/invoke pregeneration fixes #27389
* Fixes to array marshalling pregeneration #27425
* Fix IsBlittableType #27436

* Fix stack overflow issue and m_alignpad==0 assert

I've found that the changes from single-exe had issues - it was causing
stack overflow during compilation of a couple of runtime assemblies.
After I've fixed that, there was about 15 tests failing at runtime failing
with assert failure: m_alignpad == 0. This is a well known indication of a
problem where JIT and crossgen get different field offsets, resulting in
writing beyond the end of an object.
The problem was caused by incorrect usage of sequential layout for class
without LayoutSequential attribute.
I've added a commit with fix for those to this PR.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants