Skip to content

Breakpoint changes the output of the program on x64 #12875

@tommcdon

Description

@tommcdon

The output for the execution of a program may change if you add a breakpoint on a specified line.

Repro Steps:

static void Main(string[] args)
{
    Console.WriteLine(WrapDegrees(-722.5f));
    Console.WriteLine();
}

private static float WrapDegrees(float degrees)
{
    float remainder = Math.Abs(degrees);
    remainder %= 360; // breakpoint here
    return degrees < 0 ? 360 - remainder : remainder;
}

Code from: https://gist.github.com/tannergooding/af91efb30215ab360dfb3fe18e58fe36

  1. Add breakpoint at specified line;
  2. Target .NET Core 3.0 Preview 4 for x64;
  3. Start debugging;
  4. Hit breakpoint and continue execution.

Expected output
357.5

Actual output
357.51007

Remarks

  • If you don't add any breakpoint (or add any breakpoint as long as the specified line does not have a breakpoint), the output will be the same as expected;
  • Unable to reproduce the issue with v3.0.0-preview-27122-01 or older versions (regression);
  • Unable to reproduce if targeting x86.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions