Skip to content

ARM64 Vector2 multiplication breaks in .NET 8 #98137

@NoelFB

Description

@NoelFB

Description

On Linux and MacOS, various Vector2 floating point multiplications break after running for a few hundred milliseconds.

Running this code in Release Mode on a dotnet new console application on ARM64 results in the Y component of the vector being zero.

using System.Numerics;

while (true)
{
    Thread.Sleep(10);
    Step(4.0f);
}

static void Step(float number)
{
    var variable = Vector2.One * number;
    if (variable.X != variable.Y)
        throw new Exception("Components don't match");
    Console.WriteLine(variable);
}

This does not occur in Debug Mode. If I don't wrap the code in a function (Step) it doesn't seem to happen. If I hard code the floating value (Vector2.One * 4.0f) it doesn't seem to happen.

Reproduction Steps

Simply create a new console project in .NET 8 and run the above code in Program.cs with dotnet run -c Release. After running for a few hundred milliseconds the application will throw an exception.

Expected behavior

Multiplication should always result in <4,4>

Actual behavior

Multiplication results in <4,0> after several hundred milliseconds

Regression?

Does not occur in .NET 7, only .NET 8

Known Workarounds

No response

Configuration

.NET 8, ARM64, MacOS (have had reports of this same problem on ARM64 Linux)

Other information

This has been an issue found in our open source game Celeste 64 for users running the game on ARM64 for both MacOS and Linux. I personally have only tested on MacOS.

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions