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

Intermittent failure in CriticalFinalizer test #76041

Open
AntonLapounov opened this issue Sep 22, 2022 · 11 comments
Open

Intermittent failure in CriticalFinalizer test #76041

AntonLapounov opened this issue Sep 22, 2022 · 11 comments
Labels
area-VM-coreclr disabled-test The test is disabled in source code against the issue test-bug Problem in test source code (most likely)
Milestone

Comments

@AntonLapounov
Copy link
Member

AntonLapounov commented Sep 22, 2022

Affected tests:

  • baseservices/finalization/CriticalFinalizer/CriticalFinalizer.sh
  • baseservices\\finalization\\CriticalFinalizer\\CriticalFinalizer.cmd

Runfo failures in last 30 days - .sh and last 30 days - .cmd:

CoreCLR: https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-75573-merge-b0042e942c0145f38e/baseservices.finalization/1/console.e135272f.log?helixlogtype=result

BEGIN EXECUTION
"C:\h\w\A68508F4\p\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false"  CriticalFinalizer.dll 
Finalized 0 Normal and 0 Critical objects.
The first Critical object was finalized after 0 Normal objects.
Expected: 100
Actual: 101
END EXECUTION - FAILED

Mono: https://helixre107v0xdeko0k025g8.blob.core.windows.net/dotnet-runtime-refs-pull-74586-merge-662a1339f83d41b786/baseservices.finalization/1/console.0af36b40.log?helixlogtype=result

BEGIN EXECUTION
/tmp/helix/working/A1850911/p/corerun -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false CriticalFinalizer.dll ''
Finalized 100 Normal and 99 Critical objects.
The first Critical object was finalized after 100 Normal objects.
Expected: 100
Actual: 101
END EXECUTION - FAILED
{ "ErrorMessage":"CriticalFinalizer" } 

Report

Build Definition Step Name Console log
28655 dotnet/runtime LLVM AOT compile CoreCLR tests Log
Build Definition Test
29097 dotnet/runtime baseservices.finalization.WorkItemExecution
28963 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28964 dotnet/runtime baseservices.finalization.WorkItemExecution
29051 dotnet/runtime baseservices.finalization.WorkItemExecution
29016 dotnet/runtime baseservices.finalization.WorkItemExecution
29012 dotnet/runtime baseservices.finalization.WorkItemExecution
29010 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28977 dotnet/runtime baseservices.finalization.WorkItemExecution
28942 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28861 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28621 dotnet/runtime baseservices.finalization.WorkItemExecution
28899 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28892 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28655 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28841 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28819 dotnet/runtime baseservices.finalization.WorkItemExecution
28749 dotnet/runtime baseservices.finalization.WorkItemExecution
28766 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28692 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28682 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28649 dotnet/runtime baseservices.finalization.WorkItemExecution
28606 dotnet/runtime baseservices.finalization.WorkItemExecution
28615 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28597 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28592 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28591 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27258 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28513 dotnet/runtime baseservices.finalization.WorkItemExecution
28494 dotnet/runtime baseservices.finalization.WorkItemExecution
28476 dotnet/runtime baseservices.finalization.WorkItemExecution
28414 dotnet/runtime baseservices.finalization.WorkItemExecution
27149 dotnet/runtime baseservices.finalization.WorkItemExecution
28383 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28313 dotnet/runtime baseservices.finalization.WorkItemExecution
28293 dotnet/runtime baseservices.finalization.WorkItemExecution
28278 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28251 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28306 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28149 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27779 dotnet/runtime baseservices.finalization.WorkItemExecution
27987 dotnet/runtime baseservices.finalization.WorkItemExecution
27102 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28056 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
28047 dotnet/runtime baseservices.finalization.WorkItemExecution
28023 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27880 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27960 dotnet/runtime baseservices.finalization.WorkItemExecution
27940 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27866 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
26219 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27820 dotnet/runtime baseservices.finalization.WorkItemExecution
27804 dotnet/runtime baseservices.finalization.WorkItemExecution
27855 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27831 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27789 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27742 dotnet/runtime baseservices.finalization.WorkItemExecution
27754 dotnet/runtime baseservices.finalization.WorkItemExecution
27703 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
26661 dotnet/runtime baseservices.finalization.WorkItemExecution
27657 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27643 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27588 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
27630 dotnet/runtime baseservices.finalization.WorkItemExecution
27557 dotnet/runtime baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
33 65 65
@AntonLapounov AntonLapounov added this to the 8.0.0 milestone Sep 22, 2022
@AntonLapounov AntonLapounov self-assigned this Sep 22, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@AntonLapounov AntonLapounov changed the title Intermittent failures in CriticalFinalizer test Intermittent failure in CriticalFinalizer test Sep 22, 2022
@filipnavara filipnavara added the blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' label Sep 22, 2022
@HJLeee
Copy link
Contributor

HJLeee commented Sep 22, 2022

@AntonLapounov Please take a look. #76046

@karelz
Copy link
Member

karelz commented Sep 23, 2022

@AntonLapounov it seems it may have been a regression caused by #75952.
This is blocking significantly CI (see top post with update and links) -- can you please roll back the change, or disable the affected test ASAP? (definitely before the weekend) Thanks!

@buyaa-n
Copy link
Member

buyaa-n commented Sep 23, 2022

