{"record":{"id":"2f20656887e6b0a9","repo":"prometheus/node_exporter","slug":"length-of-bytes-received-from-sysctl-d-does-not","errorCode":null,"errorMessage":"length of bytes received from sysctl (%d) does not match expected bytes (long: %d), (int: %d)","messagePattern":"length of bytes received from sysctl \\((.+?)\\) does not match expected bytes \\(long: (.+?)\\), \\(int: (.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/sysctl_bsd.go","lineNumber":108,"sourceCode":"func (b bsdSysctl) getCLong() (float64, error) {\n\traw, err := unix.SysctlRaw(b.mib)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif len(raw) == C.sizeof_long {\n\t\treturn float64(*(*C.long)(unsafe.Pointer(&raw[0]))), nil\n\t}\n\n\tif len(raw) == C.sizeof_int {\n\t\t// This is valid for at least vfs.bufspace, and the default\n\t\t// long handler - which can clamp longs to 32-bits:\n\t\t//   https://github.com/freebsd/freebsd/blob/releng/10.3/sys/kern/vfs_bio.c#L338\n\t\t//   https://github.com/freebsd/freebsd/blob/releng/10.3/sys/kern/kern_sysctl.c#L1062\n\t\treturn float64(*(*C.int)(unsafe.Pointer(&raw[0]))), nil\n\t}\n\n\treturn 0, fmt.Errorf(\n\t\t\"length of bytes received from sysctl (%d) does not match expected bytes (long: %d), (int: %d)\",\n\t\tlen(raw),\n\t\tC.sizeof_long,\n\t\tC.sizeof_int,\n\t)\n\n}\n","sourceCodeStart":90,"sourceCodeEnd":116,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/sysctl_bsd.go#L90-L116","documentation":"BSD sysctl validation guard in getCLong: unix.SysctlRaw returned a byte buffer whose length is neither sizeof(long) nor sizeof(int), so the raw value cannot be safely reinterpreted as a numeric sysctl. This indicates a kernel/platform returning an unexpected size for MIB entry b.mib, or a sysctl whose value is not scalar numeric at all.","triggerScenarios":"Thrown at collector/sysctl_bsd.go:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the sysctl type: `sysctl -n <name>` / `sysctl -x` to see whether it is truly a long/int or a string/opaque value; if so, use the appropriate handler instead of the long getter.","Verify OS/arch support — unusual architectures may return different sizes; report/fix the size handling for that platform.","Update FreeBSD/OS version mappings if the kernel changed the value's representation."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}