在 M1 Mac 上的 Rider 中进入异步方法时 Dotnet 程序崩溃

问题描述 投票:0回答:1

最近我的 IDE 在调试时表现异常 - 每当我尝试进入异步方法 (C#) 时,调试会话立即结束。像这样:

我的问题: 我还能做些什么来调查/排除故障,任何人都可以深入了解可能发生的事情吗?

更多细节,我尝试过的等等。


我首先在 AspNetCore 应用程序中注意到这一点,但它可以在简单的控制台应用程序中重现,如 GIF 中一样。这是我用来重现它的代码。

Console.WriteLine("Start");

// Can step into fine
Hello();

// Step into immediately crashes program
await HelloAsync(); 

Console.WriteLine("End");

void Hello() {
    Console.Write("Hello sync");
}

async Task HelloAsync() {
    await Task.Delay(100);
    Console.Write("Hello async");
}

这是我目前所知道的:

  • 这只是最近才开始发生,就在我安装 dotnet 7 的时候(虽然可能是巧合,我不记得是不是确切之后)
  • 我转储了 rider 日志(在下面发布),看起来 Rider 只是自发地失去了与 dotnet 调试器的连接(好像调试器进程崩溃了)
  • Update 我发现更多的日志显示调试器没有崩溃,目标程序崩溃了。也在下面发布了这些日志。
  • 这不会发生在 Visual Studio for Mac 上,但它会发生在 Rider 的三个最新版本上(而且他们之前肯定没有;我已经使用 Rider 多年了)

我使用的是 M1 Macbook Pro,所以不确定这是否与某些 ARM 初期问题有关。

这是我尝试过的:

  • 安装不同版本的 Rider
  • 卸载所有版本的 .NET SDK,并单独重新安装每个版本(即 dotnet 6 本身,没有 7,反之亦然)
  • 将我的演示应用程序从 .NET 6 重新定位到 .NET 7(我发现我不得不这样做才能使用 .NET 7 SDK 运行它)
  • 重启我的系统

我也将向 Jetbrains 发布错误报告,但同时我想尝试自己进一步深入研究,因为感觉像是 Rider 和我的系统(/我的 dotnet 安装)之间的问题,这可能是我特有的。


骑手日志的相关部分

07:04:14.312 |V| RiderDebuggerSessionFrontend  | ClientSocket-DebuggerWorkerToFrontend-Receiver:13 | Debugger command received from frontend: StepIntoActionModel ()
07:04:14.371 |I| CorRuntimeEventProcessor      | Debugger worker MTA main thread:6 | Target process exited
07:04:14.372 |V| RiderDebuggerSessionFrontend  | Debugger worker MTA main thread:6 | Event from debugger: type TargetExited
07:04:14.372 |V| RiderDebuggerWorker           | Debugger worker MTA main thread:6 | Firing target exited to frontend

调试器断开连接——这可能是正常的行为,因为调试器实际上并没有崩溃:

05:46:51.427 |V| Client                        | ClientSocket-DebuggerWorkerHost::10-Receiver:72 | ClientSocket-DebuggerWorkerHost::10 Connection was gracefully shutdown
05:46:51.427 |V| Client                        | ClientSocket-DebuggerWorkerHost::10-Receiver:72 | ClientSocket-DebuggerWorkerHost::10: Total traffic: sent 690, received 4436
05:46:51.427 |V| ClientSocket-DebuggerWorkerHost::10-Sender| ClientSocket-DebuggerWorkerHost::10-Receiver:72 | PAUSE ('Disconnected') :: state=AsyncProcessing
05:46:51.427 |V| Client                        | ClientSocket-DebuggerWorkerHost::10-Receiver:72 | ClientSocket-DebuggerWorkerHost::10: connecting to 127.0.0.1:51839.
05:46:51.427 |V| Client                        | ClientSocket-DebuggerWorkerHost::10-Receiver:72 | ClientSocket-DebuggerWorkerHost::10: connection error for endpoint "127.0.0.1:51839". Connection refused 127.0.0.1:51839

--- EXCEPTION #1/2 [ExtendedSocketException]
Message = “Connection refused”
ExceptionPath = Root.InnerException
ClassName = System.Net.Internals.SocketExceptionFactory+ExtendedSocketException
HResult = E_FAIL=EFail=80004005
Source = System.Net.Sockets
NativeErrorCode = 61
StackTraceString = “
  at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) in DoConnect.il:line IL_007C mvid A973
     at System.Net.Sockets.Socket.Connect(EndPoint remoteEP) in Connect.il:line IL_00E6 mvid A973
     at JetBrains.Rd.Impl.SocketWire.Client.<>c__DisplayClass1_0.<.ctor>b__0() in Client.il:line IL_0069 mvid E45C
”

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “ClientSocket-DebuggerWorkerHost::10: connection error for endpoint "127.0.0.1:51839". Connection refused 127.0.0.1:51839”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.Util.LoggerBase.Log(LoggingLevel level, String message, Exception ex) in Log.il:line IL_0024 mvid A7F4
     at JetBrains.Diagnostics.LogEx.Verbose(ILog this, Exception ex, String message) in Verbose.il:line IL_0000 mvid 89A1 or Verbose.il:line IL_0008 mvid 89A1
     at JetBrains.Diagnostics.LogEx.Verbose(ILog logger, Exception ex, JetLogVerboseInterpolatedStringHandler& messageHandler) in Verbose.il:line IL_0000 mvid 89A1 or Verbose.il:line IL_0008 mvid 89A1
     at JetBrains.Rd.Impl.SocketWire.Client.<>c__DisplayClass1_0.<.ctor>b__0() in Client.il:line IL_0069 mvid E45C
     at System.Threading.Thread.StartHelper.Callback(Object state) in Callback.il:line IL_0000 mvid 5DC4
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in RunInternal.il:line IL_0040 mvid 5DC4
”
.net-core rider
1个回答
0
投票

使用系统崩溃日志中的关键字我终于能够找到相关问题的网络。

主要有两个:

看起来这是 ARM Mac 上的 dotnet 问题。

目前,有两种解决方法。


解决方法#1

启用 dotnet 调试器的“Just My Code”功能。

在 Jetbrains Rider 中,这是通过 Enable external source debug 下的

disabling
Settings > Build, Execution, Deployment > Debugger
来完成的:


解决方法#2

调试程序时添加

DOTNET_ReadyToRun=0
作为环境变量。

请注意,显然这并非在所有情况下都有效,因此有时您可能不得不使用解决方法#1。

© www.soinside.com 2019 - 2024. All rights reserved.