XTLS/Xray-core · error

failed to parse PID:

Error message

failed to parse PID: 

What it means

The PID string that findPidByInode produced could not be parsed by strconv.Atoi. findPidByInode derives pidStr from /proc directory names, which are always numeric, so in practice this fires only when pidStr came back malformed or the scan logic matched an unexpected entry. It is an internal-consistency failure, not a caller-input problem.

Source

Thrown at common/net/find_process_linux.go:79

	pidStr, err := findPidByInode(inode)
	if err != nil {
		return 0, "", "", errors.New("could not find PID for inode ", inode, ": ", err)
	}
	if pidStr == "" {
		return 0, "", "", errors.New("no process found for inode ", inode)
	}

	absPath, err := getAbsPath(pidStr)
	if err != nil {
		return 0, "", "", errors.New("could not get process name for PID ", pidStr, ":", err)
	}

	nameSplit := strings.Split(absPath, "/")
	procName := nameSplit[len(nameSplit)-1]

	pid, err := strconv.Atoi(pidStr)
	if err != nil {
		return 0, "", "", errors.New("failed to parse PID: ", err)
	}

	return pid, procName, absPath, nil
}

func formatLittleEndianString(addr net.IP, port Port) (string, error) {
	ip := addr
	var ipBytes []byte
	if ip.To4() != nil {
		ipBytes = ip.To4()
	} else {
		ipBytes = ip.To16()
	}
	if ipBytes == nil {
		return "", errors.New("invalid IP format for ", addr, ": ", ip)
	}

	for i, j := 0, len(ipBytes)-1; i < j; i, j = i+1, j-1 {

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Reproduce and log the exact pidStr value returned by findPidByInode to identify the malformed entry
  2. Check the kernel's /proc layout (ls /proc | grep -v '^[0-9]*$') for anomalies
  3. Treat as a non-fatal lookup failure and fall back to other routing rules
  4. Report upstream to xray-core with the kernel version if reproducible
Defensive patterns

Strategy: fallback

Type guard

func isPidParseError(err error) bool {
    return err != nil && strings.Contains(err.Error(), "failed to parse PID")
}

Try / catch

if err != nil && isPidParseError(err) {
    // internal inconsistency; log pidStr context and continue without process info
}

Prevention

When it happens

Trigger: A logic error or unexpected /proc layout (very old kernels, patched kernels with non-numeric entries) causing findPidByInode to return a non-numeric string; empty-string handling upstream would have hit the 'no process found' branch instead.

Common situations: Exotic or patched kernels with unusual /proc structures; essentially never on stock kernels. If you see it, capture pidStr from logs.

Understand the failure class

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/332d61a15ef9f0b4. Report an issue: GitHub.