Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Profiler][Tests] Add shutdown guard and filter to classload test #114849

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

Merged
merged 1 commit into from
Apr 21, 2025

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Apr 20, 2025

Fixes #114760

The test failed (once out of 250+ runs) possibly due to the profiler shutting down in the middle of a class load. Many class loads are occurring besides those from unloadlibrary.cs ( classLoadStartedCount=995 classLoadFinishedCount=994 classUnloadStartedCount=7 classUnloadFinishedCount=7), and I don't believe this test cares about any classes apart from those from unloadlibrary.cs.

This PR does the following:

  • Adds Shutdown guards to avoid possible access violations when profiler resources are freed
  • Scopes the counters to just those from UnloadLibrary.TestClass.

Testing

PS R:\> .\artifacts\tests\coreclr\windows.x64.Debug\profiler\unittest\classload\classload.cmd
BEGIN EXECUTION
 "R:\artifacts\tests\coreclr\windows.x64.Debug\Tests\Core_Root\corerun.exe" -p "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true"  classload.dll
Profiler path: R:\artifacts\tests\coreclr\windows.x64.Debug\profiler\unittest\classload\Profiler.dll
Profilee STDOUT: Profiler.dll!DllGetClassObject
Profilee STDOUT: Profiler.dll!Profiler::Initialize
Profilee STDOUT: TestClass constructed
Profilee STDOUT: 32854180
Profilee STDOUT: Setting COR_PRF_MONITOR_CLASS_LOADS mask
Profilee STDOUT: ClassLoadStarted: UnloadLibrary.TestClass
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.IEnumerable`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.ICollection`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.IList`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.IReadOnlyCollection`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.IReadOnlyList`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassLoadStarted: System.Collections.Generic.List`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: UnloadLibrary.TestClass
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.List`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.IList`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.IReadOnlyCollection`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.IReadOnlyList`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.ICollection`1<UnloadLibrary.TestClass>
Profilee STDOUT: ClassUnloadStarted: System.Collections.Generic.IEnumerable`1<UnloadLibrary.TestClass>
Profilee STDOUT: Profiler.dll!Profiler::Shutdown
Profilee STDOUT: PROFILER TEST PASSES
Expected: 100
Actual: 100
END EXECUTION - PASSED
PASSED

@Copilot Copilot AI review requested due to automatic review settings April 20, 2025 22:12
@mdh1418 mdh1418 requested review from noahfalk and jkotas April 20, 2025 22:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses intermittent test failures by adding shutdown guards and narrowing the scope of class load counters to only affect UnloadLibrary.TestClass.

  • Added shutdown guard macros to prevent resource access issues during profiler shutdown.
  • Updated counter logic in class load and unload events to filter only UnloadLibrary.TestClass.
  • Modified shutdown conditions to validate precise counts for class load and unload events.

Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@mdh1418 mdh1418 merged commit c83f92a into dotnet:main Apr 21, 2025
74 checks passed
@mdh1418 mdh1418 deleted the fix_profiler_test_classload branch April 21, 2025 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: profiler/unittest/classload/classload.cmd
3 participants