slimtoolkit/slim · error

failed to get system stat info for %s

Error message

failed to get system stat info for %s

What it means

A helper stats a file and then extracts the raw *syscall.Stat_t via FileInfo.Sys(). If the runtime type assertion fails, the caller cannot get device/inode info, so the function returns this error instead of a Stat_t. Like error 120 it only happens when Sys() is not a *syscall.Stat_t.

Source

Thrown at pkg/app/sensor/artifact/artifact.go:3591

			continue
		}

		inodes[info.Ino] = struct{}{}
		devices[uint64(info.Dev)] = struct{}{}
	}

	return inodes, devices
}

func getFileSysStats(fullName string) (*syscall.Stat_t, error) {
	statInfo, err := os.Stat(fullName)
	if err != nil {
		return nil, err
	}

	sysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)
	if !ok {
		return nil, fmt.Errorf("failed to get system stat info for %s", fullName)
	}

	return sysStatInfo, nil
}

func getFileDevice(fullName string) (uint64, error) {
	info, err := getFileSysStats(fullName)
	if err != nil {
		return 0, err
	}

	return uint64(info.Dev), nil
}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Run on Linux where Sys() is *syscall.Stat_t
  2. Check err from the preceding stat call first and return it instead of falling through to the assertion
  3. Skip or log-and-continue for files whose Sys() is not convertible

Example fix

// before
sysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)
if !ok {
	return nil, fmt.Errorf("failed to get system stat info for %s", fullName)
}
// after
if statInfo == nil || statInfo.Sys() == nil {
	return nil, fmt.Errorf("no stat info available for %s", fullName)
}
sysStatInfo, ok := statInfo.Sys().(*syscall.Stat_t)
if !ok {
	return nil, fmt.Errorf("failed to get system stat info for %s", fullName)
}
Defensive patterns

Strategy: type-guard

Validate before calling

fi, err := os.Stat(path)
if err == nil {
	if _, ok := fi.Sys().(*syscall.Stat_t); !ok { /* unsupported platform/fs */ }
}

Type guard

func statOf(fi os.FileInfo) (*syscall.Stat_t, bool) {
	s, ok := fi.Sys().(*syscall.Stat_t)
	return s, ok
}

Try / catch

_, err := getFileDevice(path)
if err != nil && strings.Contains(err.Error(), "failed to get system stat info") {
	// fall back to a default device id or skip the file
}

Prevention

When it happens

Trigger: Calling the helper (used by getFileDevice and artifact preparation) on a platform or filesystem where os.Lstat/stat returns a FileInfo whose Sys() is not *syscall.Stat_t.

Common situations: Running the sensor on darwin (Stat_t differs by GOOS build tags) or via overlay/FUSE layers; compiling with wrong GOOS.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/b310e6a56ffe359e. Report an issue: GitHub.