-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 S.R.CS.Unsafe and Intrinsify Unsafe #64861
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsCloses #45475
|
src/coreclr/nativeaot/Runtime.Base/src/Internal/Runtime/CompilerServices/Unsafe.cs
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/Unsafe.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerServices/Unsafe.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices Issue DetailsCloses #45475
|
0dca7a9
to
3abd74f
Compare
I don't understand how the main errors that i'm seeing in the CI are being caused. they are:
I changed the dll import generator to remove the Internal vs System choice but that shouldn't cause any functional change to how it works. Does anyone have any ideas? |
|
I think that the problem with generated imports is coming from this: // TODO: Remove once helper types (like ArrayMarshaller) are part of the runtime
// This check is to help with enabling the source generator for runtime libraries without making each
// library directly reference System.Memory and System.Runtime.CompilerServices.Unsafe unless it needs to
if (p.MarshallingAttributeInfo is MissingSupportMarshallingInfo
&& (environment.TargetFramework == TargetFramework.Net && environment.TargetFrameworkVersion.Major >= 7))
{
throw new MarshallingNotSupportedException(p, this);
} |
@@ -64,6 +64,7 @@ | |||
<type fullname="System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1"> | |||
<property name="ObjectIdForDebugger" /> | |||
</type> | |||
<type fullname="System.Runtime.CompilerServices.Unsafe" preserve="all" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right. Why is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See: #64861 (comment)
While debugging the trimming test failures i realised that there was a possible problem in trimmed scenarios. When resolving any unsafe method in the jit it walks along a list of if-else conditions one for each intrinsic and until it finds a match it will fetch the method description for the intrinsic to check against, if the intrinsic it's checking against has been trimmed out then the method description won't be found and it'll fail with an AV/segfault. Essentially any trimmed unsafe method could cause resolution of one which is still present to fail depending on their order of checks in the jit code. There are two ways to fix this that I can see. The simple one is to add an ILLInk preservation element so that unsafe is never trimmed. The second would be to change the intrinsic lookup to use a function which can early exit if the lookup doesn't produce a result and then use that everywhere. For now I've gone with the illink route but I would consider the other way cleaner. |
All types and methods in corelib.h are preserved via auto-generated ILLink descriptor. You do not need to pin them manually. The auto-generated ILLink desctriptor is only used for CoreCLR w/JIT. It is not used for NativeAOT and Mono since they are able to deal with the type completely missing just fine. If you add this type to the shared ILLink descriptor, the type will be always preserved on all runtime, and so it will produce unnecessary waste on NativeAOT and Mono. |
f624051
to
9095fcd
Compare
Ok. Removed from the commit. |
Libraries build failures are net6.0 target libraries, e.g.: They'll need changing so they know to pick up the correct location for Unsafe, I'm guessing @ericstj is the person to ask on this one? |
Take a look how System.Memory is referenced in System.Collections.Immutable. S.R.CS.Unsafe needs to use the same pattern. |
Could you please also change SystemRuntimeCompilerServicesUnsafeVersion in |
489b368
to
9ddb724
Compare
Done. Also rebased to clear the error caused by number formatting's new use of unsafe. |
Not sure what to do with this one. The S.R.CS.Unsafe package is already being referenced directly from the projects that are getting the error. I considered changing System.Text.Json to force the 6.0.0 version but that would prevent them using any newer unsafe methods and they are a likely place to need them for perf. |
Thanks for all the help with this, especially @BrzVlad for supplying the mono intrinsics that I wasn't able to write. |
My expectation is that most of these are due to PGO data becoming stale due to the move of these types into S.P.Corelib. There wasn't really any major changes to the IL used here and if those minor changes are impacting perf then that's likely a separate issue to look at. |
Arm64 regression in dotnet/perf-autofiling-issues#3693 |
The file was deleted in dotnet/runtime#64861
Added When you commit this breaking change:
Tagging @dotnet/compat for awareness of the breaking change. |
I just added the |
What is the breaking change? |
The relevant section from the announcement issue that was posted with .NET 6:
Apparently removing a shipping package which shipped in a previous .NET version is considered announcement worthy. In the past the breaking-change label was used to track such removals even though the change itself isn't breaking. #36707 removed a package and @eerhardt added the |
@Wraith2 There is a dependency on this package in aspnetcore that needs removing from dependency tracking: https://github.com/dotnet/aspnetcore/blob/main/eng/Version.Details.xml#L216-L219 and https://github.com/dotnet/aspnetcore/blob/main/eng/Versions.props#L116 |
Done: dotnet/aspnetcore#40471 |
Seems this change is causing multiple issues in Winforms with 7.0 P3. Bug 1495179: Intellitrace PDQ's cause hang in VS on .NET 7 Bug 1495188: VIL Does not Hook System.Runtime.CompilerServices.Unsafe.* on NET 7 |
I can't see the bugs on the internal tracker. What is the causal link between these bugs and moving of unsafe inbox? |
All issues you have linked look like dups of the same underlying issue in the VS VIL interpreter. @tommcdon Anything we can do to prioritize the fix?
The VS debugger has hardcoded assumptions about System.Private.CoreLib internal implementation details. It sometimes breaks when the CoreLib internal implementation details change in a substantial way. |
I'll work with the appropriate folks to prioritize the fix. |
@dotnet/area-system-runtime-compilerservices can you please help by filing a breaking change document? |
[Triage] I'll take care of the breaking change document for this. |
Closes #45475