runtime: Remotely debugging .NET 7 apps in linux-arm environments causes segmentation fault
Description
Unable to remotely debug .NET 7 apps in linux-arm
(32-bit).
Reproduction Steps
- Create new .NET 7 console project.
- Replace the contents of Program.cs with:
Console.WriteLine("I'm not going to do anything!");
while(true)
{
System.Threading.Thread.Sleep(1000);
}
- Publish the self-contained app with
dotnet publish --runtime linux-arm --self-contained
and deploy the files to the device as described here. - Ensure the device has vsdbg installed:
curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
- From a PC, use the following VS Code launch.json configuration to remotely launch the app in the debugger:
{
"name": "Remote Launch Pi",
"type": "coreclr",
"request": "launch",
"program": "~/myapp/myapp",
"args": [],
"cwd": "~/myapp",
"stopAtEntry": false,
"console": "internalConsole",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "ssh",
"pipeArgs": [
"pi@raspberrypi"
],
"debuggerPath": "~/vsdbg/vsdbg"
}
- Alternatively, launch the app on the Pi and then attach to the running process from the PC with this configuration:
{
"name": "Attach Pi",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "ssh",
"pipeArgs": [
"pi@raspberrypi"
],
"debuggerPath": "~/vsdbg/vsdbg"
}
}
Expected behavior
Application runs and the debugging session proceeds.
Actual behavior
When attempting to launch in the debugger:
Starting: "ssh" pi@192.168.15.141 ~/vsdbg/vsdbg --interpreter=vscode
-------------------------------------------------------------------
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 '/home/pi/Animate/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The program '[3178] Animate' has exited with code 0 (0x0).
If attempting to attach to a running process, the debugger attaches and then after breaking/continuing an indeterminite number of times, exits with Segmentation Fault
.
Regression?
This currently works in .NET 6. .NET 7 seems to be the only runtime affected.
Known Workarounds
- Use a 64-bit OS and target
linux-arm64
(when using .NET 7) - Use .NET 6 and target
linux-arm
on a 32-bit OS
Configuration
Isolated to linux-arm
. Attempted to repro on linux-x64
and linux-arm64
. linux-arm
is the only runtime affected.
This behavior has been verified on 2 separate Raspberry Pi 3 devices and one Raspberry Pi 4 device, in both Raspberry Pi OS (32-bit) and Ubuntu (32-bit).
This behavior has been observed in Visual Studio Code (both launching the process and attaching to an existing process) and in Visual Studio (attaching remotely).
Other information
This behavior has been observed by other users.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 4
- Comments: 15 (10 by maintainers)
Sorry for the slow reply @tommcdon. I’ll dig out my test hardware tomorrow and see if it still repros
Hello @CamSoper! We have not been able to reproduce this issue. Are you still seeing this problem on .NET 7?
Yep, correct. AFAIK, it’s only when debugging. I only found it because I’m making a video series and I got to the part where I show how to debug and… couldn’t.
Thanks for reporting this.
It is assumed (but not fully stated) from the write-up that the app works as expected w/o debugging in the picture. Is that fair?
I have both 32-bit and 64-bit OSes installed on my Pis and use them a fair bit. Not 100% intentional, but I think I do all development (including debugging) on the 64-bit ones. In some cases, I’m still using .NET 6. That’s a long way of saying that I use this scenario but didn’t find it for reasons.