Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch failure #104905

Closed
elinor-fung opened this issue Jul 15, 2024 · 9 comments · Fixed by #105072 or #106967
Assignees
Labels
area-System.Resources binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' in-pr There is an active PR which will close this issue when it is merged Known Build Error Use this to report build issues in the .NET Helix tab
Milestone

Comments

@elinor-fung
Copy link
Member

elinor-fung commented Jul 15, 2024

System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(value: WeakReference { IsAlive = True, Target = https://dot.net/, TrackResurrection = True }, _: [BinaryFormatTests.TypeSerializableValue, BinaryFormatTests.TypeSerializableValue]) [FAIL]
  Assert.Equal() Failure: Values differ
  Expected: 242
  Actual:   85
  Stack Trace:
    /_/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BasicObjectTests.cs(40,0): at System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(Object value, TypeSerializableValue[] _)
        at System.Object.InvokeStub_BasicObjectTests.BasicObjectsRoundTripAndMatch(Object , Span`1 )
    /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(136,0): at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Build Information

Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=739427
Build error leg or test failing: System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch
Pull request: #104749

Error Message

Fill the error message using step by step known issues guidance.

{
  "ErrorMessage": ["BasicObjectsRoundTripAndMatch", "Expected:"],
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Known issue validation

Build: 🔎
Result validation: ⚠️ Provided build not found. Provide a valid build in the "Build: 🔎" line.
Validation performed at: 8/14/2024 10:23:52 PM UTC

Report

Build Definition Test Pull Request
791827 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #107117
790572 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106965
790309 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #107050
784110 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106409
779942 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106613
779313 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106578
777681 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch
777119 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106474
776563 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106437
776146 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106416
775754 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106398
775106 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106218
769299 dotnet/runtime System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch #106108

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
1 3 13
@elinor-fung elinor-fung added area-System.Resources blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' Known Build Error Use this to report build issues in the .NET Helix tab labels Jul 15, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 15, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-resources
See info in area-owners.md if you want to be subscribed.

@elinor-fung
Copy link
Member Author

cc @adamsitnik - test was added in #102379

@ericstj ericstj added this to the 9.0.0 milestone Jul 17, 2024
@ericstj ericstj removed the untriaged New issue has not been triaged by the area owner label Jul 17, 2024
@ericstj
Copy link
Member

ericstj commented Jul 17, 2024

Adding some detail about the failure. Seems this was deserializing a WeakReference object:

System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(value: WeakReference { IsAlive = True, Target = https://dot.net/, TrackResurrection = True }, _: [BinaryFormatTests.TypeSerializableValue, BinaryFormatTests.TypeSerializableValue]) [FAIL]
      Assert.Equal() Failure: Values differ
      Expected: 242
      Actual:   85
      Stack Trace:
        /_/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BasicObjectTests.cs(40,0): at System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(Object value, TypeSerializableValue[] _)
           at System.Object.InvokeStub_BasicObjectTests.BasicObjectsRoundTripAndMatch(Object , Span`1 )
        /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs(136,0): at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

https://helixre107v0xdcypoyl9e7f.blob.core.windows.net/dotnet-runtime-refs-pull-104749-merge-d99a4fd2282b40b389/System.Resources.Extensions.BinaryFormat.Tests/1/console.d365210d.log?helixlogtype=result

Here's the corresponding test data:
https://github.com/dotnet/runtime/blob/66ae90f3b7ec4f13fffcd71913eca0b45777e58c/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/Legacy/BinaryFormatterTestData.cs#L717-L720

Seems pretty odd to me that this would be flaky. Any theories, @adamsitnik?

@adamsitnik
Copy link
Member

Any theories, @adamsitnik?

The test failed when comparing the lengths of a streams that contained:

  • serialized WeakReference
  • deserialized and serialized WeakReference

// Now compare the two streams to ensure they are identical
Assert.Equal(serialized.Length, deserializedSerialized.Length);

My theory: WeakReference was no longer pointing to an alive object when the value was serialized to another stream, so the content was different and hence the stream length difference.

Repro:

using System.Runtime.Serialization.Formatters.Binary;

Uri? dotnetUri = new("https://dot.net");
WeakReference weakReference = new(dotnetUri, true);

BinaryFormatter binaryFormatter = new();
MemoryStream memoryStream = new();

binaryFormatter.Serialize(memoryStream, weakReference);
Console.WriteLine($"IsAlive: {weakReference.IsAlive}, Length: {memoryStream.Length}");

memoryStream.Position = 0;
memoryStream.SetLength(0);

dotnetUri = null;

do
{
    GC.Collect();
    GC.WaitForPendingFinalizers();
    GC.Collect();
} while (weakReference.IsAlive);

binaryFormatter.Serialize(memoryStream, weakReference);
Console.WriteLine($"IsAlive: {weakReference.IsAlive}, Length: {memoryStream.Length}");
IsAlive: True, Length: 242
IsAlive: False, Length: 85

@stephentoub
Copy link
Member

I just hit this in #105339, which was opened after and which includes the fix for this issue...

Data Driven SubResults
❌ System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(value: WeakReference { IsAlive = True, Target = https://dot.net/, TrackResurrection = True }, _: [BinaryFormatTests.TypeSerializableValue, BinaryFormatTests.TypeSerializableValue])
Exception Message
Assert.Equal() Failure: Values differ
Expected: 242
Actual:   85
Stack Trace
   at System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(Object value, TypeSerializableValue[] _) in /_/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BasicObjectTests.cs:line 40
   at System.Object.InvokeStub_BasicObjectTests.BasicObjectsRoundTripAndMatch(Object , Span`1 )
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 136

@stephentoub stephentoub reopened this Jul 24, 2024
@adamsitnik
Copy link
Member

adamsitnik commented Jul 24, 2024

@stephentoub
Copy link
Member

Thanks. Let's close this again and see if any further occurrences are reported separately. It's possible there was some kind of staleness happening.

@stephentoub stephentoub closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
@mdh1418
Copy link
Member

mdh1418 commented Aug 7, 2024

I hit this in #106040

Data Driven SubResults
❌ System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(value: WeakReference`1 { }, _: [BinaryFormatTests.TypeSerializableValue, BinaryFormatTests.TypeSerializableValue])
Exception Message
Assert.Equal() Failure: Values differ
Expected: 479
Actual:   407
Stack Trace
   at System.Resources.Extensions.Tests.FormattedObject.BasicObjectTests.BasicObjectsRoundTripAndMatch(Object value, TypeSerializableValue[] _) in /_/src/libraries/System.Resources.Extensions/tests/BinaryFormatTests/FormattedObject/BasicObjectTests.cs:line 40
   at InvokeStub_BasicObjectTests.BasicObjectsRoundTripAndMatch(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithFewArgs(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in /_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.cs:line 136

Config: net9.0-windows-Release-x64-coreclr_checked-Windows.10.Amd64.Open

@mdh1418 mdh1418 reopened this Aug 7, 2024
@ericstj ericstj added the binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it label Aug 9, 2024
@adamsitnik
Copy link
Member

I am moving it to 10 as it's not a product issue, but a flaky test.

adamsitnik added a commit to adamsitnik/runtime that referenced this issue Aug 26, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Aug 26, 2024
adamsitnik added a commit to adamsitnik/runtime that referenced this issue Sep 9, 2024
github-actions bot pushed a commit that referenced this issue Sep 17, 2024
carlossanlop pushed a commit that referenced this issue Sep 17, 2024
* Remove package references from library tests (#106737)

* Remove package references from library tests

These tests should be referencing the product assemblies so that they
test latest and not old bits.

* Reference the OOB version of SRSF and make sure it's copied

* BinaryFormatter tests should be skipped only on AOT, WASM and Mobile (#106858)

* respect AppContext switch (which is currently enabled for all projects in the root Directory.Build.props file)

* add project reference to all test projects that need working BF (and were being skipped for a while)

* adjust to changes from #104202: EqualityComparer<string>.Default is mapped to StringEqualityComparer, but serialized as GenericEqualityComparer<string>

* Don't use WeakReferences in the round trip test, as the target may get freed in the meantime, fixes #104905 (#106967)

* Enable more BinaryFormatter tests (#107408)

* enable the BinaryFormatter tests in System.Runtime.Serialization.Formatters.Tests

* add new test project, where the flag is disabled and it runs only 3 tests in total that ensure that

* The SerializationGuard is no longer activated since BF was moved to the OOB package, the tests need to reflect that.

* Disable binary formatter tests when DotNetBuildSourceOnly. (#107549)

* [mono][tvos] Do not treat assembly.pdb/xml files as native files to bundle when AOTing on Helix (#107079)

* Do not treat assembly.pdb/xml files as native files to bundle

* Bundle satellite assemblies as well

* [mono][ci] Include PDBs from runtime pack when building on Helix if required (#107348)

---------

Co-authored-by: Eric StJohn <ericstj@microsoft.com>
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
carlossanlop pushed a commit that referenced this issue Sep 17, 2024
…107903)

* Remove package references from library tests (#106737)

* Remove package references from library tests

These tests should be referencing the product assemblies so that they
test latest and not old bits.

* Reference the OOB version of SRSF and make sure it's copied

* BinaryFormatter tests should be skipped only on AOT, WASM and Mobile (#106858)

* respect AppContext switch (which is currently enabled for all projects in the root Directory.Build.props file)

* add project reference to all test projects that need working BF (and were being skipped for a while)

* adjust to changes from #104202: EqualityComparer<string>.Default is mapped to StringEqualityComparer, but serialized as GenericEqualityComparer<string>

* Don't use WeakReferences in the round trip test, as the target may get freed in the meantime, fixes #104905 (#106967)

* Enable more BinaryFormatter tests (#107408)

* enable the BinaryFormatter tests in System.Runtime.Serialization.Formatters.Tests

* add new test project, where the flag is disabled and it runs only 3 tests in total that ensure that

* The SerializationGuard is no longer activated since BF was moved to the OOB package, the tests need to reflect that.

* Disable binary formatter tests when DotNetBuildSourceOnly. (#107549)

* [mono][tvos] Do not treat assembly.pdb/xml files as native files to bundle when AOTing on Helix (#107079)

* Do not treat assembly.pdb/xml files as native files to bundle

* Bundle satellite assemblies as well

* [mono][ci] Include PDBs from runtime pack when building on Helix if required (#107348)

---------

Co-authored-by: Eric StJohn <ericstj@microsoft.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
Co-authored-by: Tom Deseyn <tom.deseyn@gmail.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
jtschuster pushed a commit to jtschuster/runtime that referenced this issue Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Resources binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' in-pr There is an active PR which will close this issue when it is merged Known Build Error Use this to report build issues in the .NET Helix tab
Projects
None yet
5 participants