[go] os/exec: second call to Cmd.Start is always an error

8 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Dec 9, 2025, 10:10:24 AM (9 days ago) Dec 9
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Alan Donovan has uploaded the change for review

Commit message

os/exec: second call to Cmd.Start is always an error

Previously it would return an error only if the first call
resulted in process creation, contra the intent of the
comment at exec.Cmd:

// A Cmd cannot be reused after calling its [Cmd.Start], [Cmd.Run],
// [Cmd.Output], or [Cmd.CombinedOutput] methods.

Fixes #76746
Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c

Change diff

diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go
index e84ebfc..06c1839 100644
--- a/src/os/exec/exec.go
+++ b/src/os/exec/exec.go
@@ -102,6 +102,7 @@
"runtime"
"strconv"
"strings"
+ "sync/atomic"
"syscall"
"time"
)
@@ -354,6 +355,9 @@
// the work of resolving the extension, so Start doesn't need to do it again.
// This is only used on Windows.
cachedLookExtensions struct{ in, out string }
+
+ // startCalled records that Start was attempted, regardless of outcome.
+ startCalled atomic.Bool
}

// A ctxResult reports the result of watching the Context associated with a
@@ -635,7 +639,8 @@
func (c *Cmd) Start() error {
// Check for doubled Start calls before we defer failure cleanup. If the prior
// call to Start succeeded, we don't want to spuriously close its pipes.
- if c.Process != nil {
+ // It is an error to call Start twice even if the first call did not create a process.
+ if c.startCalled.Swap(true) {
return errors.New("exec: already started")
}

diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go
index 1decebd..3c71ab0 100644
--- a/src/os/exec/exec_test.go
+++ b/src/os/exec/exec_test.go
@@ -1839,3 +1839,19 @@
}
})
}
+
+// Calling Start twice is an error, regardless of outcome.
+func TestStart_twice(t *testing.T) {
+ testenv.MustHaveExec(t)
+
+ cmd := exec.Command("/bin/nonesuch")
+ for i, want := range []string{
+ "fork/exec /bin/nonesuch: no such file or directory",
+ "exec: already started",
+ } {
+ err := cmd.Start()
+ if got := fmt.Sprint(err); got != want {
+ t.Errorf("Start call #%d return err %q, want %q", i+1, got, want)
+ }
+ }
+}

Change information

Files:
  • M src/os/exec/exec.go
  • M src/os/exec/exec_test.go
