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

Avoid BuildHost crash in Mono due to missing types #74392

Closed
wants to merge 1 commit into from

Conversation

uweigand
Copy link
Contributor

@uweigand uweigand commented Jul 15, 2024

The LoadProjectFileAsync routine calls EnsureMSBuildLoaded to make sure the Microsoft.Build.dll is accessible, but requires types from that assembly within the routine itself. This may not always work with Mono, as the JIT may look up the types during compilation.

Fixed by splitting out a LoadProjectFileCoreAsync routine, similarly to what is already done for GetProjectsInSolution.

Fixes dotnet/runtime#101121.

@uweigand uweigand requested a review from a team as a code owner July 15, 2024 18:11
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 15, 2024
@dotnet-policy-service dotnet-policy-service bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Jul 15, 2024
Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

I'm fine with this, but would like @jasonmalinowski to take a look as well.

return LoadProjectFileCoreAsync(projectFilePath, languageName, cancellationToken);
}

[MethodImpl(MethodImplOptions.NoInlining)] // Do not inline this, since this uses MSBuild types which are being loaded by the caller
Copy link
Member

Choose a reason for hiding this comment

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

You may want to make a note that this was mono specific, lest somebody tries to undo this change being confused why it works on other platforms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I've updated the comment now.

@jasonmalinowski
Copy link
Member

I filed #74407 to look at what it'd take to get our tests running on mono to catch issues like this.

The LoadProjectFileAsync routine calls EnsureMSBuildLoaded to make
sure the Microsoft.Build.dll is accessible, but requires types from
that assembly within the routine itself.  This may not always work
with Mono, as the JIT may look up the types during compilation.

Fixed by splitting out a LoadProjectFileCoreAsync routine, similarly
to what is already done for GetProjectsInSolution.

Fixes dotnet/runtime#101121.
@uweigand
Copy link
Contributor Author

Not sure why this is failing now after just a comment change ... seems an infrastructure issue.

omajid added a commit to omajid/dotnet-roslyn that referenced this pull request Jul 24, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like dotnet#74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
omajid added a commit to omajid/dotnet-roslyn that referenced this pull request Jul 24, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like dotnet#74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
omajid added a commit to omajid/dotnet-roslyn that referenced this pull request Jul 24, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like dotnet#74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
omajid added a commit to omajid/dotnet-roslyn that referenced this pull request Jul 26, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like dotnet#74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
omajid added a commit to omajid/dotnet-roslyn that referenced this pull request Jul 26, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like dotnet#74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
333fred pushed a commit that referenced this pull request Jul 29, 2024
I wanted to run the roslyn test suite on Linux on arm64. Building
everything worked, but running tests would fail with errors like:

    Errors Microsoft.CodeAnalysis.CSharp.Emit.UnitTests_1
    Could not find 'dotnet' host for the 'X64' architecture.

    You can resolve the problem by installing the 'X64' .NET.

With the changes in this commit, I can build and run all tests using:

    $ ./eng/build.sh --restore --build --pack
    $ ./eng/build.sh --test

I would, eventually, like to be able to run the tests on other
platforms, including s390x and ppc64le. Hopefully that might help
identify/fix issues like #74392
earlier.

One thing I am not too happy about in this change is how many places
need an explicit addition of "linux-arm64". That won't scale as we want
to add more architectures.
@jaredpar
Copy link
Member

jaredpar commented Sep 4, 2024

/azp run

@jaredpar jaredpar closed this Sep 4, 2024
@jaredpar jaredpar reopened this Sep 4, 2024
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jaredpar
Copy link
Member

jaredpar commented Sep 4, 2024

The test run failed. Think it's still using stale integration test bits. Worry that this PR may be snagged on stale state. I rebased locally, pushed to a new branch and opened a new PR. Hopefully that one will get past these issues #74994.

@jaredpar
Copy link
Member

jaredpar commented Sep 5, 2024

Closing as I got this change to merge in cleanly in #74994.

Sorry for losing track of this.

@jaredpar jaredpar closed this Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dotnet build hangs while building libs.tests natively using cross built dotnet sdk
5 participants