dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 385 forks source link

Visual Studio hangs and then crashes when opening a solution with a circular package graph #3374

Closed davkean closed 6 years ago

davkean commented 6 years ago

Feedback items: https://developercommunity.visualstudio.com/content/problem/103063/visual-studio-hangs-and-crashes-after-opening-solu.html https://developercommunity.visualstudio.com/content/problem/210330/opening-a-large-solution-in-vs-causes-it-to-crash.html

  1. Add feed to: https://dotnet.myget.org/feed/dotnet-core/
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.IO.Pipelines" Version="4.5.0-preview2-26312-02" />
  </ItemGroup>

</Project>
  1. Change netstandard2.0-> netstandard1.3

clr!COMNlsHashProvider::HashiStringKnownLower80
clr!COMNlsInfo::InternalGetCaseInsHash
mscorlib_ni!System.Globalization.TextInfo.GetCaseInsensitiveHashCode(System.String, Boolean, Int64)
mscorlib_ni!System.OrdinalComparer.GetHashCode(System.String)
mscorlib_ni!System.Collections.Generic.Dictionary`2[[System.Guid, mscorlib],[System.__Canon, mscorlib]].FindEntry(System.Guid)
mscorlib_ni!System.Collections.Generic.Dictionary`2[[System.Guid, mscorlib],[System.__Canon, mscorlib]].TryGetValue(System.Guid, System.__Canon ByRef)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.GetDependencyChildren(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
Microsoft_VisualStudio_ProjectSystem_Managed_VS!Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.TargetedDependenciesSnapshot.FindUnresolvedDependenciesRecursive(Microsoft.VisualStudio.ProjectSystem.VS.Tree.Dependencies.Snapshot.IDependency)
davkean commented 6 years ago

This has the following hits:

Source Application Version Hits
Watson devenv.exe 15.6.27413.0 4
Watson devenv.exe 15.6.27205.2004 8
Watson devenv.exe 15.0.27130.2024 15
Watson devenv.exe 15.0.27130.2010 52
Watson devenv.exe 15.0.27004.2005 38
davkean commented 6 years ago

This looks to be caused by a circular dependency in the "System.Runtime.CompilerServices.Unsafe (4.5.0-preview2-26312-02) (.NETStandard,Version=v1.3/System.Runtime.CompilerServices.Unsafe/4.5.0-preview2-26312-02)" package, it looks like it indirectly depends on itself:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata minClientVersion="2.12">
    <id>System.Runtime.CompilerServices.Unsafe</id>
    <version>4.5.0-preview2-26312-02</version>
    <title>System.Runtime.CompilerServices.Unsafe</title>
    <authors>Microsoft</authors>
    <owners>microsoft,dotnetframework</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>https://github.com/dotnet/corefx/blob/master/LICENSE.TXT</licenseUrl>
    <projectUrl>https://dot.net/</projectUrl>
    <iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
    <description>Provides the System.Runtime.CompilerServices.Unsafe class, which provides generic, low-level functionality for manipulating pointers.

Commonly Used Types:
System.Runtime.CompilerServices.Unsafe

f1f3b3f8af21c0f782f7f0699d505a0cdb9026ba 
When using NuGet 3.x this package requires at least version 3.4.</description>
    <releaseNotes>https://go.microsoft.com/fwlink/?LinkID=799421</releaseNotes>
    <copyright>© Microsoft Corporation.  All rights reserved.</copyright>
    <serviceable>true</serviceable>
    <dependencies>
      <group targetFramework=".NETFramework4.5" />
      <group targetFramework=".NETStandard1.0">
        <dependency id="NETStandard.Library" version="1.6.1" />
      </group>
      <group targetFramework=".NETStandard2.0" />
      <group targetFramework=".NETPortable4.5-Profile259" />
      <group targetFramework="Windows8.0" />
      <group targetFramework="WindowsPhone8.0" />
      <group targetFramework="WindowsPhoneApp8.1" />
    </dependencies>
  </metadata>
</package>

We should fix the code to not crash in this case.

davkean commented 6 years ago

@etbyrd This is a good one for you to pick up and take for 15.7.

davkean commented 6 years ago

I've made .NET aware that this circular dependency exists.

davkean commented 6 years ago

~Strike above, the issue System.Threading.Tasks.Extensions:~

The issue is System.Xml.ReaderWriter:

"NETStandard.Library (1.6.1) (NETStandard.Library)" -> 
"System.Xml.ReaderWriter (4.3.0) (.NETStandard,Version=v1.3/System.Xml.ReaderWriter/4.3.0)" ->
"System.Threading.Tasks.Extensions (4.5.0-preview2-26312-02) (.NETStandard,Version=v1.3/System.Threading.Tasks.Extensions/4.5.0-preview2-26312-02)" -> 
"System.Runtime.CompilerServices.Unsafe (4.5.0-preview2-26312-02) (.NETStandard,Version=v1.3/System.Runtime.CompilerServices.Unsafe/4.5.0-preview2-26312-02)" ->
"NETStandard.Library (1.6.1) (NETStandard.Library)" 

It depends on Tasks.Extensions, which depends on Unsafe, which depends on NETStandard.Library, which depends on ReaderWriter, which depends on Extensions and so on.

ivanbasov commented 6 years ago

The corresponding VSO issue was moved to 15.8 due to small number of issues in recent version. Moving this one to 15.8 as well

etbyrd commented 6 years ago

Fixed in https://github.com/dotnet/project-system/pull/3474