Change size: S
Delta: 2 files changed, 22 insertions(+), 1 deletion(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
Gerrit-Change-Number: 728642
Gerrit-PatchSet: 1
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Alan Donovan (Gerrit)

unread,
Dec 9, 2025, 10:17:27 AM (9 days ago) Dec 9
to goph...@pubsubhelper.golang.org, Damien Neil, Go LUCI, golang-co...@googlegroups.com
Attention needed from Damien Neil

Alan Donovan added 1 comment

File src/os/exec/exec.go
Line 360, Patchset 1 (Latest): startCalled atomic.Bool
Alan Donovan . unresolved

Hmm, I'm not sure this need to be atomic. There shouldn't be races on calls to Start et al.

Open in Gerrit

Related details

Attention is currently required from:
  • Damien Neil
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Tue, 09 Dec 2025 15:17:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 9, 2025, 10:27:52 AM (9 days ago) Dec 9
    to goph...@pubsubhelper.golang.org, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil

    Alan Donovan added 1 comment

    File src/os/exec/exec_test.go
    Line 1849, Patchset 1 (Latest): "fork/exec /bin/nonesuch: no such file or directory",
    Alan Donovan . unresolved

    Windows spells this `exec: "/bin/nonesuch": executable file not found in %PATH%`

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Tue, 09 Dec 2025 15:27:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Ефим Верзаков (Gerrit)

    unread,
    Dec 10, 2025, 2:51:46 PM (8 days ago) Dec 10
    to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Damien Neil

    Ефим Верзаков added 1 comment

    Patchset-level comments
    File-level comment, Patchset 1 (Latest):
    Ефим Верзаков . unresolved

    Can we add runc mantainer Kirill Kolyshkin as a Reviewer? The initial "bug" situation was found by testing runc. Also i suspect this can influence on some Kubernetes clusters based on Ubuntu 20.04 with runc 1.4 https://github.com/opencontainers/runc/issues/5060 because the setnsProcess is used to exec command into the container.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Damien Neil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Wed, 10 Dec 2025 19:51:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Ефим Верзаков (Gerrit)

    unread,
    Dec 10, 2025, 3:01:20 PM (8 days ago) Dec 10
    to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Damien Neil

    Ефим Верзаков added 1 comment

    File src/os/exec/exec.go
    Line 655, Patchset 1 (Latest): }
    Ефим Верзаков . unresolved

    Can you add c.goroutine = nil here? I think it is not good to keep inappropriate fields in Cmd struct (funcs' pipes are closed in this defer). In successful scenario they are also deleted (line 768).

    Gerrit-Comment-Date: Wed, 10 Dec 2025 20:01:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Ефим Верзаков (Gerrit)

    unread,
    Dec 10, 2025, 3:53:20 PM (8 days ago) Dec 10
    to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Damien Neil

    Ефим Верзаков added 1 comment

    Patchset-level comments
    File-level comment, Patchset 1 (Latest):
    Ефим Верзаков . unresolved

    In Issue you have said that the user should recreate the New Cmd object. However, in runc Cmd object is created early https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/container_linux.go#L616 before it is started https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/process_linux.go#L370 . So, it will be more hard to recreate then copy. As for copy mechanism i have several notes. If it is just var cmd2 Cmd = *cmd1 then childIOFiles and parentIOPipes will be copied with its elements. And if Stdin/StdoutPipe is called before copy, then their Files will be closed twice in defer function. Also, by default Cancel funtion will try to kill the Process from the first cmd. If the first Cmd Starts returns an error then it will be nil pointer dereference. Link to playground https://play.golang.com/p/lJ6ivb8vhW_f . Also, i do not understand how to refresh ctx. I think it is need to implement copy mechanism or to document about hidden problems.

    Gerrit-Comment-Date: Wed, 10 Dec 2025 20:53:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 10, 2025, 4:09:58 PM (8 days ago) Dec 10
    to goph...@pubsubhelper.golang.org, Ефим Верзаков, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil and Ефим Верзаков

    Alan Donovan added 1 comment

    Patchset-level comments
    Ефим Верзаков . unresolved

    In Issue you have said that the user should recreate the New Cmd object. However, in runc Cmd object is created early https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/container_linux.go#L616 before it is started https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/process_linux.go#L370 . So, it will be more hard to recreate then copy. As for copy mechanism i have several notes. If it is just var cmd2 Cmd = *cmd1 then childIOFiles and parentIOPipes will be copied with its elements. And if Stdin/StdoutPipe is called before copy, then their Files will be closed twice in defer function. Also, by default Cancel funtion will try to kill the Process from the first cmd. If the first Cmd Starts returns an error then it will be nil pointer dereference. Link to playground https://play.golang.com/p/lJ6ivb8vhW_f . Also, i do not understand how to refresh ctx. I think it is need to implement copy mechanism or to document about hidden problems.

    Alan Donovan

    I think that runc is not using Cmd in a manner consistent with its documentation, and should be changed. I agree that copying the Cmd is not a solution, because it will copy the hidden fields too (and in general this is not a safe operation: consider a struct that contains a pointer to itself). But copying only the public fields seems like a safe solution. Alternatively, use some other structure to hold all the information needed to populate a Cmd, and create the Cmd just before you call Start.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Wed, 10 Dec 2025 21:09:55 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ефим Верзаков <efimve...@gmail.com>
    unsatisfied_requirement
    open
    diffy

    Damien Neil (Gerrit)

    unread,
    Dec 11, 2025, 1:39:22 PM (7 days ago) Dec 11
    to Alan Donovan, goph...@pubsubhelper.golang.org, Ефим Верзаков, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Ефим Верзаков

    Damien Neil added 2 comments

    Patchset-level comments
    Damien Neil . unresolved

    Windows failures seem real?

    File src/os/exec/exec.go
    Line 360, Patchset 1 (Latest): startCalled atomic.Bool
    Alan Donovan . resolved

    Hmm, I'm not sure this need to be atomic. There shouldn't be races on calls to Start et al.

    Damien Neil

    Seems harmless for it to be atomic, and this will ensure that misuse is detected.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Thu, 11 Dec 2025 18:39:17 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Alan Donovan <adon...@google.com>
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 12, 2025, 10:44:38 AM (6 days ago) Dec 12
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Alan Donovan and Ефим Верзаков

    Alan Donovan uploaded new patchset

    Alan Donovan uploaded patch set #2 to this change.
    Following approvals got outdated and were removed:
    • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 2
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 12, 2025, 10:46:15 AM (6 days ago) Dec 12
    to goph...@pubsubhelper.golang.org, Kirill Kolyshkin, Ефим Верзаков, Go LUCI, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Kirill Kolyshkin and Ефим Верзаков

    Alan Donovan added 4 comments

    Patchset-level comments
    File-level comment, Patchset 1:
    Damien Neil . resolved

    Windows failures seem real?

    Alan Donovan

    Oh, no doubt, I was just taking my sweet time. Fixed.

    File-level comment, Patchset 1:
    Ефим Верзаков . unresolved

    Can we add runc mantainer Kirill Kolyshkin as a Reviewer? The initial "bug" situation was found by testing runc. Also i suspect this can influence on some Kubernetes clusters based on Ubuntu 20.04 with runc 1.4 https://github.com/opencontainers/runc/issues/5060 because the setnsProcess is used to exec command into the container.

    Alan Donovan

    By all means we can add Kirill as a reviewer; done.

    File src/os/exec/exec.go
    Line 360, Patchset 1: startCalled atomic.Bool
    Alan Donovan . resolved

    Hmm, I'm not sure this need to be atomic. There shouldn't be races on calls to Start et al.

    Damien Neil

    Seems harmless for it to be atomic, and this will ensure that misuse is detected.

    Alan Donovan

    OK.

    File src/os/exec/exec_test.go
    Line 1849, Patchset 1: "fork/exec /bin/nonesuch: no such file or directory",
    Alan Donovan . resolved

    Windows spells this `exec: "/bin/nonesuch": executable file not found in %PATH%`

    Alan Donovan

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 1
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 15:46:12 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ефим Верзаков <efimve...@gmail.com>
    Comment-In-Reply-To: Damien Neil <dn...@google.com>
    Comment-In-Reply-To: Alan Donovan <adon...@google.com>
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 12, 2025, 10:52:16 AM (6 days ago) Dec 12
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Alan Donovan, Damien Neil, Kirill Kolyshkin and Ефим Верзаков

    Alan Donovan uploaded new patchset

    Alan Donovan uploaded patch set #3 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Damien Neil
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 3
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 12, 2025, 10:53:13 AM (6 days ago) Dec 12
    to goph...@pubsubhelper.golang.org, Go LUCI, Kirill Kolyshkin, Ефим Верзаков, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Alan Donovan, Damien Neil, Kirill Kolyshkin and Ефим Верзаков

    Alan Donovan voted and added 1 comment

    Votes added by Alan Donovan

    Commit-Queue+1

    1 comment

    File src/os/exec/exec.go
    Line 655, Patchset 1: }
    Ефим Верзаков . unresolved

    Can you add c.goroutine = nil here? I think it is not good to keep inappropriate fields in Cmd struct (funcs' pipes are closed in this defer). In successful scenario they are also deleted (line 768).

    Alan Donovan

    Done.

    Damien, is fixing this additional minor lifetime/finalization issue within scope for a freeze CL?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Damien Neil
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 2
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 15:53:10 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Ефим Верзаков <efimve...@gmail.com>
    unsatisfied_requirement
    open
    diffy

    Damien Neil (Gerrit)

    unread,
    Dec 15, 2025, 4:02:41 PM (3 days ago) Dec 15
    to Alan Donovan, goph...@pubsubhelper.golang.org, Go LUCI, Kirill Kolyshkin, Ефим Верзаков, golang-co...@googlegroups.com
    Attention needed from Alan Donovan, Kirill Kolyshkin and Ефим Верзаков

    Damien Neil added 2 comments

    Patchset-level comments
    File-level comment, Patchset 3 (Latest):
    Damien Neil . unresolved

    Test failure seems real?

    File src/os/exec/exec.go
    Line 655, Patchset 1: }
    Ефим Верзаков . resolved

    Can you add c.goroutine = nil here? I think it is not good to keep inappropriate fields in Cmd struct (funcs' pipes are closed in this defer). In successful scenario they are also deleted (line 768).

    Alan Donovan

    Done.

    Damien, is fixing this additional minor lifetime/finalization issue within scope for a freeze CL?

    Damien Neil

    I think this is fine, given how trivial the change is.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 3
    Gerrit-Owner: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Alan Donovan <adon...@google.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Kirill Kolyshkin <koly...@gmail.com>
    Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
    Gerrit-Attention: Alan Donovan <adon...@google.com>
    Gerrit-Comment-Date: Mon, 15 Dec 2025 21:02:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Ефим Верзаков <efimve...@gmail.com>
    Comment-In-Reply-To: Alan Donovan <adon...@google.com>
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 16, 2025, 1:33:59 PM (2 days ago) Dec 16
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Alan Donovan, Kirill Kolyshkin and Ефим Верзаков

    Alan Donovan uploaded new patchset

    Alan Donovan uploaded patch set #4 to this change.
    Following approvals got outdated and were removed:
    • TryBots-Pass: LUCI-TryBot-Result-1 by Go LUCI
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Alan Donovan
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
    Gerrit-Change-Number: 728642
    Gerrit-PatchSet: 4
    unsatisfied_requirement
    open
    diffy

    Alan Donovan (Gerrit)

    unread,
    Dec 16, 2025, 1:34:19 PM (2 days ago) Dec 16
    to goph...@pubsubhelper.golang.org, Go LUCI, Kirill Kolyshkin, Ефим Верзаков, Damien Neil, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Kirill Kolyshkin and Ефим Верзаков

    Alan Donovan added 3 comments

    Patchset-level comments
    File-level comment, Patchset 1:
    Ефим Верзаков . resolved

    In Issue you have said that the user should recreate the New Cmd object. However, in runc Cmd object is created early https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/container_linux.go#L616 before it is started https://github.com/opencontainers/runc/blob/v1.4.0/libcontainer/process_linux.go#L370 . So, it will be more hard to recreate then copy. As for copy mechanism i have several notes. If it is just var cmd2 Cmd = *cmd1 then childIOFiles and parentIOPipes will be copied with its elements. And if Stdin/StdoutPipe is called before copy, then their Files will be closed twice in defer function. Also, by default Cancel funtion will try to kill the Process from the first cmd. If the first Cmd Starts returns an error then it will be nil pointer dereference. Link to playground https://play.golang.com/p/lJ6ivb8vhW_f . Also, i do not understand how to refresh ctx. I think it is need to implement copy mechanism or to document about hidden problems.

    Alan Donovan

    I think that runc is not using Cmd in a manner consistent with its documentation, and should be changed. I agree that copying the Cmd is not a solution, because it will copy the hidden fields too (and in general this is not a safe operation: consider a struct that contains a pointer to itself). But copying only the public fields seems like a safe solution. Alternatively, use some other structure to hold all the information needed to populate a Cmd, and create the Cmd just before you call Start.

    Alan Donovan

    Acknowledged

    File-level comment, Patchset 1:
    Ефим Верзаков . resolved

    Can we add runc mantainer Kirill Kolyshkin as a Reviewer? The initial "bug" situation was found by testing runc. Also i suspect this can influence on some Kubernetes clusters based on Ubuntu 20.04 with runc 1.4 https://github.com/opencontainers/runc/issues/5060 because the setnsProcess is used to exec command into the container.

    Alan Donovan

    By all means we can add Kirill as a reviewer; done.

    Alan Donovan

    Done

    File-level comment, Patchset 3:
    Damien Neil . resolved

    Test failure seems real?

    Alan Donovan

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Kirill Kolyshkin
    • Ефим Верзаков
    Submit Requirements:
      • requirement is not satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement is not satisfiedReview-Enforcement
      • requirement is not satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
      Gerrit-Change-Number: 728642
      Gerrit-PatchSet: 3
      Gerrit-Owner: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Alan Donovan <adon...@google.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
      Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
      Gerrit-Attention: Kirill Kolyshkin <koly...@gmail.com>
      Gerrit-Attention: Ефим Верзаков <efimve...@gmail.com>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Comment-Date: Tue, 16 Dec 2025 18:34:14 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Ефим Верзаков <efimve...@gmail.com>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages