Skip to content

Incorrect Network Metrics on Windows 386 Due to Zeroed pad0for64_4for32 in mibIfRow2 #1865

@tianlin

Description

@tianlin

Describe the bug
When running on Windows 386 (32-bit) systems, network performance metrics retrieved via gopsutil appear incorrect. The root cause is that the mibIfRow2 struct’s field pad0for64_4for32 always returns zero on 32-bit systems, which leads to miscalculated values such as bandwidth or throughput.

To Reproduce

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v3/net"
)

func main() {
    counters, err := net.IOCounters(true)
    if err != nil {
        panic(err)
    }

    for _, counter := range counters {
        fmt.Printf("%+v\n", counter)
    }
}

Expected behavior
Network interface statistics (e.g., bytes sent/received) should be correctly reported, including on 32-bit Windows systems

Environment (please complete the following information):

  • Windows: Microsoft Windows [Version 10.0.19045.4291] (32-bit build)

Additional context
This issue occurs specifically on Windows 386 builds. Upon inspecting the MibIfRow2 structure in syscall usage, the field pad0for64_4for32 seems to always be zero on 32-bit, which suggests an architecture-specific issue with the struct alignment or access.
Cross-compilation was done using:

GOOS=windows GOARCH=386 go build -o netstat.exe main.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions