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

CLR_GCHEAPCOLLECT_KEYWORD triggers a GC twice #99487

Closed
kevingosse opened this issue Mar 9, 2024 · 0 comments · Fixed by #109587
Closed

CLR_GCHEAPCOLLECT_KEYWORD triggers a GC twice #99487

kevingosse opened this issue Mar 9, 2024 · 0 comments · Fixed by #109587
Assignees
Labels
area-Diagnostics-coreclr in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@kevingosse
Copy link
Contributor

Description

I've looked into how to trigger a GC remotely using dotnet-trace (by enabling keyword 0x800000) and noticed that it actually triggered two GCs: one when the keyword is enabled, and one when it's disabled.

It looks like an bug in the code.

If I look at the corresponding code in the early days of coreclr, I can see that the call is wrapped in a if(bEnabled) condition, itself set as ((ControlCode == EVENT_CONTROL_CODE_ENABLE_PROVIDER) || (ControlCode == EVENT_CONTROL_CODE_CAPTURE_STATE)): https://github.com/dotnet/coreclr/blob/ef1e2ab328087c61a6878c1e84f4fc5d710aebce/src/vm/eventtrace.cpp#L4400

Now in the current version of the code, ControlCode is not checked anymore and so ForceGC is call even when disabling the keyword: https://github.com/dotnet/runtime/blob/main/src/coreclr/vm/eventtrace.cpp#L2425

Reproduction Steps

Run dotnet-trace collect -p <pid> --providers Microsoft-Windows-DotNETRuntime:800000.

Expected behavior

One GC is triggered when opening the session.

Actual behavior

One GC is triggered when opening the session, but then another one is triggered when closing the session.

Regression?

The problem was not there in .NET Framework, I believe it was introduced with eventpipes.

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 9, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 9, 2024
@danmoseley danmoseley added area-GC-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Mar 9, 2024
@tommcdon tommcdon added this to the 9.0.0 milestone Mar 19, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Mar 19, 2024
chrisnas added a commit to chrisnas/runtime that referenced this issue May 23, 2024
- dotnet#99487: avoid double GC
- dotnet#102572: handle client sequence number
@tommcdon tommcdon modified the milestones: 9.0.0, 10.0.0 Jul 23, 2024
@mdh1418 mdh1418 assigned mdh1418 and unassigned davmason Oct 29, 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 Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Diagnostics-coreclr in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants