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

Source-build fails to build w/CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type #73850

Closed
MichaelSimons opened this issue Aug 12, 2022 · 12 comments
Assignees
Labels
area-Infrastructure blocking-release source-build Issues relating to dotnet/source-build
Milestone

Comments

@MichaelSimons
Copy link
Member

The latest dependency flow into installer's broke source-build w/the following errors:

  /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs(319,50): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(249,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(254,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(149,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs(146,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(302,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs(507,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]

CI Build Failure (internal Microsoft link)

Source-build does build with the latest compiler version and toolset which is likely a contributing factor here.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 12, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

Issue Details

The latest dependency flow into installer's broke source-build w/the following errors:

  /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs(319,50): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(249,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(254,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(149,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs(146,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(302,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs(507,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]

CI Build Failure (internal Microsoft link)

Source-build does build with the latest compiler version and toolset which is likely a contributing factor here.

Author: MichaelSimons
Assignees: -
Labels:

area-Infrastructure-coreclr

Milestone: -

@MichaelSimons
Copy link
Member Author

This is currently blocking RC1.

@hoyosjs
Copy link
Member

hoyosjs commented Aug 12, 2022

Oof. looks like we're using a roslyn that's not new enough for the bootstrap? cc: @AaronRobinsonMSFT

@hoyosjs hoyosjs added blocking-release and removed untriaged New issue has not been triaged by the area owner labels Aug 12, 2022
@hoyosjs hoyosjs added this to the 7.0.0 milestone Aug 12, 2022
@hoyosjs hoyosjs added area-Infrastructure source-build Issues relating to dotnet/source-build and removed area-Infrastructure-coreclr labels Aug 12, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Issue Details

The latest dependency flow into installer's broke source-build w/the following errors:

  /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs(319,50): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(249,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBase.cs(254,23): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('ByReference') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(149,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs(146,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs(302,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs(507,54): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('MethodBase.StackAllocatedByRefs') [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj]

CI Build Failure (internal Microsoft link)

Source-build does build with the latest compiler version and toolset which is likely a contributing factor here.

Author: MichaelSimons
Assignees: -
Labels:

blocking-release, area-Infrastructure

Milestone: 7.0.0

@AaronRobinsonMSFT
Copy link
Member

Thanks @hoyosjs. The fix for this is in-flight #73466.

@jkotas
Copy link
Member

jkotas commented Aug 12, 2022

This issue was introduced by dotnet/roslyn#63209 . I do not see the fixes for it in #73466 yet.

The problem is that C# disallows taking an address of ref struct that contains ref fields. It is artificial C# limitation that does not exist in IL. It will be pain to workaround it without taking a perf hit. Any chance we can relax the C# rules and allow taking an address of ref structs that contain object references?

@AaronRobinsonMSFT
Copy link
Member

I do not see the fixes for it in #73466 yet.

I know I've discussed this issue with @cston offline. I thought this issue was included in that PR. Let me follow-up offline.

@cston
Copy link
Member

cston commented Aug 12, 2022

For now, we're reverting dotnet/roslyn#63209 to unblock moving to the latest compiler. See dotnet/roslyn#63367.

@MichaelSimons
Copy link
Member Author

MichaelSimons commented Aug 13, 2022

We assembled a source-build run with patches that revert dotnet/roslyn#63209 and pull in the #73466 changes with the very last sdk/roslyn and a new break appeared. You can see the source-build configuration here - dotnet/installer#14319

    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(548,28): error CS8167: Cannot return by reference a member of parameter 'exInfo' because it is not a ref or out parameter [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(548,13): error CS8350: This combination of arguments to 'EH.DispatchEx(ref StackFrameIterator, ref EH.ExInfo, uint)' is disallowed because it may expose variables referenced by parameter 'frameIter' outside of their declaration scope [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(570,28): error CS8167: Cannot return by reference a member of parameter 'exInfo' because it is not a ref or out parameter [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(570,13): error CS8350: This combination of arguments to 'EH.DispatchEx(ref StackFrameIterator, ref EH.ExInfo, uint)' is disallowed because it may expose variables referenced by parameter 'frameIter' outside of their declaration scope [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(587,28): error CS8167: Cannot return by reference a member of parameter 'exInfo' because it is not a ref or out parameter [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
    /tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs(587,13): error CS8350: This combination of arguments to 'EH.DispatchEx(ref StackFrameIterator, ref EH.ExInfo, uint)' is disallowed because it may expose variables referenced by parameter 'frameIter' outside of their declaration scope [/tarball/src/runtime/artifacts/source-build/self/src/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]

I can log a new issue for this if you would like.

@cston
Copy link
Member

cston commented Aug 13, 2022

Sorry for missing the nativeaot case.

I've created #73883 which compiles with build -rc Release without errors - with the exception of tools/dotnet-pgo which fails to compile with the latest compiler because it references .NET preview 5 SDK.

@cston
Copy link
Member

cston commented Aug 15, 2022

dotnet/roslyn#63367 and #73883 have been merged.

@cston cston closed this as completed Aug 15, 2022
@cston
Copy link
Member

cston commented Aug 15, 2022

@jeffschwMSFT, @MichaelSimons, I've closed this issue since the PRs for the two issues have been merged. Please re-open if there is still something blocking here.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure blocking-release source-build Issues relating to dotnet/source-build
Projects
None yet
Development

No branches or pull requests

5 participants