Package init
This commit is contained in:
parent
c29de2f632
commit
f6abdd32e1
@ -0,0 +1,88 @@
|
||||
From edce31a2904846ae74e3c011f2cf5fddc963459e Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Jakub=20=C4=8Cajka?= <jcajka@redhat.com>
|
||||
Date: Thu, 22 Mar 2018 12:07:32 +0100
|
||||
Subject: [PATCH 1/3] Don't use the bundled tzdata at runtime, except for the
|
||||
internal test suite
|
||||
|
||||
---
|
||||
src/time/internal_test.go | 7 +++++--
|
||||
src/time/zoneinfo_test.go | 3 ++-
|
||||
src/time/zoneinfo_unix.go | 2 --
|
||||
3 files changed, 7 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/time/internal_test.go b/src/time/internal_test.go
|
||||
index 76d5524124..e81ace5f64 100644
|
||||
--- a/src/time/internal_test.go
|
||||
+++ b/src/time/internal_test.go
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
package time
|
||||
|
||||
+import "runtime"
|
||||
+
|
||||
func init() {
|
||||
// force US/Pacific for time zone tests
|
||||
ForceUSPacificForTesting()
|
||||
}
|
||||
|
||||
func initTestingZone() {
|
||||
- z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:])
|
||||
+ z, err := loadLocation("America/Los_Angeles", zoneSources)
|
||||
if err != nil {
|
||||
panic("cannot load America/Los_Angeles for testing: " + err.Error())
|
||||
}
|
||||
@@ -21,8 +23,9 @@ func initTestingZone() {
|
||||
var OrigZoneSources = zoneSources
|
||||
|
||||
func forceZipFileForTesting(zipOnly bool) {
|
||||
- zoneSources = make([]string, len(OrigZoneSources))
|
||||
+ zoneSources = make([]string, len(OrigZoneSources)+1)
|
||||
copy(zoneSources, OrigZoneSources)
|
||||
+ zoneSources = append(zoneSources, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
|
||||
if zipOnly {
|
||||
zoneSources = zoneSources[len(zoneSources)-1:]
|
||||
}
|
||||
diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go
|
||||
index 7a55d4f618..6063ca1195 100644
|
||||
--- a/src/time/zoneinfo_test.go
|
||||
+++ b/src/time/zoneinfo_test.go
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
+ "runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -128,7 +129,7 @@ func TestLoadLocationFromTZData(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
- tzinfo, err := time.LoadTzinfo(locationName, time.OrigZoneSources[len(time.OrigZoneSources)-1])
|
||||
+ tzinfo, err := time.LoadTzinfo(locationName, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go
|
||||
index 88313aa0ed..d9596115ef 100644
|
||||
--- a/src/time/zoneinfo_unix.go
|
||||
+++ b/src/time/zoneinfo_unix.go
|
||||
@@ -12,7 +12,6 @@
|
||||
package time
|
||||
|
||||
import (
|
||||
- "runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
@@ -22,7 +21,6 @@ var zoneSources = []string{
|
||||
"/usr/share/zoneinfo/",
|
||||
"/usr/share/lib/zoneinfo/",
|
||||
"/usr/lib/locale/TZ/",
|
||||
- runtime.GOROOT() + "/lib/time/zoneinfo.zip",
|
||||
}
|
||||
|
||||
func initLocal() {
|
||||
--
|
||||
2.14.3
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
From 817407fc2d6a861e65086388766f58082d38bc0b Mon Sep 17 00:00:00 2001
|
||||
From: Michael Munday <munday@ca.ibm.com>
|
||||
Date: Tue, 17 Jan 2017 11:33:38 -0500
|
||||
Subject: [PATCH 2/3] syscall: expose IfInfomsg.X__ifi_pad on s390x
|
||||
|
||||
Exposing this field on s390x improves compatibility with the other
|
||||
linux architectures, all of which already expose it.
|
||||
|
||||
Fixes #18628 and updates #18632.
|
||||
|
||||
Change-Id: I08e8e1eb705f898cd8822f8bee0d61ce11d514b5
|
||||
---
|
||||
src/syscall/ztypes_linux_s390x.go | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/syscall/ztypes_linux_s390x.go b/src/syscall/ztypes_linux_s390x.go
|
||||
index 63c4a83b19..b5894255df 100644
|
||||
--- a/src/syscall/ztypes_linux_s390x.go
|
||||
+++ b/src/syscall/ztypes_linux_s390x.go
|
||||
@@ -449,12 +449,12 @@ type RtAttr struct {
|
||||
}
|
||||
|
||||
type IfInfomsg struct {
|
||||
- Family uint8
|
||||
- _ uint8
|
||||
- Type uint16
|
||||
- Index int32
|
||||
- Flags uint32
|
||||
- Change uint32
|
||||
+ Family uint8
|
||||
+ X__ifi_pad uint8
|
||||
+ Type uint16
|
||||
+ Index int32
|
||||
+ Flags uint32
|
||||
+ Change uint32
|
||||
}
|
||||
|
||||
type IfAddrmsg struct {
|
||||
--
|
||||
2.14.3
|
||||
|
||||
44
backport-0003-golang-delete-pem-files.patch
Normal file
44
backport-0003-golang-delete-pem-files.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From de4a8f2f1c0e7c30dc5f54d19212eb29d01871ed Mon Sep 17 00:00:00 2001
|
||||
From: jingrui <jingrui@huawei.com>
|
||||
Date: Wed, 27 Nov 2019 10:46:52 +0800
|
||||
Subject: [PATCH 6/6] golang: delete pem files
|
||||
|
||||
Signed-off-by: jingrui <jingrui@huawei.com>
|
||||
---
|
||||
src/crypto/tls/testdata/example-cert.pem | 11 -----------
|
||||
src/crypto/tls/testdata/example-key.pem | 5 -----
|
||||
2 files changed, 16 deletions(-)
|
||||
delete mode 100644 src/crypto/tls/testdata/example-cert.pem
|
||||
delete mode 100644 src/crypto/tls/testdata/example-key.pem
|
||||
|
||||
diff --git a/src/crypto/tls/testdata/example-cert.pem b/src/crypto/tls/testdata/example-cert.pem
|
||||
deleted file mode 100644
|
||||
index e0bf7db..0000000
|
||||
--- a/src/crypto/tls/testdata/example-cert.pem
|
||||
+++ /dev/null
|
||||
@@ -1,11 +0,0 @@
|
||||
------BEGIN CERTIFICATE-----
|
||||
-MIIBhTCCASugAwIBAgIQIRi6zePL6mKjOipn+dNuaTAKBggqhkjOPQQDAjASMRAw
|
||||
-DgYDVQQKEwdBY21lIENvMB4XDTE3MTAyMDE5NDMwNloXDTE4MTAyMDE5NDMwNlow
|
||||
-EjEQMA4GA1UEChMHQWNtZSBDbzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABD0d
|
||||
-7VNhbWvZLWPuj/RtHFjvtJBEwOkhbN/BnnE8rnZR8+sbwnc/KhCk3FhnpHZnQz7B
|
||||
-5aETbbIgmuvewdjvSBSjYzBhMA4GA1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggr
|
||||
-BgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MCkGA1UdEQQiMCCCDmxvY2FsaG9zdDo1
|
||||
-NDUzgg4xMjcuMC4wLjE6NTQ1MzAKBggqhkjOPQQDAgNIADBFAiEA2zpJEPQyz6/l
|
||||
-Wf86aX6PepsntZv2GYlA5UpabfT2EZICICpJ5h/iI+i341gBmLiAFQOyTDT+/wQc
|
||||
-6MF9+Yw1Yy0t
|
||||
------END CERTIFICATE-----
|
||||
diff --git a/src/crypto/tls/testdata/example-key.pem b/src/crypto/tls/testdata/example-key.pem
|
||||
deleted file mode 100644
|
||||
index 104fb09..0000000
|
||||
--- a/src/crypto/tls/testdata/example-key.pem
|
||||
+++ /dev/null
|
||||
@@ -1,5 +0,0 @@
|
||||
------BEGIN EC PRIVATE KEY-----
|
||||
-MHcCAQEEIIrYSSNQFaA2Hwf1duRSxKtLYX5CB04fSeQ6tF1aY/PuoAoGCCqGSM49
|
||||
-AwEHoUQDQgAEPR3tU2Fta9ktY+6P9G0cWO+0kETA6SFs38GecTyudlHz6xvCdz8q
|
||||
-EKTcWGekdmdDPsHloRNtsiCa697B2O9IFA==
|
||||
------END EC PRIVATE KEY-----
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
From fa95a1d8e7eda9ab90a7fd29785cad0ae7d816e2 Mon Sep 17 00:00:00 2001
|
||||
From: jingrui <jingrui@huawei.com>
|
||||
Date: Wed, 27 Nov 2019 09:54:22 +0800
|
||||
Subject: [PATCH 1/6] syscall: implement rawVforkSyscall for linux/arm64
|
||||
|
||||
This allows the use of CLONE_VFORK and CLONE_VM for fork/exec, preventing
|
||||
"fork/exec ...: cannot allocate memory" failures from occuring when attempting
|
||||
to execute commands from a Go process that has a large memory footprint.
|
||||
Additionally, this should reduce the latency of fork/exec on linux/arm64.
|
||||
|
||||
With CLONE_VM the child process shares the same memory with the parent
|
||||
process. On its own this would lead to conflicting use of the same
|
||||
memory, so CLONE_VFORK is used to suspend the parent process until the
|
||||
child releases the memory when switching to the new program binary
|
||||
via the exec syscall. When the parent process continues to run, one
|
||||
has to consider the changes to memory that the child process did,
|
||||
namely the return address of the syscall function needs to be restored
|
||||
from a register.
|
||||
|
||||
exec.Command() callers can start in a faster manner, as child process who
|
||||
do exec commands job can be cloned faster via vfork than via fork on arm64.
|
||||
|
||||
The same problem was addressed on linux/amd64 via issue #5838.
|
||||
|
||||
Updates #31936
|
||||
Contributed by Howard Zhang <howard.zhang@arm.com> and Bin Lu <bin.lu@arm.com>
|
||||
|
||||
Change-Id: Ia99d81d877f564ec60d19f17e596276836576eaf
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/189418
|
||||
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
|
||||
Reviewed-by: Cherry Zhang <cherryyz@google.com>
|
||||
---
|
||||
src/syscall/asm_linux_arm64.s | 23 +++++++++++++++++++++++
|
||||
src/syscall/exec_linux.go | 2 +-
|
||||
src/syscall/syscall_linux_arm64.go | 4 +---
|
||||
3 files changed, 25 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/syscall/asm_linux_arm64.s b/src/syscall/asm_linux_arm64.s
|
||||
index 7edeafc..fb22f8d 100644
|
||||
--- a/src/syscall/asm_linux_arm64.s
|
||||
+++ b/src/syscall/asm_linux_arm64.s
|
||||
@@ -103,6 +103,29 @@ ok:
|
||||
MOVD ZR, err+72(FP) // errno
|
||||
RET
|
||||
|
||||
+// func rawVforkSyscall(trap, a1 uintptr) (r1, err uintptr)
|
||||
+TEXT ·rawVforkSyscall(SB),NOSPLIT,$0-32
|
||||
+ MOVD a1+8(FP), R0
|
||||
+ MOVD $0, R1
|
||||
+ MOVD $0, R2
|
||||
+ MOVD $0, R3
|
||||
+ MOVD $0, R4
|
||||
+ MOVD $0, R5
|
||||
+ MOVD trap+0(FP), R8 // syscall entry
|
||||
+ SVC
|
||||
+ CMN $4095, R0
|
||||
+ BCC ok
|
||||
+ MOVD $-1, R4
|
||||
+ MOVD R4, r1+16(FP) // r1
|
||||
+ NEG R0, R0
|
||||
+ MOVD R0, err+24(FP) // errno
|
||||
+ RET
|
||||
+ok:
|
||||
+ MOVD R0, r1+16(FP) // r1
|
||||
+ MOVD ZR, err+24(FP) // errno
|
||||
+ RET
|
||||
+
|
||||
+
|
||||
// func rawSyscallNoError(trap uintptr, a1, a2, a3 uintptr) (r1, r2 uintptr);
|
||||
TEXT ·rawSyscallNoError(SB),NOSPLIT,$0-48
|
||||
MOVD a1+8(FP), R0
|
||||
diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go
|
||||
index a2242b2..3540d51 100644
|
||||
--- a/src/syscall/exec_linux.go
|
||||
+++ b/src/syscall/exec_linux.go
|
||||
@@ -196,7 +196,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
|
||||
}
|
||||
}
|
||||
|
||||
- hasRawVforkSyscall := runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "s390x"
|
||||
+ hasRawVforkSyscall := runtime.GOARCH == "amd64" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "s390x" || runtime.GOARCH == "arm64"
|
||||
|
||||
// About to call fork.
|
||||
// No more allocation or calls of non-assembly functions.
|
||||
diff --git a/src/syscall/syscall_linux_arm64.go b/src/syscall/syscall_linux_arm64.go
|
||||
index 48ad0bb..89b2ab2 100644
|
||||
--- a/src/syscall/syscall_linux_arm64.go
|
||||
+++ b/src/syscall/syscall_linux_arm64.go
|
||||
@@ -154,6 +154,4 @@ const (
|
||||
SYS_EPOLL_WAIT = 1069
|
||||
)
|
||||
|
||||
-func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno) {
|
||||
- panic("not implemented")
|
||||
-}
|
||||
+func rawVforkSyscall(trap, a1 uintptr) (r1 uintptr, err Errno)
|
||||
--
|
||||
2.17.1
|
||||
|
||||
191
backport-0005-runtime-fix-crash-during-VDSO-calls-on-arm.patch
Normal file
191
backport-0005-runtime-fix-crash-during-VDSO-calls-on-arm.patch
Normal file
@ -0,0 +1,191 @@
|
||||
From 8a755c0f0389dca42ec8caef0efa9b6ebe9d1e3c Mon Sep 17 00:00:00 2001
|
||||
From: Yuichi Nishiwaki <yuichi.nishiwaki@gmail.com>
|
||||
Date: Wed, 11 Sep 2019 02:26:02 +0000
|
||||
Subject: [PATCH 2/6] runtime: fix crash during VDSO calls on arm
|
||||
|
||||
As discussed in #32912, a crash occurs when go runtime calls a VDSO function (say
|
||||
__vdso_clock_gettime) and a signal arrives to that thread.
|
||||
Since VDSO functions temporarily destroy the G register (R10),
|
||||
Go functions asynchronously executed in that thread (i.e. Go's signal
|
||||
handler) can try to load data from the destroyed G, which causes
|
||||
segmentation fault.
|
||||
|
||||
To fix the issue a guard is inserted in front of sigtrampgo, so that the control escapes from
|
||||
signal handlers without touching G in case the signal occurred in the VDSO context.
|
||||
The test case included in the patch is take from discussion in a relevant thread on github:
|
||||
https://github.com/golang/go/issues/32912#issuecomment-517874531.
|
||||
This patch not only fixes the issue on AArch64 but also that on 32bit ARM.
|
||||
|
||||
Fixes #32912
|
||||
|
||||
Change-Id: I657472e54b7aa3c617fabc5019ce63aa4105624a
|
||||
GitHub-Last-Rev: 28ce42c4a02a060f08c1b0dd1c9a392123fd2ee9
|
||||
GitHub-Pull-Request: golang/go#34030
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/192937
|
||||
Run-TryBot: Ian Lance Taylor <iant@golang.org>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
Reviewed-by: Ian Lance Taylor <iant@golang.org>
|
||||
---
|
||||
src/runtime/crash_test.go | 9 +++++
|
||||
src/runtime/signal_unix.go | 27 ++++++++++---
|
||||
src/runtime/testdata/testprog/vdso.go | 55 +++++++++++++++++++++++++++
|
||||
src/runtime/vdso_linux.go | 1 +
|
||||
4 files changed, 86 insertions(+), 6 deletions(-)
|
||||
create mode 100644 src/runtime/testdata/testprog/vdso.go
|
||||
|
||||
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go
|
||||
index c54bb57..c2cab7c 100644
|
||||
--- a/src/runtime/crash_test.go
|
||||
+++ b/src/runtime/crash_test.go
|
||||
@@ -143,6 +143,15 @@ func buildTestProg(t *testing.T, binary string, flags ...string) (string, error)
|
||||
return exe, nil
|
||||
}
|
||||
|
||||
+func TestVDSO(t *testing.T) {
|
||||
+ t.Parallel()
|
||||
+ output := runTestProg(t, "testprog", "SignalInVDSO")
|
||||
+ want := "success\n"
|
||||
+ if output != want {
|
||||
+ t.Fatalf("output:\n%s\n\nwanted:\n%s", output, want);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
var (
|
||||
staleRuntimeOnce sync.Once // guards init of staleRuntimeErr
|
||||
staleRuntimeErr error
|
||||
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
|
||||
index ad51dc1..63fb07f 100644
|
||||
--- a/src/runtime/signal_unix.go
|
||||
+++ b/src/runtime/signal_unix.go
|
||||
@@ -274,6 +274,21 @@ func sigpipe() {
|
||||
dieFromSignal(_SIGPIPE)
|
||||
}
|
||||
|
||||
+// sigFetchG fetches the value of G safely when running in a signal handler.
|
||||
+// On some architectures, the g value may be clobbered when running in a VDSO.
|
||||
+// See issue #32912.
|
||||
+//
|
||||
+//go:nosplit
|
||||
+func sigFetchG(c *sigctxt) *g {
|
||||
+ switch GOARCH {
|
||||
+ case "arm", "arm64", "ppc64", "ppc64le":
|
||||
+ if inVDSOPage(c.sigpc()) {
|
||||
+ return nil
|
||||
+ }
|
||||
+ }
|
||||
+ return getg()
|
||||
+}
|
||||
+
|
||||
// sigtrampgo is called from the signal handler function, sigtramp,
|
||||
// written in assembly code.
|
||||
// This is called by the signal handler, and the world may be stopped.
|
||||
@@ -289,9 +304,9 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
|
||||
if sigfwdgo(sig, info, ctx) {
|
||||
return
|
||||
}
|
||||
- g := getg()
|
||||
+ c := &sigctxt{info, ctx}
|
||||
+ g := sigFetchG(c)
|
||||
if g == nil {
|
||||
- c := &sigctxt{info, ctx}
|
||||
if sig == _SIGPROF {
|
||||
sigprofNonGoPC(c.sigpc())
|
||||
return
|
||||
@@ -347,7 +362,6 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
|
||||
signalDuringFork(sig)
|
||||
}
|
||||
|
||||
- c := &sigctxt{info, ctx}
|
||||
c.fixsigcode(sig)
|
||||
sighandler(sig, info, ctx, g)
|
||||
setg(g)
|
||||
@@ -650,9 +664,10 @@ func sigfwdgo(sig uint32, info *siginfo, ctx unsafe.Pointer) bool {
|
||||
return false
|
||||
}
|
||||
// Determine if the signal occurred inside Go code. We test that:
|
||||
- // (1) we were in a goroutine (i.e., m.curg != nil), and
|
||||
- // (2) we weren't in CGO.
|
||||
- g := getg()
|
||||
+ // (1) we weren't in VDSO page,
|
||||
+ // (2) we were in a goroutine (i.e., m.curg != nil), and
|
||||
+ // (3) we weren't in CGO.
|
||||
+ g := sigFetchG(c)
|
||||
if g != nil && g.m != nil && g.m.curg != nil && !g.m.incgo {
|
||||
return false
|
||||
}
|
||||
diff --git a/src/runtime/testdata/testprog/vdso.go b/src/runtime/testdata/testprog/vdso.go
|
||||
new file mode 100644
|
||||
index 0000000..6036f45
|
||||
--- /dev/null
|
||||
+++ b/src/runtime/testdata/testprog/vdso.go
|
||||
@@ -0,0 +1,55 @@
|
||||
+// Copyright 2019 The Go Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style
|
||||
+// license that can be found in the LICENSE file.
|
||||
+
|
||||
+// Invoke signal hander in the VDSO context (see issue 32912).
|
||||
+
|
||||
+package main
|
||||
+
|
||||
+import (
|
||||
+ "fmt"
|
||||
+ "io/ioutil"
|
||||
+ "os"
|
||||
+ "runtime/pprof"
|
||||
+ "time"
|
||||
+)
|
||||
+
|
||||
+func init() {
|
||||
+ register("SignalInVDSO", signalInVDSO)
|
||||
+}
|
||||
+
|
||||
+func signalInVDSO() {
|
||||
+ f, err := ioutil.TempFile("", "timeprofnow")
|
||||
+ if err != nil {
|
||||
+ fmt.Fprintln(os.Stderr, err)
|
||||
+ os.Exit(2)
|
||||
+ }
|
||||
+
|
||||
+ if err := pprof.StartCPUProfile(f); err != nil {
|
||||
+ fmt.Fprintln(os.Stderr, err)
|
||||
+ os.Exit(2)
|
||||
+ }
|
||||
+
|
||||
+ t0 := time.Now()
|
||||
+ t1 := t0
|
||||
+ // We should get a profiling signal 100 times a second,
|
||||
+ // so running for 1 second should be sufficient.
|
||||
+ for t1.Sub(t0) < time.Second {
|
||||
+ t1 = time.Now()
|
||||
+ }
|
||||
+
|
||||
+ pprof.StopCPUProfile()
|
||||
+
|
||||
+ name := f.Name()
|
||||
+ if err := f.Close(); err != nil {
|
||||
+ fmt.Fprintln(os.Stderr, err)
|
||||
+ os.Exit(2)
|
||||
+ }
|
||||
+
|
||||
+ if err := os.Remove(name); err != nil {
|
||||
+ fmt.Fprintln(os.Stderr, err)
|
||||
+ os.Exit(2)
|
||||
+ }
|
||||
+
|
||||
+ fmt.Println("success");
|
||||
+}
|
||||
diff --git a/src/runtime/vdso_linux.go b/src/runtime/vdso_linux.go
|
||||
index 71ba4ce..8518276 100644
|
||||
--- a/src/runtime/vdso_linux.go
|
||||
+++ b/src/runtime/vdso_linux.go
|
||||
@@ -281,6 +281,7 @@ func vdsoauxv(tag, val uintptr) {
|
||||
}
|
||||
|
||||
// vdsoMarker reports whether PC is on the VDSO page.
|
||||
+//go:nosplit
|
||||
func inVDSOPage(pc uintptr) bool {
|
||||
for _, k := range vdsoSymbolKeys {
|
||||
if *k.ptr != 0 {
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,253 @@
|
||||
From 4717d9a1a21dfe051a14f033615218d833371d68 Mon Sep 17 00:00:00 2001
|
||||
From: jingrui <jingrui@huawei.com>
|
||||
Date: Wed, 27 Nov 2019 10:19:13 +0800
|
||||
Subject: [PATCH 3/6] runtime: save/fetch g register during VDSO on ARM and
|
||||
ARM64
|
||||
|
||||
On ARM and ARM64, during a VDSO call, the g register may be
|
||||
temporarily clobbered by the VDSO code. If a signal is received
|
||||
during the execution of VDSO code, we may not find a valid g
|
||||
reading the g register. In CL 192937, we conservatively assume
|
||||
g is nil. But this approach has a problem: we cannot handle
|
||||
the signal in this case. Further, if the signal is not a
|
||||
profiling signal, we'll call badsignal, which calls needm, which
|
||||
wants to get an extra m, but we don't have one in a non-cgo
|
||||
binary, which cuases the program to hang.
|
||||
|
||||
This is even more of a problem with async preemption, where we
|
||||
will receive more signals than before. I ran into this problem
|
||||
while working on async preemption support on ARM64.
|
||||
|
||||
In this CL, before making a VDSO call, we save the g on the
|
||||
gsignal stack. When we receive a signal, we will be running on
|
||||
the gsignal stack, so we can fetch the g from there and move on.
|
||||
|
||||
We probably want to do the same for PPC64. Currently we rely on
|
||||
that the VDSO code doesn't actually clobber the g register, but
|
||||
this is not guaranteed and we don't have control with.
|
||||
|
||||
Idea from discussion with Dan Cross and Austin.
|
||||
|
||||
Should fix #34391.
|
||||
|
||||
Change-Id: Idbefc5e4c2f4373192c2be797be0140ae08b26e3
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/202759
|
||||
Run-TryBot: Cherry Zhang <cherryyz@google.com>
|
||||
Reviewed-by: Austin Clements <austin@google.com>
|
||||
---
|
||||
src/os/signal/signal_test.go | 49 +++++++++++++++++++++++++++++++++++
|
||||
src/runtime/proc.go | 3 +++
|
||||
src/runtime/signal_unix.go | 24 ++++++++++++-----
|
||||
src/runtime/sys_linux_arm.s | 32 +++++++++++++++++++++++
|
||||
src/runtime/sys_linux_arm64.s | 28 ++++++++++++++++++++
|
||||
5 files changed, 129 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go
|
||||
index 6ea59f4..c8274ea 100644
|
||||
--- a/src/os/signal/signal_test.go
|
||||
+++ b/src/os/signal/signal_test.go
|
||||
@@ -453,3 +453,52 @@ func atomicStopTestProgram() {
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
+
|
||||
+func TestTime(t *testing.T) {
|
||||
+ // Test that signal works fine when we are in a call to get time,
|
||||
+ // which on some platforms is using VDSO. See issue #34391.
|
||||
+ dur := 3 * time.Second
|
||||
+ if testing.Short() {
|
||||
+ dur = 100 * time.Millisecond
|
||||
+ }
|
||||
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4))
|
||||
+ done := make(chan bool)
|
||||
+ finished := make(chan bool)
|
||||
+ go func() {
|
||||
+ sig := make(chan os.Signal, 1)
|
||||
+ Notify(sig, syscall.SIGUSR1)
|
||||
+ defer Stop(sig)
|
||||
+ Loop:
|
||||
+ for {
|
||||
+ select {
|
||||
+ case <-sig:
|
||||
+ case <-done:
|
||||
+ break Loop
|
||||
+ }
|
||||
+ }
|
||||
+ finished <- true
|
||||
+ }()
|
||||
+ go func() {
|
||||
+ Loop:
|
||||
+ for {
|
||||
+ select {
|
||||
+ case <-done:
|
||||
+ break Loop
|
||||
+ default:
|
||||
+ syscall.Kill(syscall.Getpid(), syscall.SIGUSR1)
|
||||
+ runtime.Gosched()
|
||||
+ }
|
||||
+ }
|
||||
+ finished <- true
|
||||
+ }()
|
||||
+ t0 := time.Now()
|
||||
+ for t1 := t0; t1.Sub(t0) < dur; t1 = time.Now() {
|
||||
+ } // hammering on getting time
|
||||
+ close(done)
|
||||
+ <-finished
|
||||
+ <-finished
|
||||
+ // When run with 'go test -cpu=1,2,4' SIGUSR1 from this test can slip
|
||||
+ // into subsequent TestSignal() causing failure.
|
||||
+ // Sleep for a while to reduce the possibility of the failure.
|
||||
+ time.Sleep(10 * time.Millisecond)
|
||||
+}
|
||||
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
|
||||
index 93d329d..1487647 100644
|
||||
--- a/src/runtime/proc.go
|
||||
+++ b/src/runtime/proc.go
|
||||
@@ -3237,6 +3237,9 @@ func malg(stacksize int32) *g {
|
||||
})
|
||||
newg.stackguard0 = newg.stack.lo + _StackGuard
|
||||
newg.stackguard1 = ^uintptr(0)
|
||||
+ // Clear the bottom word of the stack. We record g
|
||||
+ // there on gsignal stack during VDSO on ARM and ARM64.
|
||||
+ *(*uintptr)(unsafe.Pointer(newg.stack.lo)) = 0
|
||||
}
|
||||
return newg
|
||||
}
|
||||
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
|
||||
index 63fb07f..2cf1e3b 100644
|
||||
--- a/src/runtime/signal_unix.go
|
||||
+++ b/src/runtime/signal_unix.go
|
||||
@@ -280,13 +280,23 @@ func sigpipe() {
|
||||
//
|
||||
//go:nosplit
|
||||
func sigFetchG(c *sigctxt) *g {
|
||||
- switch GOARCH {
|
||||
- case "arm", "arm64", "ppc64", "ppc64le":
|
||||
- if inVDSOPage(c.sigpc()) {
|
||||
- return nil
|
||||
- }
|
||||
- }
|
||||
- return getg()
|
||||
+ switch GOARCH {
|
||||
+ case "arm", "arm64":
|
||||
+ if inVDSOPage(c.sigpc()) {
|
||||
+ // Before making a VDSO call we save the g to the bottom of the
|
||||
+ // signal stack. Fetch from there.
|
||||
+ // TODO: in efence mode, stack is sysAlloc'd, so this wouldn't
|
||||
+ // work.
|
||||
+ sp := getcallersp()
|
||||
+ s := spanOf(sp)
|
||||
+ if s != nil && s.state == mSpanManual && s.base() < sp && sp < s.limit {
|
||||
+ gp := *(**g)(unsafe.Pointer(s.base()))
|
||||
+ return gp
|
||||
+ }
|
||||
+ return nil
|
||||
+ }
|
||||
+ }
|
||||
+ return getg()
|
||||
}
|
||||
|
||||
// sigtrampgo is called from the signal handler function, sigtramp,
|
||||
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
|
||||
index 9c73984..26e12a8 100644
|
||||
--- a/src/runtime/sys_linux_arm.s
|
||||
+++ b/src/runtime/sys_linux_arm.s
|
||||
@@ -246,7 +246,23 @@ noswitch:
|
||||
CMP $0, R11
|
||||
B.EQ fallback
|
||||
|
||||
+ // Store g on gsignal's stack, so if we receive a signal
|
||||
+ // during VDSO code we can find the g.
|
||||
+ // If we don't have a signal stack, we won't receive signal,
|
||||
+ // so don't bother saving g.
|
||||
+ MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
+ CMP $0, R6
|
||||
+ BEQ 3(PC)
|
||||
+ MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
+ MOVW g, (R6)
|
||||
+
|
||||
BL (R11)
|
||||
+
|
||||
+ CMP $0, R6 // R6 is unchanged by C code
|
||||
+ BEQ 3(PC)
|
||||
+ MOVW $0, R1
|
||||
+ MOVW R1, (R6) // clear g slot
|
||||
+
|
||||
JMP finish
|
||||
|
||||
fallback:
|
||||
@@ -297,7 +313,23 @@ noswitch:
|
||||
CMP $0, R11
|
||||
B.EQ fallback
|
||||
|
||||
+ // Store g on gsignal's stack, so if we receive a signal
|
||||
+ // during VDSO code we can find the g.
|
||||
+ // If we don't have a signal stack, we won't receive signal,
|
||||
+ // so don't bother saving g.
|
||||
+ MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
+ CMP $0, R6
|
||||
+ BEQ 3(PC)
|
||||
+ MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
+ MOVW g, (R6)
|
||||
+
|
||||
BL (R11)
|
||||
+
|
||||
+ CMP $0, R6 // R6 is unchanged by C code
|
||||
+ BEQ 3(PC)
|
||||
+ MOVW $0, R1
|
||||
+ MOVW R1, (R6) // clear g slot
|
||||
+
|
||||
JMP finish
|
||||
|
||||
fallback:
|
||||
diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s
|
||||
index 2835b6c..fd40bf9 100644
|
||||
--- a/src/runtime/sys_linux_arm64.s
|
||||
+++ b/src/runtime/sys_linux_arm64.s
|
||||
@@ -207,7 +207,21 @@ noswitch:
|
||||
MOVW $CLOCK_REALTIME, R0
|
||||
MOVD runtime·vdsoClockgettimeSym(SB), R2
|
||||
CBZ R2, fallback
|
||||
+
|
||||
+ // Store g on gsignal's stack, so if we receive a signal
|
||||
+ // during VDSO code we can find the g.
|
||||
+ // If we don't have a signal stack, we won't receive signal,
|
||||
+ // so don't bother saving g.
|
||||
+ MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
+ CBZ R22, 3(PC)
|
||||
+ MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
+ MOVD g, (R22)
|
||||
+
|
||||
BL (R2)
|
||||
+
|
||||
+ CBZ R22, 2(PC) // R22 is unchanged by C code
|
||||
+ MOVD ZR, (R22) // clear g slot
|
||||
+
|
||||
B finish
|
||||
|
||||
fallback:
|
||||
@@ -250,7 +264,21 @@ noswitch:
|
||||
MOVW $CLOCK_MONOTONIC, R0
|
||||
MOVD runtime·vdsoClockgettimeSym(SB), R2
|
||||
CBZ R2, fallback
|
||||
+
|
||||
+ // Store g on gsignal's stack, so if we receive a signal
|
||||
+ // during VDSO code we can find the g.
|
||||
+ // If we don't have a signal stack, we won't receive signal,
|
||||
+ // so don't bother saving g.
|
||||
+ MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
+ CBZ R22, 3(PC)
|
||||
+ MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
+ MOVD g, (R22)
|
||||
+
|
||||
BL (R2)
|
||||
+
|
||||
+ CBZ R22, 2(PC) // R22 is unchanged by C code
|
||||
+ MOVD ZR, (R22) // clear g slot
|
||||
+
|
||||
B finish
|
||||
|
||||
fallback:
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,179 @@
|
||||
From fce0a59fc370634fcd7de8f8691e918cdf122f7d Mon Sep 17 00:00:00 2001
|
||||
From: Cherry Zhang <cherryyz@google.com>
|
||||
Date: Thu, 31 Oct 2019 10:32:31 -0400
|
||||
Subject: [PATCH 4/6] runtime: don't fetch G from signal stack when using cgo
|
||||
|
||||
When using cgo, we save G to TLS, and when a signal happens, we
|
||||
load G from TLS in sigtramp. This should give us a valid G. Don't
|
||||
try to fetch from the signal stack. In particular, C code may
|
||||
change the signal stack or call our signal handler directly (e.g.
|
||||
TSAN), so we are not necessarily running on the original gsignal
|
||||
stack where we saved G.
|
||||
|
||||
Also skip saving G on the signal stack when using cgo.
|
||||
|
||||
Updates #35249.
|
||||
|
||||
Change-Id: I40749ce6682709bd4ebfdfd9f23bd0f317fc197d
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/204519
|
||||
Reviewed-by: Ian Lance Taylor <iant@golang.org>
|
||||
---
|
||||
src/runtime/signal_unix.go | 8 +++++---
|
||||
src/runtime/sys_linux_arm.s | 30 ++++++++++++++++++++++--------
|
||||
src/runtime/sys_linux_arm64.s | 26 ++++++++++++++++++++------
|
||||
3 files changed, 47 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
|
||||
index 2cf1e3b..721edb5 100644
|
||||
--- a/src/runtime/signal_unix.go
|
||||
+++ b/src/runtime/signal_unix.go
|
||||
@@ -282,9 +282,11 @@ func sigpipe() {
|
||||
func sigFetchG(c *sigctxt) *g {
|
||||
switch GOARCH {
|
||||
case "arm", "arm64":
|
||||
- if inVDSOPage(c.sigpc()) {
|
||||
- // Before making a VDSO call we save the g to the bottom of the
|
||||
- // signal stack. Fetch from there.
|
||||
+ if !iscgo && inVDSOPage(c.sigpc()) {
|
||||
+ // When using cgo, we save the g on TLS and load it from there
|
||||
+ // in sigtramp. Just use that.
|
||||
+ // Otherwise, before making a VDSO call we save the g to the
|
||||
+ // bottom of the signal stack. Fetch from there.
|
||||
// TODO: in efence mode, stack is sysAlloc'd, so this wouldn't
|
||||
// work.
|
||||
sp := getcallersp()
|
||||
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
|
||||
index 26e12a8..a47ac5f 100644
|
||||
--- a/src/runtime/sys_linux_arm.s
|
||||
+++ b/src/runtime/sys_linux_arm.s
|
||||
@@ -250,21 +250,28 @@ noswitch:
|
||||
// during VDSO code we can find the g.
|
||||
// If we don't have a signal stack, we won't receive signal,
|
||||
// so don't bother saving g.
|
||||
+ // When using cgo, we already saved g on TLS, also don't save
|
||||
+ // g here.
|
||||
+ MOVB runtime·iscgo(SB), R6
|
||||
+ CMP $0, R6
|
||||
+ BNE nosaveg
|
||||
MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
CMP $0, R6
|
||||
- BEQ 3(PC)
|
||||
+ BEQ nosaveg
|
||||
MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
MOVW g, (R6)
|
||||
|
||||
BL (R11)
|
||||
|
||||
- CMP $0, R6 // R6 is unchanged by C code
|
||||
- BEQ 3(PC)
|
||||
MOVW $0, R1
|
||||
- MOVW R1, (R6) // clear g slot
|
||||
+ MOVW R1, (R6) // clear g slot, R6 is unchanged by C code
|
||||
|
||||
JMP finish
|
||||
|
||||
+nosaveg:
|
||||
+ BL (R11)
|
||||
+ JMP finish
|
||||
+
|
||||
fallback:
|
||||
MOVW $SYS_clock_gettime, R7
|
||||
SWI $0
|
||||
@@ -317,21 +324,28 @@ noswitch:
|
||||
// during VDSO code we can find the g.
|
||||
// If we don't have a signal stack, we won't receive signal,
|
||||
// so don't bother saving g.
|
||||
+ // When using cgo, we already saved g on TLS, also don't save
|
||||
+ // g here.
|
||||
+ MOVB runtime·iscgo(SB), R6
|
||||
+ CMP $0, R6
|
||||
+ BNE nosaveg
|
||||
MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
CMP $0, R6
|
||||
- BEQ 3(PC)
|
||||
+ BEQ nosaveg
|
||||
MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
MOVW g, (R6)
|
||||
|
||||
BL (R11)
|
||||
|
||||
- CMP $0, R6 // R6 is unchanged by C code
|
||||
- BEQ 3(PC)
|
||||
MOVW $0, R1
|
||||
- MOVW R1, (R6) // clear g slot
|
||||
+ MOVW R1, (R6) // clear g slot, R6 is unchanged by C code
|
||||
|
||||
JMP finish
|
||||
|
||||
+nosaveg:
|
||||
+ BL (R11)
|
||||
+ JMP finish
|
||||
+
|
||||
fallback:
|
||||
MOVW $SYS_clock_gettime, R7
|
||||
SWI $0
|
||||
diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s
|
||||
index fd40bf9..94c93ca 100644
|
||||
--- a/src/runtime/sys_linux_arm64.s
|
||||
+++ b/src/runtime/sys_linux_arm64.s
|
||||
@@ -212,18 +212,25 @@ noswitch:
|
||||
// during VDSO code we can find the g.
|
||||
// If we don't have a signal stack, we won't receive signal,
|
||||
// so don't bother saving g.
|
||||
+ // When using cgo, we already saved g on TLS, also don't save
|
||||
+ // g here.
|
||||
+ MOVBU runtime·iscgo(SB), R22
|
||||
+ CBNZ R22, nosaveg
|
||||
MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
- CBZ R22, 3(PC)
|
||||
+ CBZ R22, nosaveg
|
||||
MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
MOVD g, (R22)
|
||||
|
||||
BL (R2)
|
||||
|
||||
- CBZ R22, 2(PC) // R22 is unchanged by C code
|
||||
- MOVD ZR, (R22) // clear g slot
|
||||
+ MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code
|
||||
|
||||
B finish
|
||||
|
||||
+nosaveg:
|
||||
+ BL (R2)
|
||||
+ B finish
|
||||
+
|
||||
fallback:
|
||||
MOVD $SYS_clock_gettime, R8
|
||||
SVC
|
||||
@@ -269,18 +276,25 @@ noswitch:
|
||||
// during VDSO code we can find the g.
|
||||
// If we don't have a signal stack, we won't receive signal,
|
||||
// so don't bother saving g.
|
||||
+ // When using cgo, we already saved g on TLS, also don't save
|
||||
+ // g here.
|
||||
+ MOVBU runtime·iscgo(SB), R22
|
||||
+ CBNZ R22, nosaveg
|
||||
MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
- CBZ R22, 3(PC)
|
||||
+ CBZ R22, nosaveg
|
||||
MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
MOVD g, (R22)
|
||||
|
||||
BL (R2)
|
||||
|
||||
- CBZ R22, 2(PC) // R22 is unchanged by C code
|
||||
- MOVD ZR, (R22) // clear g slot
|
||||
+ MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code
|
||||
|
||||
B finish
|
||||
|
||||
+nosaveg:
|
||||
+ BL (R2)
|
||||
+ B finish
|
||||
+
|
||||
fallback:
|
||||
MOVD $SYS_clock_gettime, R8
|
||||
SVC
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,107 @@
|
||||
From e83074ea52287115b85002a6b72137c72f6d7ecc Mon Sep 17 00:00:00 2001
|
||||
From: Cherry Zhang <cherryyz@google.com>
|
||||
Date: Sun, 10 Nov 2019 13:18:06 -0500
|
||||
Subject: [PATCH 5/6] runtime: don't save G during VDSO if we're handling
|
||||
signal
|
||||
|
||||
On some platforms (currently ARM and ARM64), when calling into
|
||||
VDSO we store the G to the gsignal stack, if there is one, so if
|
||||
we receive a signal during VDSO we can find the G.
|
||||
|
||||
If we receive a signal during VDSO, and within the signal handler
|
||||
we call nanotime again (e.g. when handling profiling signal),
|
||||
we'll save/clear the G slot on the gsignal stack again, which
|
||||
clobbers the original saved G. If we receive a second signal
|
||||
during the same VDSO execution, we will fetch a nil G, which will
|
||||
lead to bad things such as deadlock.
|
||||
|
||||
Don't save G if we're calling VDSO code from the gsignal stack.
|
||||
Saving G is not necessary as we won't receive a nested signal.
|
||||
|
||||
Fixes #35473.
|
||||
|
||||
Change-Id: Ibfd8587a3c70c2f1533908b056e81b94d75d65a5
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/206397
|
||||
Run-TryBot: Cherry Zhang <cherryyz@google.com>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
Reviewed-by: Bryan C. Mills <bcmills@google.com>
|
||||
---
|
||||
src/runtime/sys_linux_arm.s | 8 ++++++++
|
||||
src/runtime/sys_linux_arm64.s | 8 ++++++++
|
||||
2 files changed, 16 insertions(+)
|
||||
|
||||
diff --git a/src/runtime/sys_linux_arm.s b/src/runtime/sys_linux_arm.s
|
||||
index a47ac5f..577faac 100644
|
||||
--- a/src/runtime/sys_linux_arm.s
|
||||
+++ b/src/runtime/sys_linux_arm.s
|
||||
@@ -252,12 +252,16 @@ noswitch:
|
||||
// so don't bother saving g.
|
||||
// When using cgo, we already saved g on TLS, also don't save
|
||||
// g here.
|
||||
+ // Also don't save g if we are already on the signal stack.
|
||||
+ // We won't get a nested signal.
|
||||
MOVB runtime·iscgo(SB), R6
|
||||
CMP $0, R6
|
||||
BNE nosaveg
|
||||
MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
CMP $0, R6
|
||||
BEQ nosaveg
|
||||
+ CMP g, R6
|
||||
+ BEQ nosaveg
|
||||
MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
MOVW g, (R6)
|
||||
|
||||
@@ -326,12 +330,16 @@ noswitch:
|
||||
// so don't bother saving g.
|
||||
// When using cgo, we already saved g on TLS, also don't save
|
||||
// g here.
|
||||
+ // Also don't save g if we are already on the signal stack.
|
||||
+ // We won't get a nested signal.
|
||||
MOVB runtime·iscgo(SB), R6
|
||||
CMP $0, R6
|
||||
BNE nosaveg
|
||||
MOVW m_gsignal(R5), R6 // g.m.gsignal
|
||||
CMP $0, R6
|
||||
BEQ nosaveg
|
||||
+ CMP g, R6
|
||||
+ BEQ nosaveg
|
||||
MOVW (g_stack+stack_lo)(R6), R6 // g.m.gsignal.stack.lo
|
||||
MOVW g, (R6)
|
||||
|
||||
diff --git a/src/runtime/sys_linux_arm64.s b/src/runtime/sys_linux_arm64.s
|
||||
index 94c93ca..a076744 100644
|
||||
--- a/src/runtime/sys_linux_arm64.s
|
||||
+++ b/src/runtime/sys_linux_arm64.s
|
||||
@@ -214,10 +214,14 @@ noswitch:
|
||||
// so don't bother saving g.
|
||||
// When using cgo, we already saved g on TLS, also don't save
|
||||
// g here.
|
||||
+ // Also don't save g if we are already on the signal stack.
|
||||
+ // We won't get a nested signal.
|
||||
MOVBU runtime·iscgo(SB), R22
|
||||
CBNZ R22, nosaveg
|
||||
MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
CBZ R22, nosaveg
|
||||
+ CMP g, R22
|
||||
+ BEQ nosaveg
|
||||
MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
MOVD g, (R22)
|
||||
|
||||
@@ -278,10 +282,14 @@ noswitch:
|
||||
// so don't bother saving g.
|
||||
// When using cgo, we already saved g on TLS, also don't save
|
||||
// g here.
|
||||
+ // Also don't save g if we are already on the signal stack.
|
||||
+ // We won't get a nested signal.
|
||||
MOVBU runtime·iscgo(SB), R22
|
||||
CBNZ R22, nosaveg
|
||||
MOVD m_gsignal(R21), R22 // g.m.gsignal
|
||||
CBZ R22, nosaveg
|
||||
+ CMP g, R22
|
||||
+ BEQ nosaveg
|
||||
MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
|
||||
MOVD g, (R22)
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,130 @@
|
||||
From b2df6bf225859f82b3f69d471e1c99b72c208ec3 Mon Sep 17 00:00:00 2001
|
||||
From: Brad Fitzpatrick <bradfitz@golang.org>
|
||||
Date: Fri, 18 Oct 2019 20:45:33 +0000
|
||||
Subject: [PATCH] [release-branch.go1.13] net/http: don't cache
|
||||
http2.erringRoundTripper connections
|
||||
|
||||
Fixes #35087
|
||||
Updates #34978
|
||||
|
||||
Change-Id: I3baf1392ba7366ae6628889c47c343ef702ec438
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/202078
|
||||
Reviewed-by: Bryan C. Mills <bcmills@google.com>
|
||||
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
(cherry picked from commit 88186e5e232625f9c91d639e0cb90a88c6cf1172)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/202642
|
||||
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
|
||||
---
|
||||
src/net/http/transport.go | 9 +++-
|
||||
src/net/http/transport_test.go | 75 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 82 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
|
||||
index caa4bdc36f..b46c4e7066 100644
|
||||
--- a/src/net/http/transport.go
|
||||
+++ b/src/net/http/transport.go
|
||||
@@ -537,10 +537,15 @@ func (t *Transport) roundTrip(req *Request) (*Response, error) {
|
||||
if err == nil {
|
||||
return resp, nil
|
||||
}
|
||||
- if http2isNoCachedConnError(err) {
|
||||
+
|
||||
+ // Failed. Clean up and determine whether to retry.
|
||||
+
|
||||
+ _, isH2DialError := pconn.alt.(http2erringRoundTripper)
|
||||
+ if http2isNoCachedConnError(err) || isH2DialError {
|
||||
t.removeIdleConn(pconn)
|
||||
t.decConnsPerHost(pconn.cacheKey)
|
||||
- } else if !pconn.shouldRetryRequest(req, err) {
|
||||
+ }
|
||||
+ if !pconn.shouldRetryRequest(req, err) {
|
||||
// Issue 16465: return underlying net.Conn.Read error from peek,
|
||||
// as we've historically done.
|
||||
if e, ok := err.(transportReadFromServerError); ok {
|
||||
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
|
||||
index e43c8956ee..f8c13a7091 100644
|
||||
--- a/src/net/http/transport_test.go
|
||||
+++ b/src/net/http/transport_test.go
|
||||
@@ -5719,3 +5719,78 @@ func TestInvalidHeaderResponse(t *testing.T) {
|
||||
t.Errorf(`bad "Foo " header value: %q, want %q`, v, "bar")
|
||||
}
|
||||
}
|
||||
+
|
||||
+// breakableConn is a net.Conn wrapper with a Write method
|
||||
+// that will fail when its brokenState is true.
|
||||
+type breakableConn struct {
|
||||
+ net.Conn
|
||||
+ *brokenState
|
||||
+}
|
||||
+
|
||||
+type brokenState struct {
|
||||
+ sync.Mutex
|
||||
+ broken bool
|
||||
+}
|
||||
+
|
||||
+func (w *breakableConn) Write(b []byte) (n int, err error) {
|
||||
+ w.Lock()
|
||||
+ defer w.Unlock()
|
||||
+ if w.broken {
|
||||
+ return 0, errors.New("some write error")
|
||||
+ }
|
||||
+ return w.Conn.Write(b)
|
||||
+}
|
||||
+
|
||||
+// Issue 34978: don't cache a broken HTTP/2 connection
|
||||
+func TestDontCacheBrokenHTTP2Conn(t *testing.T) {
|
||||
+ cst := newClientServerTest(t, h2Mode, HandlerFunc(func(w ResponseWriter, r *Request) {}), optQuietLog)
|
||||
+ defer cst.close()
|
||||
+
|
||||
+ var brokenState brokenState
|
||||
+
|
||||
+ cst.tr.Dial = func(netw, addr string) (net.Conn, error) {
|
||||
+ c, err := net.Dial(netw, addr)
|
||||
+ if err != nil {
|
||||
+ t.Errorf("unexpected Dial error: %v", err)
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ return &breakableConn{c, &brokenState}, err
|
||||
+ }
|
||||
+
|
||||
+ const numReqs = 5
|
||||
+ var gotConns uint32 // atomic
|
||||
+ for i := 1; i <= numReqs; i++ {
|
||||
+ brokenState.Lock()
|
||||
+ brokenState.broken = false
|
||||
+ brokenState.Unlock()
|
||||
+
|
||||
+ // doBreak controls whether we break the TCP connection after the TLS
|
||||
+ // handshake (before the HTTP/2 handshake). We test a few failures
|
||||
+ // in a row followed by a final success.
|
||||
+ doBreak := i != numReqs
|
||||
+
|
||||
+ ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
|
||||
+ GotConn: func(info httptrace.GotConnInfo) {
|
||||
+ atomic.AddUint32(&gotConns, 1)
|
||||
+ },
|
||||
+ TLSHandshakeDone: func(cfg tls.ConnectionState, err error) {
|
||||
+ brokenState.Lock()
|
||||
+ defer brokenState.Unlock()
|
||||
+ if doBreak {
|
||||
+ brokenState.broken = true
|
||||
+ }
|
||||
+ },
|
||||
+ })
|
||||
+ req, err := NewRequestWithContext(ctx, "GET", cst.ts.URL, nil)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ _, err = cst.c.Do(req)
|
||||
+ if doBreak != (err != nil) {
|
||||
+ t.Errorf("for iteration %d, doBreak=%v; unexpected error %v", i, doBreak, err)
|
||||
+ }
|
||||
+ }
|
||||
+ if got, want := atomic.LoadUint32(&gotConns), 1; int(got) != want {
|
||||
+ t.Errorf("GotConn calls = %v; want %v", got, want)
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
From 94b6eec5dc639e87f0e2f739cfd257a432160881 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Roman=20Koll=C3=A1r?= <roman.kollar.0@gmail.com>
|
||||
Date: Thu, 21 Nov 2019 22:25:52 +0000
|
||||
Subject: [PATCH] [release-branch.go1.13] net/http: fix Server.ConnContext
|
||||
modifying context for all new connections
|
||||
|
||||
Updates #35750
|
||||
Fixes #35765
|
||||
|
||||
Change-Id: I65d38cfc5ddd66131777e104c269cc3559b2471d
|
||||
GitHub-Last-Rev: 953fdfd49b2be665be43f8148d2a6180dae3b91c
|
||||
GitHub-Pull-Request: golang/go#35751
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/208318
|
||||
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
||||
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
(cherry picked from commit bbbc6589dfbc05be2bfa59f51c20f9eaa8d0c531)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/208235
|
||||
Reviewed-by: Bryan C. Mills <bcmills@google.com>
|
||||
---
|
||||
src/net/http/serve_test.go | 33 +++++++++++++++++++++++++++++++++
|
||||
src/net/http/server.go | 7 ++++---
|
||||
2 files changed, 37 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go
|
||||
index 1d1449aa65..90f112b2ee 100644
|
||||
--- a/src/net/http/serve_test.go
|
||||
+++ b/src/net/http/serve_test.go
|
||||
@@ -6121,6 +6121,39 @@ func TestServerContextsHTTP2(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
+// Issue 35750: check ConnContext not modifying context for other connections
|
||||
+func TestConnContextNotModifyingAllContexts(t *testing.T) {
|
||||
+ setParallel(t)
|
||||
+ defer afterTest(t)
|
||||
+ type connKey struct{}
|
||||
+ ts := httptest.NewUnstartedServer(HandlerFunc(func(rw ResponseWriter, r *Request) {
|
||||
+ rw.Header().Set("Connection", "close")
|
||||
+ }))
|
||||
+ ts.Config.ConnContext = func(ctx context.Context, c net.Conn) context.Context {
|
||||
+ if got := ctx.Value(connKey{}); got != nil {
|
||||
+ t.Errorf("in ConnContext, unexpected context key = %#v", got)
|
||||
+ }
|
||||
+ return context.WithValue(ctx, connKey{}, "conn")
|
||||
+ }
|
||||
+ ts.Start()
|
||||
+ defer ts.Close()
|
||||
+
|
||||
+ var res *Response
|
||||
+ var err error
|
||||
+
|
||||
+ res, err = ts.Client().Get(ts.URL)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ res.Body.Close()
|
||||
+
|
||||
+ res, err = ts.Client().Get(ts.URL)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ res.Body.Close()
|
||||
+}
|
||||
+
|
||||
// Issue 30710: ensure that as per the spec, a server responds
|
||||
// with 501 Not Implemented for unsupported transfer-encodings.
|
||||
func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
|
||||
diff --git a/src/net/http/server.go b/src/net/http/server.go
|
||||
index 95a5eabaa2..8252e45aca 100644
|
||||
--- a/src/net/http/server.go
|
||||
+++ b/src/net/http/server.go
|
||||
@@ -2915,16 +2915,17 @@ func (srv *Server) Serve(l net.Listener) error {
|
||||
}
|
||||
return e
|
||||
}
|
||||
+ connCtx := ctx
|
||||
if cc := srv.ConnContext; cc != nil {
|
||||
- ctx = cc(ctx, rw)
|
||||
- if ctx == nil {
|
||||
+ connCtx = cc(connCtx, rw)
|
||||
+ if connCtx == nil {
|
||||
panic("ConnContext returned nil")
|
||||
}
|
||||
}
|
||||
tempDelay = 0
|
||||
c := srv.newConn(rw)
|
||||
c.setState(c.rwc, StateNew) // before Serve can return
|
||||
- go c.serve(ctx)
|
||||
+ go c.serve(connCtx)
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.17.1
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
From 6eee9903c7f970defbc0c9770397790b2bed5709 Mon Sep 17 00:00:00 2001
|
||||
From: Lynn Boger <laboger@linux.vnet.ibm.com>
|
||||
Date: Mon, 28 Oct 2019 09:29:40 -0400
|
||||
Subject: [PATCH] [release-branch.go1.13] runtime: fix textOff for multiple
|
||||
text sections
|
||||
|
||||
If a compilation has multiple text sections, code in
|
||||
textOff must compare the offset argument against the range
|
||||
for each text section to determine which one it is in.
|
||||
The comparison looks like this:
|
||||
|
||||
if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen
|
||||
|
||||
If the off value being compared is equal to sectaddr+sectlen then it
|
||||
is not within the range of the text section but after it. The
|
||||
comparison should be just '<'.
|
||||
|
||||
Fixes #35211
|
||||
|
||||
Change-Id: I114633fd734563d38f4e842dd884c6c239f73c95
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/203817
|
||||
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
|
||||
TryBot-Result: Gobot Gobot <gobot@golang.org>
|
||||
Reviewed-by: Ian Lance Taylor <iant@golang.org>
|
||||
Reviewed-by: Cherry Zhang <cherryyz@google.com>
|
||||
(cherry picked from commit 0ae9389609f23dc905c58fc2ad7bcc16b770f337)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/203819
|
||||
Run-TryBot: Carlos Amedee <carlos@golang.org>
|
||||
Reviewed-by: Keith Randall <khr@golang.org>
|
||||
---
|
||||
src/runtime/type.go | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/runtime/type.go b/src/runtime/type.go
|
||||
index 660b45ef39..5ae3c4b09e 100644
|
||||
--- a/src/runtime/type.go
|
||||
+++ b/src/runtime/type.go
|
||||
@@ -287,7 +287,7 @@ func (t *_type) textOff(off textOff) unsafe.Pointer {
|
||||
for i := range md.textsectmap {
|
||||
sectaddr := md.textsectmap[i].vaddr
|
||||
sectlen := md.textsectmap[i].length
|
||||
- if uintptr(off) >= sectaddr && uintptr(off) <= sectaddr+sectlen {
|
||||
+ if uintptr(off) >= sectaddr && uintptr(off) < sectaddr+sectlen {
|
||||
res = md.textsectmap[i].baseaddr + uintptr(off) - uintptr(md.textsectmap[i].vaddr)
|
||||
break
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
||||
BIN
go1.13.src.tar.gz
Normal file
BIN
go1.13.src.tar.gz
Normal file
Binary file not shown.
192
golang.spec
192
golang.spec
@ -1,104 +1,74 @@
|
||||
%global debug_package %{nil}
|
||||
%global _binaries_in_noarch_packages_terminate_build 0
|
||||
%global golibdir %{_libdir}/golang
|
||||
%global goroot /usr/lib/%{name}
|
||||
%global go_api 1.13
|
||||
%global go_version 1.13
|
||||
%global __spec_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot /usr/lib/rpm/brp-compress
|
||||
%global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$
|
||||
%global __strip /bin/true
|
||||
%define _use_internal_dependency_generator 0
|
||||
%define __find_requires %{nil}
|
||||
|
||||
%bcond_with bootstrap
|
||||
# temporalily ignore test failures
|
||||
%ifarch x86_64 aarch64
|
||||
%bcond_without ignore_tests
|
||||
%else
|
||||
%bcond_with ignore_tests
|
||||
%endif
|
||||
|
||||
# build ids are not currently generated:
|
||||
# https://code.google.com/p/go/issues/detail?id=5238
|
||||
#
|
||||
# also, debuginfo extraction currently fails with
|
||||
# "Failed to write file: invalid section alignment"
|
||||
%global debug_package %{nil}
|
||||
|
||||
# we are shipping the full contents of src in the data subpackage, which
|
||||
# contains binary-like things (ELF data for tests, etc)
|
||||
%global _binaries_in_noarch_packages_terminate_build 0
|
||||
|
||||
# Do not check any files in doc or src for requires
|
||||
%global __requires_exclude_from ^(%{_datadir}|/usr/lib)/%{name}/(doc|src)/.*$
|
||||
|
||||
# Don't alter timestamps of especially the .a files (or else go will rebuild later)
|
||||
# Actually, don't strip at all since we are not even building debug packages and this corrupts the dwarf testdata
|
||||
%global __strip /bin/true
|
||||
|
||||
# rpmbuild magic to keep from having meta dependency on libc.so.6
|
||||
%define _use_internal_dependency_generator 0
|
||||
%define __find_requires %{nil}
|
||||
%global __spec_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot \
|
||||
/usr/lib/rpm/brp-compress
|
||||
|
||||
%global golibdir %{_libdir}/golang
|
||||
|
||||
# Golang build options.
|
||||
|
||||
# Build golang using external/internal(close to cgo disabled) linking.
|
||||
%ifarch x86_64 aarch64
|
||||
%global external_linker 1
|
||||
%else
|
||||
%global external_linker 0
|
||||
%endif
|
||||
|
||||
# Build golang with cgo enabled/disabled(later equals more or less to internal linking).
|
||||
%ifarch x86_64 aarch64
|
||||
%global cgo_enabled 1
|
||||
%else
|
||||
%global cgo_enabled 0
|
||||
%endif
|
||||
|
||||
# Use golang/gcc-go as bootstrap compiler
|
||||
%if %{with bootstrap}
|
||||
%global golang_bootstrap 0
|
||||
%else
|
||||
%global golang_bootstrap 1
|
||||
%endif
|
||||
|
||||
# Controls what ever we fail on failed tests
|
||||
%if %{with ignore_tests}
|
||||
%global fail_on_tests 0
|
||||
%else
|
||||
%global fail_on_tests 1
|
||||
%endif
|
||||
|
||||
# Build golang shared objects for stdlib
|
||||
%ifarch x86_64 aarch64
|
||||
%global shared 1
|
||||
%else
|
||||
%global shared 0
|
||||
%endif
|
||||
|
||||
# Pre build std lib with -race enabled
|
||||
%ifarch x86_64
|
||||
%global race 1
|
||||
%else
|
||||
%global race 0
|
||||
%endif
|
||||
|
||||
%global goroot /usr/lib/%{name}
|
||||
|
||||
%ifarch x86_64
|
||||
%global gohostarch amd64
|
||||
%global gohostarch amd64
|
||||
%endif
|
||||
%ifarch aarch64
|
||||
%global gohostarch arm64
|
||||
%global gohostarch arm64
|
||||
%endif
|
||||
|
||||
%global go_api 1.11
|
||||
%global go_version 1.11
|
||||
|
||||
Name: golang
|
||||
Version: 1.11
|
||||
Release: 4
|
||||
Version: 1.13
|
||||
Release: 3.1
|
||||
Summary: The Go Programming Language
|
||||
# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
|
||||
License: BSD and Public Domain
|
||||
URL: http://golang.org/
|
||||
Source0: https://storage.googleapis.com/golang/go%{go_version}.src.tar.gz
|
||||
# make possible to override default traceback level at build time by setting build tag rpm_crashtraceback
|
||||
Source100: golang-gdbinit
|
||||
|
||||
# The compiler is written in Go. Needs go(1.4+) compiler for build.
|
||||
%if !%{golang_bootstrap}
|
||||
BuildRequires: gcc-go >= 5
|
||||
%else
|
||||
@ -110,46 +80,22 @@ BuildRequires: pcre-devel, glibc-static, perl-interpreter, procps-ng
|
||||
|
||||
Provides: go = %{version}-%{release}
|
||||
Requires: %{name}-devel = %{version}-%{release}
|
||||
# Pre-go1.5, all arches had to be bootstrapped individually, before usable, and
|
||||
# env variables to compile for the target os-arch.
|
||||
# Now the host compiler needs only the GOOS and GOARCH environment variables
|
||||
# set to compile for the target os-arch.
|
||||
|
||||
Obsoletes: %{name}-pkg-bin-linux-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-bin-linux-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-bin-linux-arm < 1.4.99
|
||||
Obsoletes: %{name}-pkg-linux-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-linux-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-linux-arm < 1.4.99
|
||||
Obsoletes: %{name}-pkg-darwin-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-darwin-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-windows-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-windows-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-plan9-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-plan9-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-freebsd-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-freebsd-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-freebsd-arm < 1.4.99
|
||||
Obsoletes: %{name}-pkg-netbsd-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-netbsd-amd64 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-netbsd-arm < 1.4.99
|
||||
Obsoletes: %{name}-pkg-openbsd-386 < 1.4.99
|
||||
Obsoletes: %{name}-pkg-openbsd-amd64 < 1.4.99
|
||||
|
||||
Obsoletes: golang-vet < 0-12.1
|
||||
Obsoletes: golang-cover < 0-12.1
|
||||
Obsoletes: %{name}-vet < 0-12.1
|
||||
Obsoletes: %{name}-cover < 0-12.1
|
||||
|
||||
Requires(post): %{_sbindir}/update-alternatives
|
||||
Requires(postun): %{_sbindir}/update-alternatives
|
||||
|
||||
# We strip the meta dependency, but go does require glibc.
|
||||
# This is an odd issue, still looking for a better fix.
|
||||
Requires: glibc
|
||||
Requires: gcc
|
||||
Requires: git, subversion, mercurial
|
||||
Requires: glibc gcc git, subversion, mercurial
|
||||
|
||||
|
||||
|
||||
# Bundled/Vendored provides generated by
|
||||
# generated by:
|
||||
# go list -f {{.ImportPath}} ./src/vendor/... | sed "s:_$PWD/src/vendor/::g;s:_:.:;s:.*:Provides\: bundled(golang(&)):" && go list -f {{.ImportPath}} ./src/cmd/vendor/... | sed "s:_$PWD/src/cmd/vendor/::g;s:_:.:;s:.*:Provides\: bundled(golang(&)):"
|
||||
Provides: bundled(golang(golang.org/x/crypto/chacha20poly1305))
|
||||
Provides: bundled(golang(golang.org/x/crypto/cryptobyte))
|
||||
@ -194,29 +140,30 @@ Provides: bundled(golang(golang.org/x/crypto/ssh/terminal))
|
||||
Provides: bundled(golang(golang.org/x/sys/unix))
|
||||
Provides: bundled(golang(golang.org/x/sys/windows))
|
||||
Provides: bundled(golang(golang.org/x/sys/windows/registry))
|
||||
|
||||
Provides: %{name}-bin = %{version}-%{release}
|
||||
Obsoletes: %{name}-bin
|
||||
Obsoletes: %{name}-shared
|
||||
Requires: go-srpm-macros
|
||||
|
||||
Patch1: 0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
|
||||
Patch2: 0002-syscall-expose-IfInfomsg.X__ifi_pad-on-s390x.patch
|
||||
Patch3: 0003-release-branch.go1.11-security-crypto-elliptic-reduc.patch
|
||||
Patch4: 0004-fix-CVE-2019-9512-9514.patch
|
||||
|
||||
# Having documentation separate was broken
|
||||
Obsoletes: %{name}-docs
|
||||
|
||||
# RPM can't handle symlink -> dir with subpackages, so merge back
|
||||
Obsoletes: %{name}-data < 1.1.1-4
|
||||
|
||||
# go1.4 deprecates a few packages
|
||||
Obsoletes: %{name}-vim < 1.4
|
||||
Obsoletes: emacs-%{name} < 1.4
|
||||
Requires: openEuler-rpm-config
|
||||
|
||||
Patch6001: backport-0001-Don-t-use-the-bundled-tzdata-at-runtime-except-for-t.patch
|
||||
Patch6002: backport-0002-syscall-expose-IfInfomsg.X__ifi_pad-on-s390x.patch
|
||||
Patch6003: backport-0003-golang-delete-pem-files.patch
|
||||
Patch6004: backport-0004-syscall-implement-rawVforkSyscall-for-linux-arm64.patch
|
||||
Patch6005: backport-0005-runtime-fix-crash-during-VDSO-calls-on-arm.patch
|
||||
Patch6006: backport-0006-runtime-save-fetch-g-register-during-VDSO-on-ARM-and.patch
|
||||
Patch6007: backport-0007-runtime-don-t-fetch-G-from-signal-stack-when-using-c.patch
|
||||
Patch6008: backport-0008-runtime-don-t-save-G-during-VDSO-if-we-re-handling-s.patch
|
||||
Patch6009: backport-0009-release-branch.go1.13-net-http-don-t-cache-http2.err.patch
|
||||
Patch6010: backport-0010-release-branch.go1.13-net-http-fix-Server.ConnContex.patch
|
||||
Patch6011: backport-0011-release-branch.go1.13-runtime-fix-textOff-for-multip.patch
|
||||
|
||||
ExclusiveArch: %{golang_arches}
|
||||
|
||||
Source100: golang-gdbinit
|
||||
|
||||
%description
|
||||
%{summary}.
|
||||
@ -230,14 +177,13 @@ Obsoletes: %{name}-docs
|
||||
Provides: %{name}-shared = %{version}-%{release}
|
||||
Obsoletes: %{name}-shared
|
||||
|
||||
|
||||
%description help
|
||||
%{summary}.
|
||||
|
||||
%package devel
|
||||
Summary: Golang compiler devel
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
BuildArch: noarch
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Provides: %{name}-src = %{version}-%{release}
|
||||
Obsoletes: %{name}-src
|
||||
Provides: %{name}-tests = %{version}-%{release}
|
||||
@ -263,26 +209,21 @@ end
|
||||
%autosetup -n go -p1
|
||||
|
||||
%build
|
||||
# print out system information
|
||||
uname -a
|
||||
cat /proc/cpuinfo
|
||||
cat /proc/meminfo
|
||||
|
||||
# bootstrap compiler GOROOT
|
||||
%if !%{golang_bootstrap}
|
||||
export GOROOT_BOOTSTRAP=/
|
||||
%else
|
||||
export GOROOT_BOOTSTRAP=%{goroot}
|
||||
%endif
|
||||
|
||||
# set up final install location
|
||||
export GOROOT_FINAL=%{goroot}
|
||||
|
||||
export GOHOSTOS=linux
|
||||
export GOHOSTARCH=%{gohostarch}
|
||||
|
||||
pushd src
|
||||
# use our gcc options for this build, but store gcc as default for compiler
|
||||
export CFLAGS="$RPM_OPT_FLAGS"
|
||||
export LDFLAGS="$RPM_LD_FLAGS"
|
||||
export CC="gcc"
|
||||
@ -303,7 +244,6 @@ export GO_LDFLAGS="-s -w"
|
||||
./make.bash --no-clean -v
|
||||
popd
|
||||
|
||||
# build shared std lib
|
||||
%if %{shared}
|
||||
GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared -v -x std
|
||||
%endif
|
||||
@ -313,24 +253,20 @@ GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -race -v -x std
|
||||
%endif
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
# remove GC build cache
|
||||
rm -rf %{buildroot}
|
||||
rm -rf pkg/obj/go-build/*
|
||||
|
||||
# create the top level directories
|
||||
mkdir -p $RPM_BUILD_ROOT%{_bindir}
|
||||
mkdir -p $RPM_BUILD_ROOT%{goroot}
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
mkdir -p %{buildroot}%{goroot}
|
||||
|
||||
# install everything into libdir (until symlink problems are fixed)
|
||||
# https://code.google.com/p/go/issues/detail?id=5830
|
||||
cp -apv api bin doc favicon.ico lib pkg robots.txt src misc test VERSION \
|
||||
$RPM_BUILD_ROOT%{goroot}
|
||||
%{buildroot}%{goroot}
|
||||
|
||||
# bz1099206
|
||||
find $RPM_BUILD_ROOT%{goroot}/src -exec touch -r $RPM_BUILD_ROOT%{goroot}/VERSION "{}" \;
|
||||
find %{buildroot}%{goroot}/src -exec touch -r %{buildroot}%{goroot}/VERSION "{}" \;
|
||||
# and level out all the built archives
|
||||
touch $RPM_BUILD_ROOT%{goroot}/pkg
|
||||
find $RPM_BUILD_ROOT%{goroot}/pkg -exec touch -r $RPM_BUILD_ROOT%{goroot}/pkg "{}" \;
|
||||
touch %{buildroot}%{goroot}/pkg
|
||||
find %{buildroot}%{goroot}/pkg -exec touch -r %{buildroot}%{goroot}/pkg "{}" \;
|
||||
# generate the spec file ownership of this source tree and packages
|
||||
cwd=$(pwd)
|
||||
src_list=$cwd/go-src.list
|
||||
@ -342,7 +278,7 @@ docs_list=$cwd/go-docs.list
|
||||
tests_list=$cwd/go-tests.list
|
||||
rm -f $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list $race_list
|
||||
touch $src_list $pkg_list $docs_list $misc_list $tests_list $shared_list $race_list
|
||||
pushd $RPM_BUILD_ROOT%{goroot}
|
||||
pushd %{buildroot}%{goroot}
|
||||
find src/ -type d -a \( ! -name testdata -a ! -ipath '*/testdata/*' \) -printf '%%%dir %{goroot}/%p\n' >> $src_list
|
||||
find src/ ! -type d -a \( ! -ipath '*/testdata/*' -a ! -name '*_test.go' \) -printf '%{goroot}/%p\n' >> $src_list
|
||||
|
||||
@ -388,24 +324,19 @@ pushd $RPM_BUILD_ROOT%{goroot}
|
||||
find lib/ ! -type d -printf '%{goroot}/%p\n' >> $tests_list
|
||||
popd
|
||||
|
||||
# remove the doc Makefile
|
||||
rm -rfv $RPM_BUILD_ROOT%{goroot}/doc/Makefile
|
||||
rm -rfv %{buildroot}%{goroot}/doc/Makefile
|
||||
|
||||
# put binaries to bindir, linked to the arch we're building,
|
||||
# leave the arch independent pieces in {goroot}
|
||||
mkdir -p $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}
|
||||
ln -sf %{goroot}/bin/go $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/go
|
||||
ln -sf %{goroot}/bin/gofmt $RPM_BUILD_ROOT%{goroot}/bin/linux_%{gohostarch}/gofmt
|
||||
mkdir -p %{buildroot}%{goroot}/bin/linux_%{gohostarch}
|
||||
ln -sf %{goroot}/bin/go %{buildroot}%{goroot}/bin/linux_%{gohostarch}/go
|
||||
ln -sf %{goroot}/bin/gofmt %{buildroot}%{goroot}/bin/linux_%{gohostarch}/gofmt
|
||||
|
||||
# ensure these exist and are owned
|
||||
mkdir -p $RPM_BUILD_ROOT%{gopath}/src/github.com
|
||||
mkdir -p $RPM_BUILD_ROOT%{gopath}/src/bitbucket.org
|
||||
mkdir -p $RPM_BUILD_ROOT%{gopath}/src/code.google.com/p
|
||||
mkdir -p $RPM_BUILD_ROOT%{gopath}/src/golang.org/x
|
||||
mkdir -p %{buildroot}%{gopath}/src/github.com
|
||||
mkdir -p %{buildroot}%{gopath}/src/bitbucket.org
|
||||
mkdir -p %{buildroot}%{gopath}/src/code.google.com/p
|
||||
mkdir -p %{buildroot}%{gopath}/src/golang.org/x
|
||||
|
||||
# gdbinit
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d
|
||||
cp -av %{SOURCE100} $RPM_BUILD_ROOT%{_sysconfdir}/gdbinit.d/golang.gdb
|
||||
mkdir -p %{buildroot}%{_sysconfdir}/gdbinit.d
|
||||
cp -av %{SOURCE100} %{buildroot}%{_sysconfdir}/gdbinit.d/golang.gdb
|
||||
|
||||
%check
|
||||
export GOROOT=$(pwd -P)
|
||||
@ -422,18 +353,15 @@ export GO_LDFLAGS="-linkmode internal"
|
||||
export CGO_ENABLED=0
|
||||
%endif
|
||||
|
||||
# make sure to not timeout
|
||||
export GO_TEST_TIMEOUT_SCALE=2
|
||||
|
||||
%if %{fail_on_tests}
|
||||
# ./run.bash --no-rebuild -v -v -v -k
|
||||
echo tests ignored
|
||||
%else
|
||||
./run.bash --no-rebuild -v -v -v -k || :
|
||||
%endif
|
||||
cd ..
|
||||
|
||||
|
||||
%post
|
||||
%{_sbindir}/update-alternatives --install %{_bindir}/go \
|
||||
go %{goroot}/bin/go 90 \
|
||||
@ -444,23 +372,17 @@ if [ $1 = 0 ]; then
|
||||
%{_sbindir}/update-alternatives --remove go %{goroot}/bin/go
|
||||
fi
|
||||
|
||||
|
||||
%files -f go-pkg.list
|
||||
%doc AUTHORS CONTRIBUTORS LICENSE PATENTS
|
||||
# VERSION has to be present in the GOROOT, for `go install std` to work
|
||||
%doc %{goroot}/VERSION
|
||||
%dir %{goroot}/doc
|
||||
%doc %{goroot}/doc/*
|
||||
|
||||
# go files
|
||||
%dir %{goroot}
|
||||
%exclude %{goroot}/src/
|
||||
%exclude %{goroot}/doc/
|
||||
%exclude %{goroot}/misc/
|
||||
%exclude %{goroot}/test/
|
||||
%{goroot}/*
|
||||
|
||||
# ensure directory ownership, so they are cleaned up if empty
|
||||
%dir %{gopath}
|
||||
%dir %{gopath}/src
|
||||
%dir %{gopath}/src/github.com/
|
||||
@ -470,7 +392,6 @@ fi
|
||||
%dir %{gopath}/src/golang.org
|
||||
%dir %{gopath}/src/golang.org/x
|
||||
|
||||
# gdbinit (for gdb debugging)
|
||||
%{_sysconfdir}/gdbinit.d
|
||||
|
||||
%files help -f go-docs.list -f go-shared.list
|
||||
@ -478,5 +399,8 @@ fi
|
||||
%files devel -f go-tests.list -f go-misc.list -f go-src.list
|
||||
|
||||
%changelog
|
||||
* Tue Dec 10 2019 jingrui<jingrui@huawei.com> - 1.13.3.1
|
||||
- upgrade to golang 1.13.3
|
||||
|
||||
* Tue Sep 03 2019 leizhongkai<leizhongkai@huawei.com> - 1.11-1
|
||||
- backport fix CVE-2019-9512 and CVE-2019-9514
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user