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

fix Kernel32.GetSystemTimes usage on Windows #84526

Merged
merged 1 commit into from
Apr 9, 2023

Conversation

sxtfv
Copy link
Contributor

@sxtfv sxtfv commented Apr 8, 2023

systemUserTime & systemKernelTime were mixed up
The method is declared as

internal static partial class Kernel32
{
    [LibraryImport(Libraries.Kernel32, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    internal static partial bool GetSystemTimes(out long idle, out long kernel, out long user);
}

Method's documentation https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getsystemtimes

All other usages of this method are correct

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 8, 2023
@ghost
Copy link

ghost commented Apr 8, 2023

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

Issue Details

systemUserTime & systemKernelTime were mixed up
The method is declared as

internal static partial class Kernel32
{
    [LibraryImport(Libraries.Kernel32, SetLastError = true)]
    [return: MarshalAs(UnmanagedType.Bool)]
    internal static partial bool GetSystemTimes(out long idle, out long kernel, out long user);
}

Method's documentation https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getsystemtimes

All other usages of this method are correct

Author: sxtfv
Assignees: -
Labels:

area-System.Diagnostics.Tracing

Milestone: -

@sxtfv
Copy link
Contributor Author

sxtfv commented Apr 8, 2023

@dotnet-policy-service agree

@xtqqczze
Copy link
Contributor

xtqqczze commented Apr 9, 2023

Issue has been present since dotnet/coreclr#23680.

Copy link
Member

@tarekgh tarekgh left a comment

Choose a reason for hiding this comment

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

Thanks @sxtfv for the catch!

@tarekgh tarekgh merged commit 2d062c0 into dotnet:main Apr 9, 2023
@sxtfv sxtfv deleted the fix_windows_get_cpu_usage branch April 9, 2023 22:05
@ghost ghost locked as resolved and limited conversation to collaborators May 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics.Tracing community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants