{"record":{"id":"5e812eaab66b36e6","repo":"rakyll/hey","slug":"call-failed","errorCode":null,"errorMessage":"call failed","messagePattern":"call failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"requester/now_windows.go","lineNumber":44,"sourceCode":"\tsyscall.Syscall(queryPerformanceCounterProc.Addr(), 1, uintptr(unsafe.Pointer(&now)), 0, 0)\n\treturn time.Duration(now) * time.Second / (time.Duration(qpcFrequency) * time.Nanosecond)\n}\n\n// precision timing\nvar (\n\tmodkernel32                   = syscall.NewLazyDLL(\"kernel32.dll\")\n\tqueryPerformanceFrequencyProc = modkernel32.NewProc(\"QueryPerformanceFrequency\")\n\tqueryPerformanceCounterProc   = modkernel32.NewProc(\"QueryPerformanceCounter\")\n\n\tqpcFrequency = queryPerformanceFrequency()\n)\n\n// queryPerformanceFrequency returns frequency in ticks per second\nfunc queryPerformanceFrequency() int64 {\n\tvar freq int64\n\tr1, _, _ := syscall.Syscall(queryPerformanceFrequencyProc.Addr(), 1, uintptr(unsafe.Pointer(&freq)), 0, 0)\n\tif r1 == 0 {\n\t\tpanic(\"call failed\")\n\t}\n\treturn freq\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/rakyll/hey/blob/5626f79b8698df6daf9b25799c9805c6acc96740/requester/now_windows.go#L26-L48","documentation":"On Windows, hey's high-resolution timing uses QueryPerformanceFrequency via syscall.Syscall. The Win32 contract is that QueryPerformanceFrequency returns nonzero on success; if it returns 0 the call failed and this code panics with \"call failed\" because the QPC frequency is essential for the now() clock and there is no meaningful fallback. Because it is a panic (not an error return), the whole process aborts.","triggerScenarios":"queryPerformanceFrequency calls syscall.Syscall on queryPerformanceFrequencyProc and the underlying Win32 API returns r1 == 0 — i.e. Windows itself failed to report the performance-counter frequency. Note the panic lives in queryPerformanceFrequency, which qpcFrequency calls lazily when the requester builds its clock.","commonSituations":"Running a build on an unsupported or broken Windows version where QueryPerformanceFrequency is unavailable (extremely old Windows without QPC support), corrupted system state/driver issues affecting the HAL, or running under an emulation/virtualization layer where the syscall fails; also a mismatched proc address if the syscall.NewLazyDLL lookup silently returned a stub.","solutions":["Verify the Windows version supports QueryPerformanceFrequency (Windows 2000+ / XP+); patch the OS to a supported build.","Re-run on real hardware or a properly configured VM — check hypervisor/virtualization settings, as broken HAL or paravirtualized clocks can fail the syscall.","Update Windows system drivers/HAL or run sfc /scannow to repair system files that may be corrupting kernel time services.","Rebuild hey for the correct platform (GOOS=windows) so the lazy proc lookup binds to the real kernel32.QueryPerformanceFrequency rather than a stub.","If maintaining the library, replace the panic with a non-fatal fallback clock (e.g. time.Now) so a QPC failure degrades timing resolution instead of crashing."],"exampleFix":"// before\nfunc queryPerformanceFrequency() int64 {\n\tvar freq int64\n\tr1, _, _ := syscall.Syscall(queryPerformanceFrequencyProc.Addr(), 1, uintptr(unsafe.Pointer(&freq)), 0, 0)\n\tif r1 == 0 {\n\t\tpanic(\"call failed\")\n\t}\n\treturn freq\n}\n\n// after\nfunc queryPerformanceFrequency() int64 {\n\tvar freq int64\n\tr1, _, err := syscall.SyscallN(queryPerformanceFrequencyProc.Addr(), uintptr(unsafe.Pointer(&freq)))\n\tif r1 == 0 {\n\t\tfreq = int64(time.Second) // safe fallback: 1 tick == 1 ns via time.Now clock\n\t\t_ = err\n\t}\n\treturn freq\n}","handlingStrategy":"fallback","validationCode":"// Pre-flight check on Windows before running the load test:\n// ensure the process can initialize QPC (Go: golang.org/x/sys/windows)\nfunc qpcAvailable() bool {\n\tvar freq int64\n\t// QueryPerformanceFrequency documented to succeed on Win2000+; verify on target host\n\treturn windows.QueryPerformanceFrequency(&freq) == nil && freq > 0\n}","typeGuard":null,"tryCatchPattern":"// Wrap the load-test run so a QPC panic is converted to a diagnosable failure:\nfunc runSafe(run func()) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tif fmt.Sprint(r) == \"call failed\" {\n\t\t\t\tfmt.Fprintln(os.Stderr, \"QueryPerformanceFrequency failed on this Windows host; update OS/VM or use a non-Windows host\")\n\t\t\t\tos.Exit(1)\n\t\t\t}\n\t\t\tpanic(r)\n\t\t}\n\t}()\n\trun()\n}","preventionTips":["Run hey on a supported, patched Windows version (or Linux/macOS) — QPC failure indicates an OS/HAL problem, not a usage error.","Avoid broken paravirtualized clocks: configure the VM with a reliable time source before load testing.","Pin builds per-platform so GOOS/GOARCH always match the host and lazy DLL bindings resolve to real kernel32 exports.","Monitor for the panic message 'call failed' in CI on Windows runners and fall back to a non-Windows runner."],"tags":["windows","syscall","panic","high-resolution-timer"],"backgroundTag":"qpc-syscall-failed","analyzedSha":"5626f79b8698df6daf9b25799c9805c6acc96740","analyzedAt":"2026-09-02T10:01:29.707Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}