From 0b12684a4a79b93444a3517e4a53e543ce736388 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 2 Dec 2022 14:52:34 -0500 Subject: [release-branch.go1.18] cmd/go: skip TestScript/mod_replace_gopkgin (Until it can be made hermetic.) The gopkg.in service has had a lot of flakiness lately. Go users in general are isolated from that flakiness by the Go module mirror (proxy.golang.org), but this test intentionally bypasses the module mirror because the mirror itself uses cmd/go to download the module. In the long term, we can redirect the gopkg.in URL to the local (in-process) vcweb server added for #27494. In the meantime, let's skip the test to reduce the impact of upstream outages. Fixes #57057. Updates #54503. Change-Id: Icf3de7ca416db548e53864a71776fe22b444fcea Reviewed-on: https://go-review.googlesource.com/c/go/+/454503 Run-TryBot: Bryan Mills Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Heschi Kreinick (cherry picked from commit c5f5cb659adda026d01b7fa9bd39b2ad3b58c5bf) Reviewed-on: https://go-review.googlesource.com/c/go/+/454840 --- src/cmd/go/testdata/script/mod_replace_gopkgin.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd/go') diff --git a/src/cmd/go/testdata/script/mod_replace_gopkgin.txt b/src/cmd/go/testdata/script/mod_replace_gopkgin.txt index df752d9716..8cb034c36c 100644 --- a/src/cmd/go/testdata/script/mod_replace_gopkgin.txt +++ b/src/cmd/go/testdata/script/mod_replace_gopkgin.txt @@ -4,6 +4,9 @@ # even if there is an explicit go.mod file containing the # gopkg.in path. +skip 'skipping test that depends on an unreliable third-party server; see https://go.dev/issue/54503' + # TODO(#54043): Make this test hermetic and re-enable it. + [short] skip [!net] skip [!exec:git] skip -- cgit v1.2.1 From 2b989668973ae2b00bdcb30cf2ed141da9d22655 Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 2 Dec 2022 14:11:00 -0500 Subject: [release-branch.go1.18] cmd/go: remove TestScript/version_buildvcs_git_gpg This was a regression test added for a 'git' command line used for build stamping. Unfortunately, 'gpg' has proved to be extremely fragile: * In recent versions, it appears to always require 'gpg-agent' to be installed for anything involving secret keys, but for some reason is not normally marked as requiring gpg-agent in Debian's package manager. * It tries to create a Unix domain socket in a subdirectory of $TMPDIR without checking the path length, which fails when $TMPDIR is too long to fit in the 'sun_path' field of a sockaddr_un struct (which typically tops out somewhere between 92 and 108 bytes). We could theoretically address those by artificially reducing the script's TMPDIR length and checking for gpg-agent in addition to gpg, but arguably those should both be fixed upstream instead. On balance, the incremental value that this test provides does not seem worth the complexity of dealing with such a fragile third-party tool. Updates #50675. Updates #48802. Updates #57034. Fixes #57054. Change-Id: Ia3288c2f84f8db86ddfa139b4d1c0112d67079ef Reviewed-on: https://go-review.googlesource.com/c/go/+/454502 TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills Auto-Submit: Bryan Mills Reviewed-by: Cherry Mui (cherry picked from commit 45f5ef4ed7a774b6911650319a265e17ee9e6e0e) Reviewed-on: https://go-review.googlesource.com/c/go/+/454956 --- .../testdata/script/version_buildvcs_git_gpg.txt | 105 --------------------- 1 file changed, 105 deletions(-) delete mode 100644 src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt (limited to 'src/cmd/go') diff --git a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt b/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt deleted file mode 100644 index dcf97d7c44..0000000000 --- a/src/cmd/go/testdata/script/version_buildvcs_git_gpg.txt +++ /dev/null @@ -1,105 +0,0 @@ -# This test checks that VCS information is stamped into Go binaries even when -# the current commit is signed and the use has configured git to display commit -# signatures. - -[!exec:git] skip -[!exec:gpg] skip -[short] skip -env GOBIN=$GOPATH/bin -env GNUPGHOME=$WORK/.gpupg -mkdir $GNUPGHOME -chmod 0700 $GNUPGHOME - -# Create GPG key -exec gpg --batch --passphrase '' --quick-generate-key gopher@golang.org -exec gpg --list-secret-keys --with-colons gopher@golang.org -cp stdout keyinfo.txt -go run extract_key_id.go keyinfo.txt -cp stdout keyid.txt - -# Initialize repo -cd repo/ -exec git init -exec git config user.email gopher@golang.org -exec git config user.name 'J.R. Gopher' -exec git config --add log.showSignature true -go run ../configure_signing_key.go ../keyid.txt - -# Create signed commit -cd a -exec git add -A -exec git commit -m 'initial commit' --gpg-sign -exec git log - -# Verify commit signature does not interfere with versioning -go install -go version -m $GOBIN/a -stdout '^\tbuild\tvcs\.revision=' -stdout '^\tbuild\tvcs\.time=' -stdout '^\tbuild\tvcs\.modified=false$' - --- repo/README -- -Far out in the uncharted backwaters of the unfashionable end of the western -spiral arm of the Galaxy lies a small, unregarded yellow sun. --- repo/a/go.mod -- -module example.com/a - -go 1.18 --- repo/a/a.go -- -package main - -func main() {} - --- extract_key_id.go -- -package main - -import "fmt" -import "io/ioutil" -import "os" -import "strings" - -func main() { - err := run(os.Args[1]) - if err != nil { - panic(err) - } -} - -func run(keyInfoFilePath string) error { - contents, err := ioutil.ReadFile(keyInfoFilePath) - if err != nil { - return err - } - lines := strings.Split(string(contents), "\n") - for _, line := range lines { - fields := strings.Split(line, ":") - if fields[0] == "sec" { - fmt.Print(fields[4]) - return nil - } - } - return fmt.Errorf("key ID not found in: %s", keyInfoFilePath) -} - --- configure_signing_key.go -- -package main - -import "io/ioutil" -import "os" -import "os/exec" - -func main() { - err := run(os.Args[1]) - if err != nil { - panic(err) - } -} - -func run(keyIdFilePath string) error { - keyId, err := ioutil.ReadFile(keyIdFilePath) - if err != nil { - return err - } - gitCmd := exec.Command("git", "config", "user.signingKey", string(keyId)) - return gitCmd.Run() -} -- cgit v1.2.1 From 63dd776220bb3a443e6b5c0766a389ec33dc4b69 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Wed, 16 Nov 2022 14:53:39 -0600 Subject: [release-branch.go1.18] cmd/link/internal/ppc64: fix trampoline reuse distance calculation If a compatible trampoline has been inserted by a previously laid function in the same section, and is known to be sufficiently close, it can be reused. When testing if the trampoline can be reused, the addend of the direct call should be ignored. It is already encoded in the trampoline. If the addend is non-zero, and the target sufficiently far away, and just beyond direct call reach, this may cause the trampoline to be incorrectly reused. This was observed on go1.17.13 and openshift-installer commit f3c53b382 building in release mode with the following error: github.com/aliyun/alibaba-cloud-sdk-go/services/cms.(*Client).DescribeMonitoringAgentAccessKeyWithChan.func1: direct call too far: runtime.duffzero+1f0-tramp0-1 -2000078 Fixes #56833 Change-Id: I54af957302506d4e3cd5d3121542c83fe980e912 Reviewed-on: https://go-review.googlesource.com/c/go/+/451415 Reviewed-by: Cherry Mui Run-TryBot: Paul Murphy TryBot-Result: Gopher Robot Reviewed-by: Lynn Boger Reviewed-by: Than McIntosh Reviewed-on: https://go-review.googlesource.com/c/go/+/451916 Reviewed-by: Joedian Reid --- .../go/testdata/script/trampoline_reuse_test.txt | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 src/cmd/go/testdata/script/trampoline_reuse_test.txt (limited to 'src/cmd/go') diff --git a/src/cmd/go/testdata/script/trampoline_reuse_test.txt b/src/cmd/go/testdata/script/trampoline_reuse_test.txt new file mode 100644 index 0000000000..bca897c16d --- /dev/null +++ b/src/cmd/go/testdata/script/trampoline_reuse_test.txt @@ -0,0 +1,100 @@ +# Verify PPC64 does not reuse a trampoline which is too far away. +# This tests an edge case where the direct call relocation addend should +# be ignored when computing the distance from the direct call to the +# already placed trampoline +[short] skip +[!ppc64] [!ppc64le] skip +[aix] skip + +# Note, this program does not run. Presumably, 'DWORD $0' is simpler to +# assembly 2^26 or so times. +# +# We build something which should be laid out as such: +# +# bar.Bar +# main.Func1 +# bar.Bar+400-tramp0 +# main.BigAsm +# main.Func2 +# bar.Bar+400-tramp1 +# +# bar.Bar needs to be placed far enough away to generate relocations +# from main package calls. and main.Func1 and main.Func2 are placed +# a bit more than the direct call limit apart, but not more than 0x400 +# bytes beyond it (to verify the reloc calc). + +go build + +-- go.mod -- + +module foo + +go 1.19 + +-- main.go -- + +package main + +import "foo/bar" + +func Func1() + +func main() { + Func1() + bar.Bar2() +} + +-- foo.s -- + +TEXT main·Func1(SB),0,$0-0 + CALL bar·Bar+0x400(SB) + CALL main·BigAsm(SB) +// A trampoline will be placed here to bar.Bar + +// This creates a gap sufficiently large to prevent trampoline reuse +#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; +#define NOP256 NOP64 NOP64 NOP64 NOP64 +#define NOP2S10 NOP256 NOP256 NOP256 NOP256 +#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10 +#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12 +#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14 +#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16 +#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18 +#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20 +#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22 +#define BIGNOP NOP2S24 NOP2S24 +TEXT main·BigAsm(SB),0,$0-0 + // Fill to the direct call limit so Func2 must generate a new trampoline. + // As the implicit trampoline above is just barely unreachable. + BIGNOP + MOVD $main·Func2(SB), R3 + +TEXT main·Func2(SB),0,$0-0 + CALL bar·Bar+0x400(SB) +// Another trampoline should be placed here. + +-- bar/bar.s -- + +#define NOP64 DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; DWORD $0; +#define NOP256 NOP64 NOP64 NOP64 NOP64 +#define NOP2S10 NOP256 NOP256 NOP256 NOP256 +#define NOP2S12 NOP2S10 NOP2S10 NOP2S10 NOP2S10 +#define NOP2S14 NOP2S12 NOP2S12 NOP2S12 NOP2S12 +#define NOP2S16 NOP2S14 NOP2S14 NOP2S14 NOP2S14 +#define NOP2S18 NOP2S16 NOP2S16 NOP2S16 NOP2S16 +#define NOP2S20 NOP2S18 NOP2S18 NOP2S18 NOP2S18 +#define NOP2S22 NOP2S20 NOP2S20 NOP2S20 NOP2S20 +#define NOP2S24 NOP2S22 NOP2S22 NOP2S22 NOP2S22 +#define BIGNOP NOP2S24 NOP2S24 NOP2S10 +// A very big not very interesting function. +TEXT bar·Bar(SB),0,$0-0 + BIGNOP + +-- bar/bar.go -- + +package bar + +func Bar() + +func Bar2() { +} -- cgit v1.2.1