diff options
| author | Russ Cox <rsc@golang.org> | 2017-10-17 21:48:47 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2017-10-19 15:41:09 +0000 |
| commit | d790ea3ef1152cd8aded824ffca50a8c56577469 (patch) | |
| tree | 781bfc6c6d811812faf021a2fa93c5645d9d886a /src | |
| parent | 52dd39965e78260145091226490ee5510ea34ced (diff) | |
| download | go-d790ea3ef1152cd8aded824ffca50a8c56577469.tar.xz | |
cmd/go: skip updateBuildID on binaries we will run
On modern Unix systems it is basically impossible for a multithreaded
program to open a binary for write, close it, and then fork+exec that
same binary. So don't write the binary if we're going to fork+exec it.
This fixes the ETXTBSY flakes.
Fixes #22220.
See also #22315.
Change-Id: I6be4802fa174726ef2a93d5b2f09f708da897cdb
Reviewed-on: https://go-review.googlesource.com/71570
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/go/internal/work/build.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 50e3cc1d7d..11e4632815 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -1696,8 +1696,18 @@ func (b *Builder) build(a *Action) (err error) { } } - if err := b.updateBuildID(a, actionID, objpkg); err != nil { - return err + // Update the binary with the final build ID. + // But if OmitDebug is set, don't, because we set OmitDebug + // on binaries that we are going to run and then delete. + // There's no point in doing work on such a binary. + // Worse, opening the binary for write here makes it + // essentially impossible to safely fork+exec due to a fundamental + // incompatibility between ETXTBSY and threads on modern Unix systems. + // See golang.org/issue/22220. + if !a.Package.Internal.OmitDebug { + if err := b.updateBuildID(a, actionID, objpkg); err != nil { + return err + } } return nil |
