Debugger crash on macOS (Rosetta 2 on M1)
I'm not sure this is where I need to put this or if you guys are even entertaining bugs for the M1 yet, but here goes...
Repro steps
Debugging the default console "hello world" project in VSCode results in an apparent crash of the debugger:
namespace test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Debug Console output:
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Stack overflow.
at System.Collections.HashHelpers.GetPrime(Int32)
at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Initialize(Int32)
at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(Int32, System.Collections.Generic.IEqualityComparer`1<System.__Canon>)
at System.AppContext.Setup(Char**, Char**, Int32)
Running the dll from the command line in a terminal window is successful:
johncoleman@edgar net5.0 % ls
ref test.dll test.runtimeconfig.dev.json
test.deps.json test.pdb test.runtimeconfig.json
johncoleman@edgar net5.0 % dotnet test.dll
Hello World!
johncoleman@edgar net5.0 %
Crash is reproducible, happens every time.
Thanks.
Having the same problem. try run without debug
Tagging subscribers to this area: @tommcdon See info in area-owners.md if you want to be subscribed.
Issue Details
I'm not sure this is where I need to put this or if you guys are even entertaining bugs for the M1 yet, but here goes...
Repro steps
Debugging the default console "hello world" project in VSCode results in an apparent crash of the debugger:
namespace test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Debug Console output:
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/5.0.0/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Stack overflow.
at System.Collections.HashHelpers.GetPrime(Int32)
at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Initialize(Int32)
at System.Collections.Generic.Dictionary`2[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(Int32, System.Collections.Generic.IEqualityComparer`1<System.__Canon>)
at System.AppContext.Setup(Char**, Char**, Int32)
Running the dll from the command line in a terminal window is successful:
johncoleman@edgar net5.0 % ls
ref test.dll test.runtimeconfig.dev.json
test.deps.json test.pdb test.runtimeconfig.json
johncoleman@edgar net5.0 % dotnet test.dll
Hello World!
johncoleman@edgar net5.0 %
Crash is reproducible, happens every time.
Thanks.
| Author: | johnvcoleman |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
Thank you for reporting the issue! Adding @jeffhandley in case this is a known issue with System.Collections.HashHelpers.GetPrime and rosetta 2 FYI @caslan
Is there any chance it would be fixed earlier pls?
Adding @sdmaclea @janvorli who have been investigating Rosetta 2 issues
I wonder if the Stack overflow could somehow be caused by the stack probing issues we've recently discovered and caused by the fact that the Apple Silicon uses 16kB memory pages unlike other systems where the memory page size is 4kB.
@petrkoutnycz We would target fixing this for .NET 5.0 with Rosetta 2.
@janvorli I'll take a look to see if this issue is fixed with the stack probing fix
I can confirm I can repro the issue locally on M1 device. I am looking into it.
I can confirm I can repro the issue locally on M1 device. I am looking into it.
That sounds great / Těsím se 👍
I have found the culprit - it was a Rosetta 2 bug. I have reported it to Apple and it was found that it is actually fixed in 11.1 beta release. I have installed that beta and verified that debugging now starts correctly. But I've found another issue behind that. When you set a breakpoint, it gets hit correctly, the debugger breaks in just fine. However, when you single step, the runtime crashes with access violation. I am currently looking into this secondary issue.
I've found the culprit for the secondary issue. This one is a Rosetta 2 issue too. I have reported it to Apple.
Things seem to have regressed after an update to Big Sur Beta 11.2:
❯ dotnet new webapi -f net5.0 --name test-api --force
The template "ASP.NET Core Web API" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on sadf/sadf.csproj...
Determining projects to restore...
All projects are up-to-date for restore.
assertion failed [abi_info.u.translated_code.instruction_extents.kind == InstructionOffsetKind::Syscall]: on sigreturn exit path but instruction isn't marked as a syscall
(ThreadContextRegisterState.cpp:381 x86_gpr_state_from_arm_state)
[1] 4395 trace trap dotnet new webapi -f net5.0 --name test-api --force
Before this update, I was able to generate and run dotnet apps successfully.
I've hit the same issue yesterday while testing the 11.2 beta and reported it to Apple. Btw, it seems this is an intermittent issue that doesn't occur always.
I have official 11.1 installed and I do have this crash about one time out of two tries.
Installed 11.2 and the issue is resolved for me. I can debug in Jetbrains Rider, I can't say the same for VS Code because I haven't tried it, but I assume since it was labeled as Rosetta 2 issue one can debug in VS Code too.
I was able to debug in both Rider and VS Code after install of 11.2.
Can also confirm that debugging in VS for Mac works fine after upgrading to 11.2 (as expected).
Same for me, I was able to debug using Visual Studio for Mac without issue after updating to 11.2 🥳
Hi,
I am facing the same issue. Please tell me how to resolve it. My MAC OS version is: MacOS Big Sur, version: 11.0.1 Visual Studio Version is: Visual Studio for Mac Community, version: 8.9.6 (build 6)
Thanks & Regards, Dheeraj
@deejay24 If you have an M1, update your OS. Otherwise, whatever you are running into is different.