Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execing command in container: error stream protocol error: invalid exit code value 4294967295 #34

Open
113xiaoji opened this issue Jan 22, 2024 · 0 comments

Comments

@113xiaoji
Copy link

When using crictl to execute the exec command, there is an intermittent error reported:

execing command in container: error stream protocol error: invalid exit code value 4294967295

The relevant Go code snippet is as follows:

		return pidMonitor.pidPoller.Add(pidFD, func() error {
			execPid := e.Pid()

			status := 256

			event, err := execExitStore.GetExitedEvent(e.traceEventID)

			if err == nil && event.Pid == uint32(execPid) {
				status = int(event.ExitCode)
			}
			execExitStore.DeleteExitedEvent(e.traceEventID)

			e.SetExited(status)
			return nil
		})

When event, err := execExitStore.GetExitedEvent(e.traceEventID) encounters an error, the status is set to 256. The setExited method then calls unix.WaitStatus(status).ExitStatus(), as shown here:

func (e *execProcess) setExited(status int) {
    e.status = unix.WaitStatus(status).ExitStatus()
    e.exited = time.Now()

    if e.parent.platform != nil {
       e.parent.platform.ShutdownConsole(context.Background(), e.console)
    }
    close(e.waitBlock)
}

According to the source code, this will return -1:

func (w WaitStatus) ExitStatus() int {
	if !w.Exited() {
		return -1
	}
	return int(w>>shift) & 0xFF
}

As a result, the error message is generated:

execing command in container: error stream protocol error: invalid exit code value 4294967295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant