dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

Access Violation exception #70038

Open ryanbrandenburg opened 2 years ago

ryanbrandenburg commented 2 years ago

Description

In the Razor Tooling repro we run into an AccessViolation exception when running this test on certain machines.

Reproduction Steps

  1. Clone the razor-tooling repo.
  2. Run .\restore.ps1
  3. Run .\build.cmd
  4. Run C:\Users\rybrande\projects\razor-tooling\src\Razor\test\Microsoft.VisualStudio.LanguageServerClient.Razor.Test
  5. Run dotnet test
  6. If you're on an affected machine you should get an AccessViolation Exception.

Expected behavior

No AccessViolationException.

Actual behavior

AccessViolationException.

Regression?

I did not see this before our recent upgrade to dotnet 7.0.100-preview.4.22252.9, but that could just be a coincidence since I don't run this code often.

Known Workarounds

Not all machines seem to be affected, so using a different machine can work around it.

Configuration

.NET SDK:
 Version:   7.0.100-preview.4.22252.9
 Commit:    6bc31786a8

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-preview.4.22252.9\

global.json file:
  C:\Users\rybrande\projects\razor-tooling\global.json

Host:
  Version:      7.0.0-preview.4.22229.4
  Architecture: x64
  Commit:       9c37a3b3eb

.NET SDKs installed:
  2.1.526 [C:\Program Files\dotnet\sdk]
  3.1.419 [C:\Program Files\dotnet\sdk]
  5.0.301 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.105 [C:\Program Files\dotnet\sdk]
  6.0.300 [C:\Program Files\dotnet\sdk]
  7.0.100-preview.4.22252.9 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.4.22251.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.3.22175.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.4.22229.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.25 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.4.22229.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

Other information

My machine is older (~2019) so reproducing on an older machine might be part of the issue. Seems to happen 100% of the time for me, so producing dumps should be possible provided you tell me how you would prefer them.

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

EgorBo commented 2 years ago

I've just tried to follow the build steps and the very first step (restore) failed with a lot of network-related iisues:

Failed to download package 'Microsoft.VisualStudio.Threading.Analyzers.17.2.32' from 'https://pkgs.dev.azure.com/azur
  e-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/2a239fd0-3e21-40b0-b9d6-bc122fec7eb2/nuget/v3/flat2/microsof
  t.visualstudio.threading.analyzers/17.2.32/microsoft.visualstudio.threading.analyzers.17.2.32.nupkg'.
  An error occurred while sending the request.
    Unable to connect to the remote server
    A connection attempt failed because the connected party did not properly respond after a period of time, or establi
  shed connection failed because connected host has failed to respond 13.107.6.175:443
  Failed to download package 'xunit.assert.2.4.1' from 'https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d
  082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/xunit.assert/2.4.1/xunit.assert.2.4.1.nupkg'.
  An error occurred while sending the request.
    Unable to connect to the remote server
    A connection attempt failed because the connected party did not properly respond after a period of time, or establi
  shed connection failed because connected host has failed to respond 13.107.6.175:443
  Failed to download package 'Microsoft.CodeAnalysis.Remote.ServiceHub.4.3.0-2.22267.5' from 'https://pkgs.dev.azure.co
  m/azure-public/3ccf6661-f8ce-4e8a-bb2e-eff943ddd3c7/_packaging/78665e4c-b767-412b-9804-2b1ef7a48b8a/nuget/v3/flat2/mi
  crosoft.codeanalysis.remote.servicehub/4.3.0-2.22267.5/microsoft.codeanalysis.remote.servicehub.4.3.0-2.22267.5.nupkg
  '.
  An error occurred while sending the request.
    Unable to connect to the remote server
    A connection attempt failed because the connected party did not properly respond after a period of time, or establi
  shed connection failed because connected host has failed to respond 13.107.6.175:443
  Failed to download package 'System.Runtime.CompilerServices.Unsafe.5.0.0' from 'https://pkgs.dev.azure.com/dnceng/9ee
  6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/45bacae2-5efb-47c8-91e5-8ec20c22b4f8/nuget/v3/flat2/system.runtime.compi
  lerservices.unsafe/5.0.0/system.runtime.compilerservices.unsafe.5.0.0.nupkg'.
ryanbrandenburg commented 2 years ago

@EgorBo we saw a bunch of restore issues on our CI yesterday too, would you mind clearing your cache and trying again now that it seems resolved?

EgorBo commented 2 years ago

@EgorBo we saw a bunch of restore issues on our CI yesterday too, would you mind clearing your cache and trying again now that it seems resolved?

Thanks, builds just fine today. Furthermore, I was able to reproduce AVE on my machine

EgorBo commented 2 years ago

@ryanbrandenburg the assembly with the test is net4.7 - not sure I understand how .NET 7.0 is involved here

janvorli commented 2 years ago

@EgorBo do you happen to have stack trace of the AVE? I was trying to repro it locally and the restore step failed to me due to some weird sdk / msbuild version mismatch.

janvorli commented 2 years ago

@ryanbrandenburg I was trying to follow the repro steps, but the restore.cmd fails

F:\issues\70038\razor-tooling\src\Razor\src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj : error : Version 7.0.100-preview.5.
22307.18 of the .NET SDK requires at least version 17.0.0 of MSBuild. The current available version of MSBuild is 16.11.2.50704. Change the .NET SDK specified
in global.json to an older version that requires the MSBuild version currently available.
F:\issues\70038\razor-tooling\src\Razor\src\Microsoft.CodeAnalysis.Remote.Razor\Microsoft.CodeAnalysis.Remote.Razor.csproj : error MSB4236: The SDK 'Microsoft.
NET.Sdk' specified could not be found.
F:\issues\70038\razor-tooling\src\Razor\test\Microsoft.AspNetCore.Razor.Test.MvcShim\Microsoft.AspNetCore.Razor.Test.MvcShim.csproj : error MSB4236: The SDK 'M
icrosoft.NET.Sdk' specified could not be found.
F:\issues\70038\razor-tooling\src\Razor\test\Microsoft.AspNetCore.Razor.Test.Common\Microsoft.AspNetCore.Razor.Test.Common.csproj : error MSB4236: The SDK 'Mic
rosoft.NET.Sdk' specified could not be found.
F:\issues\70038\razor-tooling\src\Razor\src\Microsoft.CodeAnalysis.Razor.Workspaces\Microsoft.CodeAnalysis.Razor.Workspaces.csproj : error MSB4236: The SDK 'Mi
crosoft.NET.Sdk' specified could not be found.

Can you please check what's wrong so that I can try to repro the issue locally?

ryanbrandenburg commented 2 years ago

@janvorli I suggest checking out an old commit of razor-tooling such as https://github.com/dotnet/razor-tooling/commit/e014e91b63399c3b721c10df7c23f2e6d795b4fc from around that time. There were significant changes to the way RazorTooling builds since then and it's likely to be harder for you to build (and also likely doesn't reproduce) on latest commits.

mangod9 commented 2 years ago

@ryanbrandenburg I notice that the repro is from preview4, have you continued to see such failures on latest previews (6 or 7)? We have fixed a few non deterministic failures in various parts of the runtime since then.