{"record":{"id":"655065a88f7ea6d6","repo":"wasmerio/wasmer","slug":"wasi-platform-clock-time-get-wasi-clockid-proce","errorCode":null,"errorMessage":"wasi::platform_clock_time_get(wasi::Clockid::ProcessCputimeId, ..)","messagePattern":"wasi::platform_clock_time_get\\(wasi::Clockid::ProcessCputimeId, \\.\\.\\)","errorType":"panic","errorClass":"panic","httpStatus":null,"severity":"error","filePath":"lib/wasix/src/syscalls/windows.rs","lineNumber":47,"sourceCode":"    precision: Timestamp,\n) -> Result<i64, wasi::Errno> {\n    let nanos = match clock_id {\n        wasi::Snapshot0Clockid::Monotonic => {\n            let tick_ms =\n                unsafe { windows_sys::Win32::System::SystemInformation::GetTickCount64() };\n            tick_ms * 1_000_000\n        }\n        wasi::Snapshot0Clockid::Realtime => {\n            let duration = std::time::SystemTime::now()\n                .duration_since(std::time::UNIX_EPOCH)\n                .map_err(|e| {\n                    debug!(\"Error in wasi::platform_clock_time_get: {:?}\", e);\n                    wasi::Errno::Io\n                })?;\n            duration.as_nanos() as u64\n        }\n        wasi::Snapshot0Clockid::ProcessCputimeId => {\n            unimplemented!(\"wasi::platform_clock_time_get(wasi::Clockid::ProcessCputimeId, ..)\")\n        }\n        wasi::Snapshot0Clockid::ThreadCputimeId => {\n            unimplemented!(\"wasi::platform_clock_time_get(wasi::Clockid::ThreadCputimeId, ..)\")\n        }\n        _ => return Err(wasi::Errno::Inval),\n    };\n    Ok(nanos as i64)\n}\n","sourceCodeStart":29,"sourceCodeEnd":56,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/wasix/src/syscalls/windows.rs#L29-L56","documentation":"On Windows, wasix's platform_clock_time_get has no implementation for the ProcessCputimeId clock, so requesting process CPU time panics with this unimplemented! message. Other clocks (e.g. realtime/monotonic) are supported on Windows, but CPU-time clocks were never wired up.","triggerScenarios":"A WASI guest calling clock_time_get (snapshot0) with clock id ProcessCputimeId while the runtime executes the Windows code path in lib/wasix/src/syscalls/windows.rs.","commonSituations":"Guest programs that measure their own CPU usage (profilers, benchmarking code, runtimes like Node's process.cpuUsage equivalents) running under Wasmer on Windows.","solutions":["Avoid requesting ProcessCputimeId on Windows; use MonotonicClock/Realtime clocks instead.","Guard the guest code with a platform check and fall back to wall-clock time on Windows.","Implement the Windows variant in windows.rs using GetProcessTimes() and return the CPU time as nanoseconds instead of panicking."],"exampleFix":"// before\nwasi::Snapshot0Clockid::ProcessCputimeId => {\n    unimplemented!(\"wasi::platform_clock_time_get(wasi::Clockid::ProcessCputimeId, ..)\")\n}\n// after (Windows implementation idea)\nwasi::Snapshot0Clockid::ProcessCputimeId => {\n    let mut creation = 0; let mut exit = 0; let mut kernel = 0; let mut user = 0;\n    unsafe { GetProcessTimes(GetCurrentProcess(), &mut creation, &mut exit, &mut kernel, &mut user) };\n    (user.saturating_add(kernel)) * 100 // FILETIME 100ns -> ns\n}","handlingStrategy":"fallback","validationCode":"// guest/host-side: detect Windows before requesting CPU-time clocks\n#[cfg(windows)]\nfn supports_cputime_clock() -> bool { false }\n#[cfg(not(windows))]\nfn supports_cputime_clock() -> bool { true }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never request ProcessCputimeId on Windows; prefer Monotonic/Realtime clocks","Compile-test WASIX workloads on Windows in CI","Feature-guest CPU-profiling code paths behind a non-Windows check"],"tags":["wasix","wasi","windows","clock","unimplemented","panic"],"backgroundTag":"unimplemented-platform-clock","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}