Failed in #75965
Log: https://helix.dot.net/api/2019-06-17/jobs/ab2fe355-3fb8-48fd-bf26-f1ab51bd2648/workitems/baseservices.finalization/console

baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd [FAIL]
      
      Return code:      1
      Raw output file:      C:\h\w\BD950A05\w\B05A0982\uploads\Reports\baseservices.finalization\CriticalFinalizer\CriticalFinalizer.output.txt
      Raw output:
      BEGIN EXECUTION
       "C:\h\w\BD950A05\p\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false"  CriticalFinalizer.dll 
      Finalized 0 Normal and 0 Critical objects.
      The first Critical object was finalized after 0 Normal objects.
      Expected: 100
      Actual: 101
      END EXECUTION - FAILED
      FAILED
      Test Harness Exitcode is : 1
      To run the test:
      > set CORE_ROOT=C:\h\w\BD950A05\p
      > C:\h\w\BD950A05\w\B05A0982\e\baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
      Expected: True
      Actual:   False
      Stack Trace:
           at baseservices_finalization._CriticalFinalizer_CriticalFinalizer_._CriticalFinalizer_CriticalFinalizer_cmd()
           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
           at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
      Output:
        
        Return code:      1
        Raw output file:      C:\h\w\BD950A05\w\B05A0982\uploads\Reports\baseservices.finalization\CriticalFinalizer\CriticalFinalizer.output.txt
        Raw output:
        BEGIN EXECUTION
         "C:\h\w\BD950A05\p\corerun.exe" -p "System.Reflection.Metadata.MetadataUpdater.IsSupported=false"  CriticalFinalizer.dll 
        Finalized 0 Normal and 0 Critical objects.
        The first Critical object was finalized after 0 Normal objects.
        Expected: 100
        Actual: 101
        END EXECUTION - FAILED
        FAILED
        Test Harness Exitcode is : 1
        To run the test:
        > set CORE_ROOT=C:\h\w\BD950A05\p
        > C:\h\w\BD950A05\w\B05A0982\e\baseservices\finalization\CriticalFinalizer\CriticalFinalizer.cmd
  Finished:    baseservices.finalization.XUnitWrapper
=== TEST EXECUTION SUMMARY ===
   baseservices.finalization.XUnitWrapper  Total: 1, Errors: 0, Failed: 1, Skipped: 0, Time: 1.235s

@jkotas
Copy link
Member

jkotas commented Sep 24, 2022

Disabling the test in #76131. Please re-enable once fixed.

@jkotas jkotas added the disabled-test The test is disabled in source code against the issue label Sep 24, 2022
VSadov pushed a commit that referenced this issue Sep 25, 2022
* Disable frequently failing CriticalFinalizer test

Contributes to #76041

* Delete coreclr specific exclusion, the test is failing everywhere
@jkotas jkotas removed the blocking-clean-ci Blocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms' label Sep 25, 2022
@jkotas jkotas removed the Known Build Error Use this to report build issues in the .NET Helix tab label Sep 25, 2022
@AustinWise
Copy link
Contributor

If my system is doing something CPU intensive, like compiling CoreCLR, the test failure reproduces more reliably. It fails rough 1 in 100 runs.

Calling GC.Collect and GC.WaitForPendingFinalizers several times in a loop seems to fix the problem. I'm not sure though that is really a reliable way to fix the test.

@AntonLapounov
Copy link
Member Author

There are two issues:

  • The lambda used in Parallel.For creates a closure object (DisplayClass) and places the arr reference there. That closure object may be kept alive by one of thread pool threads.
  • In some Mono runs the test reports only 99 Critical objects collected out of 100. I suspect that GC.WaitForPendingFinalizers() might not synchronize the current thread with the finalizer thread regarding visibility of memory stores performed by finalizers.

@AntonLapounov
Copy link
Member Author

Looking at the Mono code, there may be a race condition in sgen_have_pending_finalizers for checking the pending_unqueued_finalizer flag:

gboolean
sgen_have_pending_finalizers (void)
{
if (sgen_suspend_finalizers)
return FALSE;
return pending_unqueued_finalizer || !sgen_pointer_queue_is_empty (&fin_ready_queue) || !sgen_pointer_queue_is_empty (&critical_fin_queue);
}

@mangod9
Copy link
Member

mangod9 commented Jul 29, 2023

I am closing this based on #76046. We can reopen if this continues to be an issue.

@mangod9 mangod9 closed this as completed Jul 29, 2023
@AustinWise
Copy link
Contributor

@mangod9 This test is still disabled, referencing this issue:

https://github.com/dotnet/runtime/blob/main/src/tests/issues.targets#L14-L16

So I'm don't think the test was ever fixed to be reliable.

@jkotas jkotas modified the milestones: 8.0.0, 9.0.0 Aug 14, 2023
@jkotas jkotas added the test-bug Problem in test source code (most likely) label Aug 14, 2023
@jkotas
Copy link
Member

jkotas commented Aug 14, 2023

We should either delete the test or fix it to be reliable.

@jkotas jkotas reopened this Aug 14, 2023
@mangod9 mangod9 modified the milestones: 9.0.0, 10.0.0 Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr disabled-test The test is disabled in source code against the issue test-bug Problem in test source code (most likely)
Projects
None yet
Development

No branches or pull requests

8 participants