-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Make DangerousGetPinnableReference internal and remove DangerousTryGetArray #15557
Conversation
@@ -128,7 +128,7 @@ internal ReadOnlySpan(ref T ptr, int length) | |||
/// </summary> | |||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |||
[EditorBrowsable(EditorBrowsableState.Never)] | |||
public ref T DangerousGetPinnableReference() | |||
internal ref readonly T DangerousGetPinnableReference() | |||
{ | |||
return ref _pointer.Value; |
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.
We will also want to change this to return null for empty Spans, and maybe rename it to GetPinnableReference. It can wait for future change that makes it public again.
@dotnet-bot test this please |
@dotnet-bot test this please |
1 similar comment
@dotnet-bot test this please |
@ahsonkhan This change seems to have broken our PGO count collection scenario in the dotnet/optimization repository on Linux. In this scenario, we build coreclr/clrjit with the pgoinstrument flag, and then copy coreclr, clrjit, and System.Private.Corelib.dll into a dotnet cli install that we have pulled down before running scenarios. After this change, when we try to do a dotnet restore, we get the following failure:
Do you have any idea why we would be seeing this? |
@adiaaida, there is likely a version mismatch somewhere in the set of things that are being pulled down resulting in this method being called when it shouldn't. Unfortunately, I am OOF atm, and will be able to look into this issue until next week. It is possible that I didn't replace all calls to (the now hidden) DangerousGetPinnableReference with MemoryMarshal.GetReference. Although, I couldn't find any such uses in the coreclr repo.
Which repo is this? If it is still using DangerousGetPinnableReference somewhere, that needs to be replaced. |
The repo itself doesn't actually use this. What we do is we run the cli's dotnet-install.sh script to pull down dotnet, build a private build of coreclr with pgo instrument then copy over the coreclr, clrjit and system.private.corelib bits into the dotnet install we pulled down using the script. We then run dotnet new console and dotnet restore, which is what fails with this error. I wonder if what we are pulling down from myget is stale in comparison to the system.private.corelib bits (like maybe we haven't been pushing new bits since you checked in this change), since without the copying of bits, we get:
|
@adiaaida, can you still repro this issue? |
No. It looks like things worked themselves out. |
Fixes:
https://github.com/dotnet/corefx/issues/25412
https://github.com/dotnet/corefx/issues/25615
Also fixes https://github.com/dotnet/corefx/issues/23881
Blocked until all uses of DangerousGetPinnableReference and DangerousTryGetArray are replaced with MemoryMarshal APIs (in progress).
Related corefx PR: dotnet/corefx#25964
Following the staging plan from here: https://github.com/dotnet/corefx/issues/23881#issuecomment-343767740
Doing it this way will avoid the need for complex staging or things being on the floor for extensive periods of time.
cc @jkotas, @stephentoub, @KrzysztofCwalina, @davidfowl