runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[From xunit/xunit] Structs passed via [MemberData(...)] may be corrupted on Ubuntu

Open jamesqo opened this issue 9 years ago • 6 comments

I found this issue at https://github.com/xunit/xunit/issues/1069 and it looks like it might be of interest to people here.

Original text

When running xUnit tests on the .Net CLI using the public Travis CI servers (running Ubuntu), data held within a simple struct containing four float fields is corrupted when passed to theory using the [MemberData(...)] attribute. When running the same tests on a local Windows machine, or via AppVeyor (Windows CI) all tests pass as expected.

Example struct,

public struct Vector
{
    public float X;
    public float Y;
    public float Z;
    public float W;

    public Vector(float x, float y, float z, float w)
    {
        W = w;
        X = x;
        Y = y;
        Z = z;
    }
}

Usage,

public static object[][] ArrayVectorData = new[] { new object[] { new Vector(1, 2, 3, 4) } };

[Theory]
[MemberData(nameof(ArrayVectorData))]
public void Vector_ViaArrayMemberData(Vector vector)
{
    Assert.Equal(1, vector.X);
    Assert.Equal(2, vector.Y);
    Assert.Equal(3, vector.Z);
    Assert.Equal(4, vector.W);
}

On Windows: Test passes. On Travis CI: Expected: 3, Actual: -2.511178E-26

I've created a simple repro at, Andy-Wilkinson/BugRepro-VectorTests The corresponding CI logs show Travis CI failing (log) and AppVeyor passing (log)

jamesqo avatar Jan 20 '17 23:01 jamesqo

/cc @Andy-Wilkinson, @onovotny

jamesqo avatar Jan 20 '17 23:01 jamesqo

@jamesqo, @Andy-Wilkinson, I have tried to repro the issue using the simple repro on my Ubuntu 14.04, building it using the latest CLI tools available here: https://dotnetcli.blob.core.windows.net/dotnet/Sdk/rel-1.0.0/dotnet-dev-ubuntu-x64.latest.tar.gz I cannot repro the issue, the app completes successfuly.

janvorli avatar Jan 21 '17 00:01 janvorli

@jamesqo do you have a repro for this using a recent/latest build that can be used for investigation?

gkhanna79 avatar Jan 29 '17 02:01 gkhanna79

@gkhanna79 No, I don't own an Ubuntu machine; I opened entirely on behalf of the original owner of the issue at xunit/xunit.

jamesqo avatar Jan 29 '17 02:01 jamesqo

Thanks for the comments @gkhanna79 . Unfortunately I'm not much of an expert with Linux - it was only something I spotted when trying to run some Travis CI builds (the logs from the build are here ).

This is using the 1.0.0-preview2-003121 version of the SDK by the look of it. I will have a look to see if I can force Travis to update before the build.

Andy-Wilkinson avatar Jan 29 '17 11:01 Andy-Wilkinson

I've managed to get Travis CI to update to the latest version of the dotnet SDK (1.0.0-rc4-004771) and the tests run without error now (build logs here ).

@jamesqo - Thanks for submitting this issue with the coreclr repo. You can close this issue as fixed now.

Andy-Wilkinson avatar Feb 16 '17 21:02 Andy-Wilkinson