-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Access Violation starting with .NET 8.0.0 when debugging console application with Visual Studio on Windows x64 #96322
Comments
Tagging subscribers to this area: @tommcdon Issue DetailsDescriptionHi, I noticed that after upgrading from .NET 7.0.14 to 8.0.0, debugging the following simple console application on Windows x64 with Visual Studio 17.8.3 causes an access violation, when setting a break point at the However, this seems to happen only when debugging, so maybe it is an issue in the debugger only. Reproduction StepsCreate the following two files:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
using System.Net.Sockets;
using System.Threading;
class Program
{
private static readonly string serverName = "localhost";
private static readonly int serverPort = 12345;
private static long x;
private static long y;
static void Main()
{
var updateConsoleThread = new Thread(() =>
{
long localX = x;
long localY = y;
});
updateConsoleThread.Start();
var senderThread = new Thread(() => RunSenderThread());
senderThread.Start();
senderThread.Join();
updateConsoleThread.Join();
}
private static void RunSenderThread()
{
using var client = new TcpClient();
try
{
client.Connect(serverName, serverPort);
}
catch (SocketException)
{
// Ignore
}
}
}
Expected behaviorNo access violation occurs when pressing F10 after reaching the breakpoint. Actual behaviorAn access violation occurs in most cases when pressing F10 after reaching the breakpoint. Regression?Yes, this doesn't happen when running with .NET 7.0.14 instead of 8.0.0 (by changing the Known WorkaroundsNo response Configuration
Other informationNo response
|
Hmm. tested it 10 times (on mac and windows) and I always reach the SocketException |
Hi @Fabi, Additionally, I have now uploaded a video (in the original post) showing the reproduction steps on a clean Windows Server 2022 VM (Build 20348.2113), hope this helps! Thanks! |
Hmm. Im on latest Win11 & macOS. But I'm already confused by your first port related exception :D |
Regression caused by #96339 |
Hi @kpreisser, would you mind try setting DOTNET_EnableAVX=0? That would help to confirm my suspicion that the issue is caused by #96339. |
@tommcdon is that the right ID? |
Hi @tommcdon, I tried setting the private static void RunSenderThread()
{
using var client = new TcpClient();
try
{
Debug.WriteLine($"DOTNET_EnableAVX: '{Environment.GetEnvironmentVariable("DOTNET_EnableAVX")}'");
client.Connect(serverName, serverPort);
}
catch (SocketException)
{
// Ignore
}
} However, when debugging with the breakpoint and then continuing, the AV still happens:
Thanks! |
@kpreisser I have found the source of the regression and have a candidate fix: #96352. The issue is that we are not skipping AMD64 instruction prefixes and are treating the prefix as the opcode when single-stepping over the breakpoint patch table. I can provide a private 8.0 build for testing purposes. Please let me know if you would be willing to try it out to help verify the fix. |
Hi @tommcdon, |
Hi @kpreisser! Please unzip the 5 DLL's from https://github.com/tommcdon/runtime/releases/tag/8.0_x64_stepping_fix and copy them into your .NET 8 install directory (e.g. |
Hi @tommcdon, |
Servicing approved the 8.0 backport PR, so closing this issue |
Description
Hi, I noticed that after upgrading from .NET 7.0.14 to 8.0.0, debugging the following simple console application on Windows x64 with Visual Studio 17.8.3 causes an access violation, when setting a break point at the
client.Connect(...)
line, and then stepping over with F10.However, this seems to happen only when debugging, so maybe it's a debugger-related issue only.
Reproduction Steps
Create the following two files:
TestProject.csproj
Program.cs
client.Connect(serverName, serverPort);
line:Video
This video shows the reproduction steps I used on an empty Windows Server 2022 VM (Build 20348.2113). Note that the first time running the application, the AV doesn't happen but an unexpected
ArgumentOutOfRangeException
occurs (which suggests an out-of-range port number would be specified). When trying again, the AV occurs.Repro-Dotnet-Runtime-Issue-96322.mp4
Expected behavior
No access violation occurs when pressing F10 after reaching the breakpoint.
Actual behavior
An access violation occurs in most cases when pressing F10 after reaching the breakpoint.
Regression?
Yes, this doesn't happen when running with .NET 7.0.14 instead of 8.0.0 (by changing the
TargetFramework
tonet7.0
).Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: