diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-03 17:26:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-03 17:26:57 +0200 |
| commit | b212cd054ee567038243b8fc0eca925493b8c692 (patch) | |
| tree | 9c6060e717216a99acd5ffd4d77455caef920a03 | |
| parent | 06fba4fb0d30bac8e6a3d45fd002b9f1b8284e26 (diff) | |
| parent | bcbcbfff4452ca34c4cee6a7737141df39591668 (diff) | |
| download | rust-b212cd054ee567038243b8fc0eca925493b8c692.tar.gz rust-b212cd054ee567038243b8fc0eca925493b8c692.zip | |
Rollup merge of #127270 - klensy:PROCESS_MEMORY_COUNTERS, r=Kobzol
bootstrap: pass correct struct size to winapi Into K32GetProcessMemoryInfo (https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo) passed in pointer to PROCESS_MEMORY_COUNTERS, but size of PROCESS_MEMORY_COUNTERS_EX, whoops.
| -rw-r--r-- | src/bootstrap/src/bin/rustc.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs index 009e62469b4..46e845f77ae 100644 --- a/src/bootstrap/src/bin/rustc.rs +++ b/src/bootstrap/src/bin/rustc.rs @@ -317,9 +317,7 @@ fn format_rusage_data(child: Child) -> Option<String> { use windows::{ Win32::Foundation::HANDLE, - Win32::System::ProcessStatus::{ - K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS, PROCESS_MEMORY_COUNTERS_EX, - }, + Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS}, Win32::System::Threading::GetProcessTimes, Win32::System::Time::FileTimeToSystemTime, }; @@ -331,6 +329,7 @@ fn format_rusage_data(child: Child) -> Option<String> { let mut kernel_filetime = Default::default(); let mut kernel_time = Default::default(); let mut memory_counters = PROCESS_MEMORY_COUNTERS::default(); + let memory_counters_size = std::mem::size_of_val(&memory_counters); unsafe { GetProcessTimes( @@ -347,15 +346,9 @@ fn format_rusage_data(child: Child) -> Option<String> { // Unlike on Linux with RUSAGE_CHILDREN, this will only return memory information for the process // with the given handle and none of that process's children. - unsafe { - K32GetProcessMemoryInfo( - handle, - &mut memory_counters, - std::mem::size_of::<PROCESS_MEMORY_COUNTERS_EX>() as u32, - ) - } - .ok() - .ok()?; + unsafe { K32GetProcessMemoryInfo(handle, &mut memory_counters, memory_counters_size as u32) } + .ok() + .ok()?; // Guide on interpreting these numbers: // https://docs.microsoft.com/en-us/windows/win32/psapi/process-memory-usage-information |
