dotnet / runtime

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

Memory violation/corruption error with sdk7 docker image on M1 MAC #81232

Closed erdembayar closed 1 year ago

erdembayar commented 1 year ago

Description

This problem is regression with sdk7.0 from sdk6.0, everything works as expected on sdk 6.0. I see memory violation/corruption error in stack trace and it looks like an issue in the runtime: see System.Net.Security.AsyncReadWriteAdapter in stacktrace, can see previous similar issues https://github.com/dotnet/runtime/issues/70656, https://github.com/dotnet/runtime/issues/58349.

NuGet side issue #12329, see comment. Considering this issue repro with dotnew new list command, I believe this is not NuGet issue, because it doesn’t involve any NuGet operation.

Reproduction Steps

Need M1 MAC machine.

  1. Extract this erickTest.zip, it has dotnet list new or dotnet new console command.
  2. Run the command: docker-compose build
  3. Notice that on an Intel mac it completes successfully.
  4. Notice that on an M1 mac this throws exception.

Expected behavior

Here is successful docker build log with sdk6 on same M1 MAC machine, it's before regression experience.

DEBU[0000] using default config store "/Users/tester/.docker/buildx" 
[+] Building 32.2s (17/18)                                                                                            
 => [internal] load build definition from Dockerfile                                                             0.0s
 => => transferring dockerfile: 838B                                                                             0.0s
 => [internal] load .dockerignore                                                                                0.0s
 => => transferring context: 2B                                                                                  0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0                                               32.1s
 => CACHED [build 1/9] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:408f1593d25f04e5d1c97115da40760ca032505c97d  0.0s
 => [internal] load build context                                                                                0.0s
 => => transferring context: 5.38kB                                                                              0.0s
 => [build 2/9] RUN dotnet --info                                                                                1.1s
 => [build 3/9] RUN dotnet --version                                                                             1.1s
 => [build 4/9] WORKDIR /src                                                                                     0.0s 
 => [build 5/9] COPY [ericktest/ericktest.csproj, ericktest/]                                                    0.0s 
 => [build 6/9] COPY [ericktest/Program.cs, ericktest/]                                                          0.0s 
 => [build 7/9] COPY . .                                                                                         0.0s 
 => [build 8/9] WORKDIR /src/ericktest                                                                           0.0s
 => [build 9/9] RUN dotnet build "ericktest.csproj" -c Release -o /app/build                                    20.0s
 => [publish 1/1] RUN dotnet publish "ericktest.csproj" -c Release -o /app/publish /p:UseAppHost=false           9.8s
 => CACHED [base 2/2] WORKDIR /app                                                                               0.0s 
 => CACHED [final 1/2] WORKDIR /app                                                                              0.0s 
 => CACHED [final 2/2] COPY --from=publish /app/publish .                                                        0.0s 
 => exporting to image                                                                                           0.0s 
 => => exporting layers                                                                                          0.0s
 => => writing image sha256:aaab5afe6491bc002ca867aef6859a214e2fb83979399576e9b482ad5076a2cd                     0.0s
 => => naming to docker.io/library/ericktest                                                                     0.0s
DEBU[0000] serving grpc connection                      
DEBU[0000] stopping session                              span="load buildkit capabilities"
DEBU[0000] serving grpc connection                      
DEBU[0032] stopping session     

Actual behavior

  1. Here is stack trace dotnet new list:

Dockerfile

FROM mcr.microsoft.com/dotnet/sdk:7.0 as base
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build
WORKDIR /src
RUN `dotnet new list`
DEBU[0000] using default config store "/Users/tester/.docker/buildx" 
[+] Building 4.8s (7/10)                                                                                     
 => [internal] load build definition from Dockerfile                                                    0.0s
 => => transferring dockerfile: 32B                                                                     0.0s
 => [internal] load .dockerignore                                                                       0.0s
 => => transferring context: 2B                                                                         0.0s
 => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:7.0                                       0.0s
 => [build 1/6] FROM mcr.microsoft.com/dotnet/sdk:7.0@sha256:028d360c0f409f13daf8689edfe680dba9d4b651e  0.0s
 => [internal] load build context                                                                       0.0s
 => => transferring context: 2.08kB                                                                     0.0s
 => CACHED [build 2/6] WORKDIR /src                                                                     0.0s
 => ERROR [build 3/6] RUN dotnet new list                                                               4.7s
------                                                                                                       
 > [build 3/6] RUN dotnet new list:                                                                          
#0 4.412 Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.                                                             
#0 4.418    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetStateMachineBox[[System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ReadAsyncInternal>d__159`1<System.Net.Security.AsyncReadWriteAdapter> ByRef, StateMachineBox<Int32> ByRef)
#0 4.418    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AwaitUnsafeOnCompleted[[System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ConfiguredValueTaskAwaiter<Int32> ByRef, <ReadAsyncInternal>d__159`1<System.Net.Security.AsyncReadWriteAdapter> ByRef, StateMachineBox<Int32> ByRef)
#0 4.420    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AwaitUnsafeOnCompleted[[System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ConfiguredValueTaskAwaiter<Int32> ByRef, <ReadAsyncInternal>d__159`1<System.Net.Security.AsyncReadWriteAdapter> ByRef)
#0 4.420    at System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()
#0 4.420    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ReadAsyncInternal>d__159`1<System.Net.Security.AsyncReadWriteAdapter> ByRef)
#0 4.420    at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Security.SslStream+<ReadAsyncInternal>d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<ReadAsyncInternal>d__159`1<System.Net.Security.AsyncReadWriteAdapter> ByRef)
#0 4.420    at System.Net.Security.SslStream.ReadAsyncInternal[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](System.Memory`1<Byte>, System.Threading.CancellationToken)
#0 4.420    at System.Net.Http.HttpConnection.PrepareForReuse(Boolean)
#0 4.420    at System.Net.Http.HttpConnectionPool.TryGetPooledHttp11Connection(System.Net.Http.HttpRequestMessage, Boolean, System.Net.Http.HttpConnection ByRef, HttpConnectionWaiter`1<System.Net.Http.HttpConnection> ByRef)
#0 4.420    at System.Net.Http.HttpConnectionPool+<SendWithVersionDetectionAndRetryAsync>d__84.MoveNext()
#0 4.420    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Http.HttpConnectionPool+<SendWithVersionDetectionAndRetryAsync>d__84, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<SendWithVersionDetectionAndRetryAsync>d__84 ByRef)
#0 4.420    at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Http.HttpConnectionPool+<SendWithVersionDetectionAndRetryAsync>d__84, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<SendWithVersionDetectionAndRetryAsync>d__84 ByRef)
#0 4.420    at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken)
#0 4.420    at System.Net.Http.HttpConnectionPool.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken)
#0 4.420    at System.Net.Http.HttpConnectionPoolManager.SendAsyncCore(System.Net.Http.HttpRequestMessage, System.Uri, Boolean, Boolean, Boolean, System.Threading.CancellationToken)
#0 4.420    at System.Net.Http.HttpConnectionPoolManager.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken)
#0 4.420    at System.Net.Http.HttpMessageHandlerStage.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
#0 4.421    at System.Net.Http.DiagnosticsHandler.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, System.Threading.CancellationToken)
#0 4.421    at System.Net.Http.HttpMessageHandlerStage.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
#0 4.421    at System.Net.Http.SocketsHttpHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
#0 4.421    at Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+<SendAsync>d__4.MoveNext()
#0 4.421    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+<SendAsync>d__4, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<SendAsync>d__4 ByRef)
#0 4.421    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+<SendAsync>d__4, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<SendAsync>d__4 ByRef)
#0 4.421    at Microsoft.ApplicationInsights.Channel.RedirectHttpHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken)
#0 4.421    at System.Net.Http.HttpClient+<<SendAsync>g__Core|83_0>d.MoveNext()
#0 4.421    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Http.HttpClient+<<SendAsync>g__Core|83_0>d, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<<SendAsync>g__Core|83_0>d ByRef)
#0 4.421    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Http.HttpClient+<<SendAsync>g__Core|83_0>d, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<<SendAsync>g__Core|83_0>d ByRef)
#0 4.421    at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(System.Net.Http.HttpRequestMessage, System.Net.Http.HttpCompletionOption, System.Threading.CancellationTokenSource, Boolean, System.Threading.CancellationTokenSource, System.Threading.CancellationToken)
#0 4.421    at System.Net.Http.HttpClient.SendAsync(System.Net.Http.HttpRequestMessage, System.Net.Http.HttpCompletionOption, System.Threading.CancellationToken)
#0 4.421    at Microsoft.ApplicationInsights.Channel.Transmission+<SendAsync>d__53.MoveNext()
#0 4.421    at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.ApplicationInsights.Channel.Transmission+<SendAsync>d__53, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<SendAsync>d__53 ByRef)
#0 4.421    at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.ApplicationInsights.Channel.Transmission+<SendAsync>d__53, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](<SendAsync>d__53 ByRef)
#0 4.421    at Microsoft.ApplicationInsights.Channel.Transmission.SendAsync()
#0 4.421    at Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Sender.Send(Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.StorageTransmission, System.TimeSpan ByRef)
#0 4.421    at Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Sender.SendLoop()
#0 4.421    at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
#0 4.421    at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
#0 4.425 qemu: uncaught target signal 6 (Aborted) - core dumped
#0 4.717 Aborted
------
DEBU[0000] serving grpc connection                      
DEBU[0000] stopping session                              span="load buildkit capabilities"
DEBU[0000] serving grpc connection                      
DEBU[0005] stopping session                             
failed to solve: executor failed running [/bin/sh -c dotnet new list]: exit code: 134
  1. Different stacktrace for same dotnet new list, I got this from inside container. Below messages suggest it's sdk image problem, probably Docker is not pulling in correct platform image. I did try linux/arm64/v8 platform with docker-composer but it found, not sure if it by design or not. There are many issues regarding qemu: uncaught target signal 11 (Segmentation fault), they suggest it's either qemu or docker image problem: https://stackoverflow.com/a/68916382, https://github.com/docker/for-mac/issues/5123
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested.

>dotnet new list
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
  1. Here is stack trace for dotnet new console,
Stack trace details ```cli Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Newtonsoft.Json.JsonWriter.AutoComplete(Newtonsoft.Json.JsonToken) at Newtonsoft.Json.JsonTextWriter.WriteValue(Int64) at Newtonsoft.Json.Linq.JValue.WriteTo(Newtonsoft.Json.JsonWriter, Newtonsoft.Json.JsonConverter[]) at Newtonsoft.Json.Linq.JToken.ToString(Newtonsoft.Json.Formatting, Newtonsoft.Json.JsonConverter[]) at Microsoft.TemplateEngine.JExtensions.ToJTokenStringDictionary(Newtonsoft.Json.Linq.JToken, System.StringComparer, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.GeneratedSymbol..ctor(System.String, Newtonsoft.Json.Linq.JObject) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.SymbolModelConverter.GetModelForObject(System.String, Newtonsoft.Json.Linq.JObject, Microsoft.Extensions.Logging.ILogger, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel..ctor(Newtonsoft.Json.Linq.JObject, Microsoft.Extensions.Logging.ILogger, Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ISimpleConfigModifiers, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectConfig..ctor(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings, Microsoft.TemplateEngine.Abstractions.IGenerator, Microsoft.TemplateEngine.Abstractions.Mount.IFile, Microsoft.TemplateEngine.Abstractions.Mount.IFile, Microsoft.TemplateEngine.Abstractions.Mount.IFile, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.Microsoft.TemplateEngine.Abstractions.IGenerator.GetTemplatesAndLangpacksFromDir(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint, System.Collections.Generic.IList`1 ByRef) at Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanMountPointForTemplatesAndLangpacks(MountPointScanSource) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+<>c__DisplayClass22_0.b__2(Int32) at System.Threading.Tasks.Parallel+<>c__DisplayClass19_0`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__1(System.Threading.Tasks.RangeWorker ByRef, Int32, Boolean ByRef) at System.Threading.Tasks.TaskReplicator+Replica.Execute() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.Task.InternalRunSynchronously(System.Threading.Tasks.TaskScheduler, Boolean) at System.Threading.Tasks.TaskReplicator.Run[[System.Threading.Tasks.RangeWorker, System.Threading.Tasks.Parallel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ReplicatableUserAction`1, System.Threading.Tasks.ParallelOptions, Boolean) at System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1, System.Action`2, System.Func`4, System.Func`1, System.Action`1) at System.Threading.Tasks.Parallel.For(Int32, Int32, System.Action`1) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1, System.__Canon) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Threading.Tasks.UnwrapPromise`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetFromTask(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.UnwrapPromise`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ProcessInnerTask(System.Threading.Tasks.Task) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task.FinishSlow(Boolean) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() qemu: uncaught target signal 6 (Aborted) - core dumped Aborted ``` ### Regression? Yes, it's regression. Same Dockerfile works fine with sdk6 image on both Intel and M1 MAC machines. I used same machines with latest docker `20.10.22, build 3a2c30b`. ### Known Workarounds Use `mcr.microsoft.com/dotnet/sdk:6.0` docker image instead of `mcr.microsoft.com/dotnet/sdk:7.0` ### Configuration - Docker image: `mcr.microsoft.com/dotnet/sdk:7.0` - docker `20.10.22, build 3a2c30b`. - MAC Apple M1 Version 12.6.2 ### Other information _No response_
dotnet-issue-labeler[bot] commented 1 year 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.

ghost commented 1 year ago

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

Issue Details
### Description This problem is regression with sdk7.0 from sdk6.0, everything works as expected on sdk 6.0. I see `memory violation/corruption error` in stack trace and it looks like an issue in the runtime: see `System.Net.Security.AsyncReadWriteAdapter` in stacktrace, can see previous similar issues https://github.com/dotnet/runtime/issues/70656, https://github.com/dotnet/runtime/issues/58349. NuGet side issue [#12329](https://github.com/NuGet/Home/issues/12329), see [comment](https://github.com/NuGet/Home/issues/12329#issuecomment-1404540175). Considering this issue repro with `dotnew new list` command, I believe this is not NuGet issue, because it doesn’t involve any NuGet operation. ### Reproduction Steps Need M1 MAC machine. 1. Extract this [erickTest.zip](https://github.com/NuGet/Home/files/10511741/erickTest.zip), it has `dotnet list new` or `dotnet new console` command. 2. Run the command: docker-compose build 3. Notice that on an Intel mac it completes successfully. 4. Notice that on an M1 mac this throws exception. ### Expected behavior Here is successful docker build log with sdk6 on same M1 MAC machine, it's before regression experience. ```cli DEBU[0000] using default config store "/Users/tester/.docker/buildx" [+] Building 32.2s (17/18) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 838B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0 32.1s => CACHED [build 1/9] FROM mcr.microsoft.com/dotnet/sdk:6.0@sha256:408f1593d25f04e5d1c97115da40760ca032505c97d 0.0s => [internal] load build context 0.0s => => transferring context: 5.38kB 0.0s => [build 2/9] RUN dotnet --info 1.1s => [build 3/9] RUN dotnet --version 1.1s => [build 4/9] WORKDIR /src 0.0s => [build 5/9] COPY [ericktest/ericktest.csproj, ericktest/] 0.0s => [build 6/9] COPY [ericktest/Program.cs, ericktest/] 0.0s => [build 7/9] COPY . . 0.0s => [build 8/9] WORKDIR /src/ericktest 0.0s => [build 9/9] RUN dotnet build "ericktest.csproj" -c Release -o /app/build 20.0s => [publish 1/1] RUN dotnet publish "ericktest.csproj" -c Release -o /app/publish /p:UseAppHost=false 9.8s => CACHED [base 2/2] WORKDIR /app 0.0s => CACHED [final 1/2] WORKDIR /app 0.0s => CACHED [final 2/2] COPY --from=publish /app/publish . 0.0s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:aaab5afe6491bc002ca867aef6859a214e2fb83979399576e9b482ad5076a2cd 0.0s => => naming to docker.io/library/ericktest 0.0s DEBU[0000] serving grpc connection DEBU[0000] stopping session span="load buildkit capabilities" DEBU[0000] serving grpc connection DEBU[0032] stopping session ``` ### Actual behavior 1. Here is stack trace `dotnet new list`: Dockerfile ``` FROM mcr.microsoft.com/dotnet/sdk:7.0 as base FROM mcr.microsoft.com/dotnet/sdk:7.0 as build WORKDIR /src RUN `dotnet new list` ``` ``` DEBU[0000] using default config store "/Users/tester/.docker/buildx" [+] Building 4.8s (7/10) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 32B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for mcr.microsoft.com/dotnet/sdk:7.0 0.0s => [build 1/6] FROM mcr.microsoft.com/dotnet/sdk:7.0@sha256:028d360c0f409f13daf8689edfe680dba9d4b651e 0.0s => [internal] load build context 0.0s => => transferring context: 2.08kB 0.0s => CACHED [build 2/6] WORKDIR /src 0.0s => ERROR [build 3/6] RUN dotnet new list 4.7s ------ > [build 3/6] RUN dotnet new list: #0 4.412 Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. #0 4.418 at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetStateMachineBox[[System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](d__159`1 ByRef, StateMachineBox ByRef) #0 4.418 at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AwaitUnsafeOnCompleted[[System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ConfiguredValueTaskAwaiter ByRef, d__159`1 ByRef, StateMachineBox ByRef) #0 4.420 at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].AwaitUnsafeOnCompleted[[System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1+ConfiguredValueTaskAwaiter[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ConfiguredValueTaskAwaiter ByRef, d__159`1 ByRef) #0 4.420 at System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext() #0 4.420 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](d__159`1 ByRef) #0 4.420 at System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Security.SslStream+d__159`1[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]], System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](d__159`1 ByRef) #0 4.420 at System.Net.Security.SslStream.ReadAsyncInternal[[System.Net.Security.AsyncReadWriteAdapter, System.Net.Security, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](System.Memory`1, System.Threading.CancellationToken) #0 4.420 at System.Net.Http.HttpConnection.PrepareForReuse(Boolean) #0 4.420 at System.Net.Http.HttpConnectionPool.TryGetPooledHttp11Connection(System.Net.Http.HttpRequestMessage, Boolean, System.Net.Http.HttpConnection ByRef, HttpConnectionWaiter`1 ByRef) #0 4.420 at System.Net.Http.HttpConnectionPool+d__84.MoveNext() #0 4.420 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Http.HttpConnectionPool+d__84, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](d__84 ByRef) #0 4.420 at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Http.HttpConnectionPool+d__84, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](d__84 ByRef) #0 4.420 at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken) #0 4.420 at System.Net.Http.HttpConnectionPool.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken) #0 4.420 at System.Net.Http.HttpConnectionPoolManager.SendAsyncCore(System.Net.Http.HttpRequestMessage, System.Uri, Boolean, Boolean, Boolean, System.Threading.CancellationToken) #0 4.420 at System.Net.Http.HttpConnectionPoolManager.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, Boolean, System.Threading.CancellationToken) #0 4.420 at System.Net.Http.HttpMessageHandlerStage.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) #0 4.421 at System.Net.Http.DiagnosticsHandler.SendAsync(System.Net.Http.HttpRequestMessage, Boolean, System.Threading.CancellationToken) #0 4.421 at System.Net.Http.HttpMessageHandlerStage.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) #0 4.421 at System.Net.Http.SocketsHttpHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) #0 4.421 at Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+d__4.MoveNext() #0 4.421 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+d__4, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__4 ByRef) #0 4.421 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.ApplicationInsights.Channel.RedirectHttpHandler+d__4, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__4 ByRef) #0 4.421 at Microsoft.ApplicationInsights.Channel.RedirectHttpHandler.SendAsync(System.Net.Http.HttpRequestMessage, System.Threading.CancellationToken) #0 4.421 at System.Net.Http.HttpClient+<g__Core|83_0>d.MoveNext() #0 4.421 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.Net.Http.HttpClient+<g__Core|83_0>d, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<g__Core|83_0>d ByRef) #0 4.421 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[System.Net.Http.HttpClient+<g__Core|83_0>d, System.Net.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](<g__Core|83_0>d ByRef) #0 4.421 at System.Net.Http.HttpClient.g__Core|83_0(System.Net.Http.HttpRequestMessage, System.Net.Http.HttpCompletionOption, System.Threading.CancellationTokenSource, Boolean, System.Threading.CancellationTokenSource, System.Threading.CancellationToken) #0 4.421 at System.Net.Http.HttpClient.SendAsync(System.Net.Http.HttpRequestMessage, System.Net.Http.HttpCompletionOption, System.Threading.CancellationToken) #0 4.421 at Microsoft.ApplicationInsights.Channel.Transmission+d__53.MoveNext() #0 4.421 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Microsoft.ApplicationInsights.Channel.Transmission+d__53, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__53 ByRef) #0 4.421 at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Start[[Microsoft.ApplicationInsights.Channel.Transmission+d__53, Microsoft.ApplicationInsights, Version=2.20.0.103, Culture=neutral, PublicKeyToken=31bf3856ad364e35]](d__53 ByRef) #0 4.421 at Microsoft.ApplicationInsights.Channel.Transmission.SendAsync() #0 4.421 at Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Sender.Send(Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.StorageTransmission, System.TimeSpan ByRef) #0 4.421 at Microsoft.DotNet.Cli.Telemetry.PersistenceChannel.Sender.SendLoop() #0 4.421 at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) #0 4.421 at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) #0 4.425 qemu: uncaught target signal 6 (Aborted) - core dumped #0 4.717 Aborted ------ DEBU[0000] serving grpc connection DEBU[0000] stopping session span="load buildkit capabilities" DEBU[0000] serving grpc connection DEBU[0005] stopping session failed to solve: executor failed running [/bin/sh -c dotnet new list]: exit code: 134 ``` 2. Different stacktrace for same `dotnet new list`, I got this from inside container. Below messages suggest it's `sdk image` problem, probably Docker is not pulling in correct platform image. I did try `linux/arm64/v8` platform with `docker-composer` but it found, not sure if it by design or not. There are many issues regarding `qemu: uncaught target signal 11 (Segmentation fault)`, they suggest it's either `qemu` or `docker image` problem: https://stackoverflow.com/a/68916382, https://github.com/docker/for-mac/issues/5123 ``` WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested. >dotnet new list qemu: uncaught target signal 11 (Segmentation fault) - core dumped Segmentation fault ``` 3. Here is stack trace for `dotnet new console`,
Stack trace details ```cli Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at Newtonsoft.Json.JsonWriter.AutoComplete(Newtonsoft.Json.JsonToken) at Newtonsoft.Json.JsonTextWriter.WriteValue(Int64) at Newtonsoft.Json.Linq.JValue.WriteTo(Newtonsoft.Json.JsonWriter, Newtonsoft.Json.JsonConverter[]) at Newtonsoft.Json.Linq.JToken.ToString(Newtonsoft.Json.Formatting, Newtonsoft.Json.JsonConverter[]) at Microsoft.TemplateEngine.JExtensions.ToJTokenStringDictionary(Newtonsoft.Json.Linq.JToken, System.StringComparer, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.GeneratedSymbol..ctor(System.String, Newtonsoft.Json.Linq.JObject) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.SymbolModelConverter.GetModelForObject(System.String, Newtonsoft.Json.Linq.JObject, Microsoft.Extensions.Logging.ILogger, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ConfigModel.TemplateConfigModel..ctor(Newtonsoft.Json.Linq.JObject, Microsoft.Extensions.Logging.ILogger, Microsoft.TemplateEngine.Orchestrator.RunnableProjects.ISimpleConfigModifiers, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectConfig..ctor(Microsoft.TemplateEngine.Abstractions.IEngineEnvironmentSettings, Microsoft.TemplateEngine.Abstractions.IGenerator, Microsoft.TemplateEngine.Abstractions.Mount.IFile, Microsoft.TemplateEngine.Abstractions.Mount.IFile, Microsoft.TemplateEngine.Abstractions.Mount.IFile, System.String) at Microsoft.TemplateEngine.Orchestrator.RunnableProjects.RunnableProjectGenerator.Microsoft.TemplateEngine.Abstractions.IGenerator.GetTemplatesAndLangpacksFromDir(Microsoft.TemplateEngine.Abstractions.Mount.IMountPoint, System.Collections.Generic.IList`1 ByRef) at Microsoft.TemplateEngine.Edge.Settings.Scanner.ScanMountPointForTemplatesAndLangpacks(MountPointScanSource) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+<>c__DisplayClass22_0.b__2(Int32) at System.Threading.Tasks.Parallel+<>c__DisplayClass19_0`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__1(System.Threading.Tasks.RangeWorker ByRef, Int32, Boolean ByRef) at System.Threading.Tasks.TaskReplicator+Replica.Execute() at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.TaskScheduler.TryRunInline(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.Task.InternalRunSynchronously(System.Threading.Tasks.TaskScheduler, Boolean) at System.Threading.Tasks.TaskReplicator.Run[[System.Threading.Tasks.RangeWorker, System.Threading.Tasks.Parallel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]](ReplicatableUserAction`1, System.Threading.Tasks.ParallelOptions, Boolean) at System.Threading.Tasks.Parallel.ForWorker[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](Int32, Int32, System.Threading.Tasks.ParallelOptions, System.Action`1, System.Action`2, System.Func`4, System.Func`1, System.Action`1) at System.Threading.Tasks.Parallel.For(Int32, Int32, System.Action`1) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__22, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].SetExistingTaskResult(System.Threading.Tasks.Task`1, System.__Canon) at Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ExecutionContextCallback(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext(System.Threading.Thread) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.TemplateEngine.Edge.Settings.TemplatePackageManager+d__13, Microsoft.TemplateEngine.Edge, Version=7.0.102.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Runtime.CompilerServices.IAsyncStateMachineBox, Boolean) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetResult(System.__Canon) at System.Threading.Tasks.UnwrapPromise`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TrySetFromTask(System.Threading.Tasks.Task, Boolean) at System.Threading.Tasks.UnwrapPromise`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ProcessInnerTask(System.Threading.Tasks.Task) at System.Threading.Tasks.Task.RunContinuations(System.Object) at System.Threading.Tasks.Task.FinishSlow(Boolean) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread) at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart() qemu: uncaught target signal 6 (Aborted) - core dumped Aborted ``` ### Regression? Yes, it's regression. Same Dockerfile works fine with sdk6 image on both Intel and M1 MAC machines. I used same machines with latest docker `20.10.22, build 3a2c30b`. ### Known Workarounds Use `mcr.microsoft.com/dotnet/sdk:6.0` docker image instead of `mcr.microsoft.com/dotnet/sdk:7.0` ### Configuration - Docker image: `mcr.microsoft.com/dotnet/sdk:7.0` - docker `20.10.22, build 3a2c30b`. - MAC Apple M1 Version 12.6.2 ### Other information _No response_
Author: erdembayar
Assignees: -
Labels: `area-System.Net.Security`, `untriaged`
Milestone: -
rzikm commented 1 year ago

Triage: We should investigate in 8.0 timeframe.

wfurt commented 1 year ago

I'll try to reproduce it but I don't se anything in macOS PAL that would be suspicious. We starts using pool for the async state and that may be something fishy there. Any through on this @stephentoub ?

wfurt commented 1 year ago

https://github.com/dotnet/runtime/blob/ddba2aafec61e780d795775d2bfc0e545964c208/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.IO.cs#L793-L794

stephentoub commented 1 year ago

We starts using pool for the async state and that may be something fishy there. Any through on this @stephentoub ?

I'd be very surprised if something in the pooling implementation somehow caused an AV.

rainersigwald commented 1 year ago

Related: https://github.com/dotnet/runtime/issues/13648 and https://gitlab.com/qemu-project/qemu/-/issues/249.

Also, I think the crash is happening in a Linux guest OS (in Docker) so the macOS PAL might not be directly relevant.

wfurt commented 1 year ago

yes, the QEMU is tricky IMHO. I was using it for ARM (Linux on Linux) while back and it was never stable for me. Now, if I understand correctly the repro would run Linux x64 runtime binaries on M1 macOS, right? That is long shot.

ARM has different memory model and while our binaries should account for that, the x64 binaries do not e.g. they assume particular behavior and it is up to the emulation to deal with that. For macOS binaries this is handled by macOS kernel AFAIK ... and we used to produce x64 for a while even for the M1/2.

Now, 7.0 SslStream did change and we use pooling now for async state. But it is certainly possible that this simply exposed QEMU bug. It would be interesting if there is any repro without QEMU...

wfurt commented 1 year ago

there is no strong indication this is .NET bug. With QEMU involved I'm going to close it unless proven otherwise.