dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.36k stars 9.99k forks source link

[WebToolsE2E][ARM64]Failed to run .exe file with error "System.AccessViolationException: Attempted to read or write protected memory" from publish folder after publishing .NET 8.0 project against self-contained with single file #54899

Open Serena01 opened 6 months ago

Serena01 commented 6 months ago

Is there an existing issue for this?

Describe the bug

Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2014650

Testcases Affected This issue was found via Exploratory Testing, no test case was affected.

Platform

INSTALL STEPS

  1. Clean machine: A clean ARM64 virtual machine
  2. Install the latest March Servicing SDK 8.0.203(runtime 8.0.3) from https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.203-windows-arm64-installer

Repro Steps

  1. Open command prompt->Create a folder named as "Web01" with command mkdir Web01
  2. Navigate Web01 folder ->Create ASP.NET Core Web App(Razor Pages) with command dotnet new razor -f net8.0
  3. Run the project with command dotnet build
  4. Publish to folder against self-contained with single file with command dotnet publish -c Release -r win-arm64 --self-contained true -p:PublishSingleFile=true
  5. Double click the .exe file from publish path "...\Web01\bin\Release\net8.0\win-arm64\publish\" when finish running publish command.

Note:

  1. The issue also reproduce from VS with UI.
  2. The issue only reproduce on NET 8.0, cannot reproduce on Net6.0/7.0
  3. The issue also reproduce on February servicing SDK 8.0 and April Servicing 8.0, so it is not a regression issue.
  4. The issue only reproduce on Net 8.0 publish to folder against self-contained with single file, cannot reproduce publish to folder against self-contained.
  5. This issue cannot reproduce on x64 machines, only reproduce on arm64 machines.

ACTUAL Failed to run .exe file as following image

Error messages: Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Microsoft.AspNetCore.Mvc.ApplicationModels.AuthorizationApplicationModelProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelProviderContext) at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(System.Collections.Generic.IEnumerable1<System.Reflection.TypeInfo>) at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors() at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptorProviderContext) at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize() at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken() at Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration1[[System.Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(System.Func1<Microsoft.Extensions.Primitives.IChangeToken>, System.Action1<System.Canon>, System.__Canon) at Microsoft.Extensions.Primitives.ChangeToken.OnChange(System.Func`1, System.Action) at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe() at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.GetOrCreateDataSource(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder) at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.MapRazorPages(Microsoft.AspNetCore.Routing.IEndpointRouteBuilder) at Program.

$(System.String[])

EXPECTED .exe file should run successfully. image

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

v-hozha1 commented 3 months ago

We also encounter this issue when executing "dotnet new mstest" on Win ARM.

image

dotnet --info image

MonkSoul commented 3 months ago

same problems:

image