Skip to content

Class Vector3 field assignation overwrites the next field's contents when using LLVM AOT #110820

Closed
@rolfbjarne

Description

@rolfbjarne

From @jeromelaban on Wed, 18 Dec 2024 15:09:40 GMT

Apple platform

iOS, macOS, Mac Catalyst, tvOS

Framework version

net9.0-*

Affected platform version

9.0.101

Description

When a class contains two consecutive Vector3 fields, setting the value for the first will modify the first inner field (X) of the second field.

Steps to Reproduce

Add the following code to an app, then run, the error message should not happen:

public partial class MyTestClass
{
    private Vector3 _offset;
    private Vector3 _scale = new Vector3(1, 1, 1);

    internal static void RunTest()
    {
		var v1 = new MyTestClass();
		System.Console.WriteLine($"Scale: {v1.Scale} Offset: {v1.Offset} Scale: {v1.Scale}");

		var v2 = new MyTestClass() { Offset = new(1.1f, 1.1f, 5.0f) };
		System.Console.WriteLine($"Scale: {v2.Scale} Offset: {v2.Offset} Scale: {v2.Scale}");

		if(v2.Scale != new Vector3(1, 1, 1))
                {
			System.Console.WriteLine("Error: Scale is not 1, 1, 1");
                }
    }

    public Vector3 Offset
    {
        get => _offset;
        set
        {
            System.Console.WriteLine($"Before Offset: {Offset} Scale: {Scale}");

            _offset = value;

            System.Console.WriteLine($"After Offset: {Offset} Scale: {Scale}");
        }
    }

    public Vector3 Scale => _scale;
}

Repro project: 21825-iosllvmissue.zip

Did you find any workaround?

Adding a field of another type in between seems to works around the issue.

Relevant logs

No response

Copied from original issue dotnet/macios#21825

Metadata

Metadata

Assignees

Labels

area-Codegen-LLVM-monoin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions