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

Remove the sealed blittable layoutclass correctness fix because of backcompat. #54235

Merged
merged 1 commit into from
Jun 16, 2021

Conversation

jkoritzinsky
Copy link
Member

We can't do the correct thing and ensure we marshal blittable layout classes correctly in subclass situations due to backcompat issues, so remove that correctness check and add a massive comment block explaining why we can't so we don't accidentally regress this again.

Fixes #54132

Fixes #53542

@jkoritzinsky
Copy link
Member Author

@jkotas let me know if you want me to start a backport request for this for .NET 5.

@@ -2496,10 +2496,14 @@ void ILBlittablePtrMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* pslIL

bool ILBlittablePtrMarshaler::CanMarshalViaPinning()
{
// [COMPAT] For correctness, we can't marshal via pinning if we might need to marshal differently at runtime.
// See calls to EmitExactTypeCheck where we check the runtime type of the object being marshalled.
Copy link
Member

Choose a reason for hiding this comment

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

Just to understand the history: Was the EmitExactTypeCheck check added for better compatibility with .NET Framework, or was it added as attempt to fix a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was added as an attempt to fix a compat issue from the StructMarshal IL stubs work. The old struct/class marshalling used the runtime type of a given type to determine how to marshal, not the metadata type. The Struct Marshalling IL Stubs initially used the metadata type. The type check was to bring back compat with the runtime type check because some customers were using it to map a native discriminated union to managed.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Based on some of the discussion on the issue I think we should service 5.0 for this.

@jkotas
Copy link
Member

jkotas commented Jun 15, 2021

Based on some of the discussion on the issue I think we should service 5.0 for this.

Agree.

@jkoritzinsky jkoritzinsky merged commit ccc3d9f into dotnet:main Jun 16, 2021
@jkoritzinsky jkoritzinsky deleted the layoutclass-blittable branch June 16, 2021 20:55
trylek added a commit to trylek/runtime that referenced this pull request Jun 22, 2021
trylek added a commit that referenced this pull request Jun 23, 2021
thaystg added a commit to thaystg/runtime that referenced this pull request Jun 23, 2021
…nitial_config

* origin/main: (362 commits)
  [wasm][debugger] Reuse debugger-agent on wasm debugger (dotnet#52300)
  Put Crossgen2 in sync with dotnet#54235 (dotnet#54438)
  Move System.Object serialization to ObjectConverter (dotnet#54436)
  Move setting fHasVirtualStaticMethods out of sanity check section (dotnet#54574)
  [wasm] Compile .bc->.o in parallel, before passing to the linker (dotnet#54053)
  Change PathInternal.IsCaseSensitive to a constant (dotnet#54340)
  Make mono_polling_required a public symbol (dotnet#54592)
  Respect EventSource::IsSupported setting in more codepaths (dotnet#51977)
  Root ComActivator for hosting (dotnet#54524)
  Add ILLink annotations to S.D.Common related to DbConnectionStringBuilder (dotnet#54280)
  Fix finalizer issue with regions (dotnet#54550)
  Add support for multi-arch install locations (dotnet#53763)
  Update library testing docs page to reduce confusion (dotnet#54324)
  [FileStream] handle UNC and device paths (dotnet#54483)
  Update NetAnalyzers version (dotnet#54511)
  Added runtime dependency to fix the intermittent test failures (dotnet#54587)
  Disable failing System.Reflection.Tests.ModuleTests.GetMethods (dotnet#54564)
  [wasm] Move AOT builds from `runtime-staging` to `runtime` (dotnet#54577)
  Keep obj node for ArrayIndex. (dotnet#54584)
  Disable another failing MemoryCache test (dotnet#54578)
  ...
thaystg added a commit to thaystg/runtime that referenced this pull request Jun 24, 2021
…bugger2

* origin/main: (107 commits)
  Disable MacCatalyst arm64 PR test runs on staging pipeline (dotnet#54678)
  [WASM] Fix async/await in config loading (dotnet#54652)
  Fix for heap_use_after_free flagged by sanitizer (dotnet#54679)
  [wasm] Bump emscripten to 2.0.23 (dotnet#53603)
  Fix compiler references when building inside VS (dotnet#54614)
  process more TLS frames at one when available (dotnet#50815)
  Add PeriodicTimer (dotnet#53899)
  UdpClient with span support (dotnet#53429)
  exclude fragile tests (dotnet#54671)
  get last error before calling a method that might fail as well (dotnet#54667)
  [FileStream] add tests for device and UNC paths (dotnet#54545)
  Fix sporadic double fd close (dotnet#54660)
  Remove Version.Clone from AssemblyName.Clone (dotnet#54621)
  [wasm] Enable fixed libraries tests (dotnet#54641)
  [wasm] Fix blazor/aot builds (dotnet#54651)
  [mono][wasm] Fix compilation error on wasm (dotnet#54659)
  Fix telemetry for Socket connects to Dns endpoints (dotnet#54071)
  [wasm] Build static components; include hot_reload in runtime (dotnet#54568)
  [wasm][debugger] Reuse debugger-agent on wasm debugger (dotnet#52300)
  Put Crossgen2 in sync with dotnet#54235 (dotnet#54438)
  ...
@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants