Skip to content

Xml_TypeInCollectibleALC Test Fails in CI with Unexisting Assembly Under PreGenMode when TestReadyToRun is Enabled #96799

Open
@ivdiazsa

Description

@ivdiazsa

Example run: https://dev.azure.com/dnceng-public/public/_build/results?buildId=520677&view=logs&jobId=a3afc042-504d-5914-10aa-806e778b39dd&j=a3afc042-504d-5914-10aa-806e778b39dd&t=6bb3abb3-e298-5c87-7809-e536a76b86e3

In the TestReadyToRun test runs, located in the runtime-coreclr crossgen2 pipeline, the Xml_TypeInCollectibleALC() test fails with an error that a necessary assembly doesn't exist under "PreGen Mode". Here's the log:

+ export PYTHONPATH=/root/helix/scripts:
+ cd /root/helix/work/workitem/e
+ mkdir -p /home/helixbot/dotnetbuild/dumps/
+ /root/helix/work/correlation/scripts/760d3a31a12b47afaa9b8611d3c1be55/execute.sh
+ ./RunTests.sh --runtime-path /root/helix/work/correlation
========================= Begin custom configuration settings ==============================
export __TestArchitecture=x64
export __IsXUnitLogCheckerSupported=1
========================== End custom configuration settings ===============================
----- start Wed 10 Jan 2024 01:56:30 AM UTC =============== To repro directly: =====================================================
pushd .
chmod +rwx Microsoft.XmlSerializer.Generator.Tests ^&^& ./Microsoft.XmlSerializer.Generator.Tests -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing -xml testResults.xml 
popd
===========================================================================================================
/root/helix/work/workitem/e /root/helix/work/workitem/e
Running assembly:Microsoft.XmlSerializer.Generator.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
.NET Xml Serialization Generation Utility, Version 9.0.0-ci]
Serialization Code File Name: /root/helix/work/workitem/e/SerializableAssembly.XmlSerializers.cs.
Generated serialization code for assembly /root/helix/work/workitem/e/SerializableAssembly.dll --> '/root/helix/work/workitem/e/SerializableAssembly.XmlSerializers.cs'.
[FAIL] Microsoft.XmlSerializer.Generator.Tests.SgenTests.SgenCommandTest
Assert.Equal() Failure: Values differ
Expected: 844696
Actual:   844713
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[FAIL] XmlSerializerTests.Xml_TypeInCollectibleALC
System.IO.FileLoadException : "Fail to load assembly SerializableAssembly.XmlSerializers or SerializableAssembly.XmlSerializers doesn't exist under PreGen Mode.
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
   at XmlSerializerTests.ExecuteAndUnload(String assemblyfile, String typename, WeakReference& wref) in /_/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs:line 2178
   at XmlSerializerTests.Xml_TypeInCollectibleALC() in /_/src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs:line 2107
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Finished Microsoft.XmlSerializer.Generator.Tests, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

Tests run: 95, Errors: 0, Failures: 2, Skipped: 0. Time: 0.4777931s
/root/helix/work/workitem/e

The first failure might be unrelated to this one, and is being tracked in issue #96796.

If PR #96721 has been merged when investigating this issue, then first make sure to enable the failing test by removing its ActiveIssue annotation in src/libraries/System.Private.Xml/tests/XmlSerializer/XmlSerializerTests.cs:

    [Fact]
#if XMLSERIALIZERGENERATORTESTS
    // Lack of AssemblyDependencyResolver results in assemblies that are not loaded by path to get
    // loaded in the default ALC, which causes problems for this test.
    [SkipOnPlatform(TestPlatforms.Browser, "AssemblyDependencyResolver not supported in wasm")]
#endif
    [ActiveIssue("34072", TestRuntimes.Mono)]
    // Comment this one out --> [ActiveIssue("https://github.com/dotnet/runtime/issues/96799", typeof(PlatformDetection), nameof(PlatformDetection.IsReadyToRunCompiled))]
    public static void Xml_TypeInCollectibleALC()
    {
        ExecuteAndUnload("SerializableAssembly.dll", "SerializationTypes.SimpleType", out var weakRef);

        for (int i = 0; weakRef.IsAlive && i < 10; i++)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
        Assert.True(!weakRef.IsAlive);
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions