Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger crash on macOS (Rosetta 2 on M1) #44958

Closed
johnvcoleman opened this issue Nov 18, 2020 · 22 comments
Closed

Debugger crash on macOS (Rosetta 2 on M1) #44958

johnvcoleman opened this issue Nov 18, 2020 · 22 comments
Assignees
Labels
arch-arm64 area-Diagnostics-coreclr os-macos-bigsur (macOS11) tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone

Comments

@johnvcoleman
Copy link

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.

@Jidongang
Copy link

Having the same problem. try run without debug

@jkotas jkotas transferred this issue from dotnet/core Nov 19, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner labels Nov 19, 2020
@ghost
Copy link

ghost commented Nov 19, 2020

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:

area-Diagnostics-coreclr, untriaged

Milestone: -

@tommcdon
Copy link
Member

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

@tommcdon tommcdon removed the untriaged New issue has not been triaged by the area owner label Nov 20, 2020
@tommcdon tommcdon added this to the 6.0.0 milestone Nov 20, 2020
@petrkoutnycz
Copy link

Is there any chance it would be fixed earlier pls?

@tommcdon
Copy link
Member

Adding @sdmaclea @janvorli who have been investigating Rosetta 2 issues

@janvorli
Copy link
Member

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.

@sdmaclea
Copy link
Contributor

@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

@janvorli
Copy link
Member

janvorli commented Dec 7, 2020

I can confirm I can repro the issue locally on M1 device. I am looking into it.

@janvorli janvorli self-assigned this Dec 7, 2020
@petrkoutnycz
Copy link

petrkoutnycz commented Dec 8, 2020

I can confirm I can repro the issue locally on M1 device. I am looking into it.

That sounds great / Těsím se 👍

@tommcdon tommcdon changed the title Debugger crash on macOS (M1) Debugger crash on macOS (Rosetta 2 on M1) Dec 8, 2020
@janvorli
Copy link
Member

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.

@janvorli
Copy link
Member

I've found the culprit for the secondary issue. This one is a Rosetta 2 issue too. I have reported it to Apple.

arthurlockman added a commit to arthurlockman/omnisharp-vscode that referenced this issue Dec 11, 2020
Issue dotnet#4277

This commit removes the bit of code that was preventing the .net debugger from starting on Apple Silicon.
I've added a warning message that indicates that you might see unexpected issues when running this way.
This should start working once macOS 11.1 is released next week. (See dotnet/runtime#44958 for more details)
arthurlockman added a commit to arthurlockman/omnisharp-vscode that referenced this issue Dec 11, 2020
Issue dotnet#4277

This commit removes the bit of code that was preventing the .net debugger from starting on Apple Silicon.
I've added a warning message that indicates that you might see unexpected issues when running this way.
This should start working once macOS 11.1 is released next week. (See dotnet/runtime#44958 for more details)
gregg-miskelly pushed a commit to dotnet/vscode-csharp that referenced this issue Dec 11, 2020
* Allowing arm64 macOS to debug dotnet projects

Issue #4277

This commit removes the bit of code that was preventing the .net debugger from starting on Apple Silicon.
I've added a warning message that indicates that you might see unexpected issues when running this way.
This should start working once macOS 11.1 is released next week. (See dotnet/runtime#44958 for more details)

* Adding `arm64` to debug architectures
@peterprice
Copy link

peterprice commented Dec 18, 2020

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.

@janvorli
Copy link
Member

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.

@ogxd
Copy link
Contributor

ogxd commented Jan 29, 2021

I have official 11.1 installed and I do have this crash about one time out of two tries.

@MarkoZnidar
Copy link

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.

@smithsj2318
Copy link

I was able to debug in both Rider and VS Code after install of 11.2.

@Webreaper
Copy link

Can also confirm that debugging in VS for Mac works fine after upgrading to 11.2 (as expected).

@ogxd
Copy link
Contributor

ogxd commented Feb 12, 2021

Same for me, I was able to debug using Visual Studio for Mac without issue after updating to 11.2 🥳

@Dj51589
Copy link

Dj51589 commented Apr 28, 2021

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

@gregg-miskelly
Copy link
Contributor

@DeeJay24 If you have an M1, update your OS. Otherwise, whatever you are running into is different.

@Webreaper
Copy link

Yep, just scroll up. The answer is in the 3 comments right above yours. 👆 😁

@tommcdon
Copy link
Member

Closing this issue as macOS version 11.2 seems to resolve the bug

@ghost ghost locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-arm64 area-Diagnostics-coreclr os-macos-bigsur (macOS11) tracking-external-issue The issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Projects
None yet
Development

No branches or pull requests

15 participants