Bug#993318: bullseye-pu: package golang-1.15/1.15.15-1~deb11u1
On Sat, Sep 11, 2021 at 11:28:18AM +0100, Adam D. Barratt wrote:
> Do any of these changes imply needing to rebuild dependent packages? If
> so, which ones?
>
These changes include fixes for Go std library, runtime, and the `go` command.
The changes for std library and runtime are only effected after rebuilding.
If the question is how many packages need to rebuild to make the changes in
golang-1.15 packages be propagated, the all Go packages need to rebuild.
However I don't think these issues are important enough to do an archive-wide
rebuild. For example the referred first CVE is marked as non-dsa. The second
is new but my assumption is also not urgent.
The golang-1.15 package is not only for building the Go packages but also
for people using it to compile on their own. So it still worth to update for
bullseye.
> > The full diff is still at
> > https://people.debian.org/~zhsj/golang-1.15_1.15.15-1~deb11u1.debdiff
>
> It needs to be attached to this bug report, please, as reportbug should
> have requested and as documented. The request should be self-contained,
> not relying on external resources that might change or be removed.
>
Attached now.
diff -Nru golang-1.15-1.15.9/debian/changelog golang-1.15-1.15.15/debian/changelog
--- golang-1.15-1.15.9/debian/changelog 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/changelog 2021-09-11 15:54:07.000000000 +0800
@@ -1,3 +1,29 @@
+golang-1.15 (1.15.15-1~deb11u1) bullseye; urgency=medium
+
+ [ Anthony Fok ]
+ * Fix Lintian warning tab-in-license-text
+ debian/copyright (starting at line 381)
+
+ [ Shengjing Zhu ]
+ * Rebuild 1.15.15 for bullseye
+ + Include fix for CVE-2021-36221 (Closes: #991961)
+ net/http: panic due to racy read of persistConn after handler panic
+ * Backport patch for CVE-2021-39293
+ archive/zip: overflow in preallocation check can cause OOM panic
+
+ -- Shengjing Zhu <zhsj@debian.org> Sat, 11 Sep 2021 15:54:07 +0800
+
+golang-1.15 (1.15.15-1) unstable; urgency=medium
+
+ * Team upload.
+ * New upstream version 1.15.15
+ * Remove security patches which were previously backported
+ for 1.15.9 but are already in 1.15.15
+ * Update Standards-Version to 4.5.1, no changes needed
+ * Change Section from devel to golang
+
+ -- Anthony Fok <foka@debian.org> Sun, 15 Aug 2021 16:44:15 -0600
+
golang-1.15 (1.15.9-6) unstable; urgency=medium
* Team upload.
diff -Nru golang-1.15-1.15.9/debian/control golang-1.15-1.15.15/debian/control
--- golang-1.15-1.15.9/debian/control 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/control 2021-09-11 15:54:07.000000000 +0800
@@ -9,12 +9,12 @@
Tianon Gravi <tianon@debian.org>,
Michael Hudson-Doyle <mwhudson@debian.org>,
Dr. Tobias Quathamer <toddy@debian.org>
-Section: devel
+Section: golang
Priority: optional
Build-Depends: debhelper-compat (= 13),
golang-any (>= 2:1.4~) | golang-go (>= 2:1.4~) | gccgo (>= 4:5~),
netbase
-Standards-Version: 4.5.0
+Standards-Version: 4.5.1
Vcs-Browser: https://salsa.debian.org/go-team/compiler/golang/tree/golang-1.15
Vcs-Git: https://salsa.debian.org/go-team/compiler/golang.git -b golang-1.15
Homepage: https://golang.org
diff -Nru golang-1.15-1.15.9/debian/control.in golang-1.15-1.15.15/debian/control.in
--- golang-1.15-1.15.9/debian/control.in 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/control.in 2021-09-11 15:54:07.000000000 +0800
@@ -5,12 +5,12 @@
Tianon Gravi <tianon@debian.org>,
Michael Hudson-Doyle <mwhudson@debian.org>,
Dr. Tobias Quathamer <toddy@debian.org>
-Section: devel
+Section: golang
Priority: optional
Build-Depends: debhelper-compat (= 13),
golang-any (>= 2:1.4~) | golang-go (>= 2:1.4~) | gccgo (>= 4:5~),
netbase
-Standards-Version: 4.5.0
+Standards-Version: 4.5.1
Vcs-Browser: https://salsa.debian.org/go-team/compiler/golang/tree/golang-X.Y
Vcs-Git: https://salsa.debian.org/go-team/compiler/golang.git -b golang-X.Y
Homepage: https://golang.org
diff -Nru golang-1.15-1.15.9/debian/copyright golang-1.15-1.15.15/debian/copyright
--- golang-1.15-1.15.9/debian/copyright 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/copyright 2021-09-11 15:54:07.000000000 +0800
@@ -514,25 +514,25 @@
.
e. For the avoidance of doubt:
.
- i. Non-waivable Compulsory License Schemes. In those
- jurisdictions in which the right to collect royalties
- through any statutory or compulsory licensing scheme cannot
- be waived, the Licensor reserves the exclusive right to
- collect such royalties for any exercise by You of the
+ i. Non-waivable Compulsory License Schemes. In those
+ jurisdictions in which the right to collect royalties
+ through any statutory or compulsory licensing scheme cannot
+ be waived, the Licensor reserves the exclusive right to
+ collect such royalties for any exercise by You of the
rights granted under this License;
.
ii. Waivable Compulsory License Schemes. In those jurisdictions
- in which the right to collect royalties through any
- statutory or compulsory licensing scheme can be waived, the
- Licensor waives the exclusive right to collect such
- royalties for any exercise by You of the rights granted
+ in which the right to collect royalties through any
+ statutory or compulsory licensing scheme can be waived, the
+ Licensor waives the exclusive right to collect such
+ royalties for any exercise by You of the rights granted
under this License; and,
.
iii. Voluntary License Schemes. The Licensor waives the right to
- collect royalties, whether individually or, in the event
- that the Licensor is a member of a collecting society that
- administers voluntary licensing schemes, via that society,
- from any exercise by You of the rights granted under this
+ collect royalties, whether individually or, in the event
+ that the Licensor is a member of a collecting society that
+ administers voluntary licensing schemes, via that society,
+ from any exercise by You of the rights granted under this
License.
.
The above rights may be exercised in all media and formats whether
diff -Nru golang-1.15-1.15.9/debian/patches/0006-skip-userns-test-in-schroot-as-well.patch golang-1.15-1.15.15/debian/patches/0006-skip-userns-test-in-schroot-as-well.patch
--- golang-1.15-1.15.9/debian/patches/0006-skip-userns-test-in-schroot-as-well.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0006-skip-userns-test-in-schroot-as-well.patch 2021-09-11 15:54:07.000000000 +0800
@@ -8,7 +8,7 @@
1 file changed, 7 insertions(+)
diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go
-index b79dee7..9f3d651 100644
+index df4ed62..ea38bca 100644
--- a/src/syscall/exec_linux_test.go
+++ b/src/syscall/exec_linux_test.go
@@ -33,6 +33,10 @@ func isLXC() bool {
diff -Nru golang-1.15-1.15.9/debian/patches/0007-CVE-2021-31525.patch golang-1.15-1.15.15/debian/patches/0007-CVE-2021-31525.patch
--- golang-1.15-1.15.9/debian/patches/0007-CVE-2021-31525.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0007-CVE-2021-31525.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,45 +0,0 @@
-From: Katie Hockman <katie@golang.org>
-Date: Wed, 28 Apr 2021 14:47:48 -0400
-Subject: [PATCH] [release-branch.go1.15] std: update golang.org/x/net to
- 20210428183841-261fb518b1ed
-
-Steps:
- go get -d golang.org/x/net@release-branch.go1.15
- go mod tidy
- go mod vendor
-
-This http2 bundle does not need to be updated.
-
-Fixes #45711
-
-Change-Id: I085ca592dfc8d5d9c328a7979142e88e7130a813
-Reviewed-on: https://go-review.googlesource.com/c/go/+/314790
-Trust: Katie Hockman <katie@golang.org>
-Run-TryBot: Katie Hockman <katie@golang.org>
-Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
----
- src/vendor/golang.org/x/net/http/httpguts/httplex.go | 10 ++++++----
- 1 file changed, 6 insertions(+), 4 deletions(-)
-
-diff --git a/src/vendor/golang.org/x/net/http/httpguts/httplex.go b/src/vendor/golang.org/x/net/http/httpguts/httplex.go
-index e7de24e..c79aa73 100644
---- a/src/vendor/golang.org/x/net/http/httpguts/httplex.go
-+++ b/src/vendor/golang.org/x/net/http/httpguts/httplex.go
-@@ -137,11 +137,13 @@ func trimOWS(x string) string {
- // contains token amongst its comma-separated tokens, ASCII
- // case-insensitively.
- func headerValueContainsToken(v string, token string) bool {
-- v = trimOWS(v)
-- if comma := strings.IndexByte(v, ','); comma != -1 {
-- return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token)
-+ for comma := strings.IndexByte(v, ','); comma != -1; comma = strings.IndexByte(v, ',') {
-+ if tokenEqual(trimOWS(v[:comma]), token) {
-+ return true
-+ }
-+ v = v[comma+1:]
- }
-- return tokenEqual(v, token)
-+ return tokenEqual(trimOWS(v), token)
- }
-
- // lowerASCII returns the ASCII lowercase version of b.
diff -Nru golang-1.15-1.15.9/debian/patches/0007-CVE-2021-39293.patch golang-1.15-1.15.15/debian/patches/0007-CVE-2021-39293.patch
--- golang-1.15-1.15.9/debian/patches/0007-CVE-2021-39293.patch 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0007-CVE-2021-39293.patch 2021-09-11 15:54:07.000000000 +0800
@@ -0,0 +1,49 @@
+From: Roland Shoemaker <roland@golang.org>
+Date: Wed, 18 Aug 2021 11:49:29 -0700
+Subject: CVE-2021-39293
+
+Origin: backport, https://github.com/golang/go/commit/bacbc334
+---
+ src/archive/zip/reader.go | 2 +-
+ src/archive/zip/reader_test.go | 18 ++++++++++++++++++
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
+index 2d5151a..a695773 100644
+--- a/src/archive/zip/reader.go
++++ b/src/archive/zip/reader.go
+@@ -90,7 +90,7 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
+ // indicate it contains up to 1 << 128 - 1 files. Since each file has a
+ // header which will be _at least_ 30 bytes we can safely preallocate
+ // if (data size / 30) >= end.directoryRecords.
+- if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
++ if end.directorySize < uint64(size) && (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
+ z.File = make([]*File, 0, end.directoryRecords)
+ }
+ z.Comment = end.comment
+diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
+index 6f67d2e..ef6ff5f 100644
+--- a/src/archive/zip/reader_test.go
++++ b/src/archive/zip/reader_test.go
+@@ -1129,3 +1129,21 @@ func TestCVE202133196(t *testing.T) {
+ t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
+ }
+ }
++
++func TestCVE202139293(t *testing.T) {
++ // directory size is so large, that the check in Reader.init
++ // overflows when subtracting from the archive size, causing
++ // the pre-allocation check to be bypassed.
++ data := []byte{
++ 0x50, 0x4b, 0x06, 0x06, 0x05, 0x06, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
++ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
++ 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x4b,
++ 0x06, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
++ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
++ 0xff, 0x50, 0xfe, 0x00, 0xff, 0x00, 0x3a, 0x00, 0x00, 0x00, 0xff,
++ }
++ _, err := NewReader(bytes.NewReader(data), int64(len(data)))
++ if err != ErrFormat {
++ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
++ }
++}
diff -Nru golang-1.15-1.15.9/debian/patches/0008-CVE-2021-33196.patch golang-1.15-1.15.15/debian/patches/0008-CVE-2021-33196.patch
--- golang-1.15-1.15.9/debian/patches/0008-CVE-2021-33196.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0008-CVE-2021-33196.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,124 +0,0 @@
-From: Roland Shoemaker <roland@golang.org>
-Date: Tue, 11 May 2021 11:31:31 -0700
-Subject: archive/zip: only preallocate File slice if reasonably sized
-
-Since the number of files in the EOCD record isn't validated, it isn't
-safe to preallocate Reader.Files using that field. A malformed archive
-can indicate it contains up to 1 << 128 - 1 files. We can still safely
-preallocate the slice by checking if the specified number of files in
-the archive is reasonable, given the size of the archive.
-
-Thanks to the OSS-Fuzz project for discovering this issue and to
-Emmanuel Odeke for reporting it.
-
-Updates #46242
-Fixes #46396
-Fixes CVE-2021-33196
-
-Change-Id: I3c76d8eec178468b380d87fdb4a3f2cb06f0ee76
-Reviewed-on: https://go-review.googlesource.com/c/go/+/318909
-Trust: Roland Shoemaker <roland@golang.org>
-Trust: Katie Hockman <katie@golang.org>
-Trust: Joe Tsai <thebrokentoaster@gmail.com>
-Run-TryBot: Roland Shoemaker <roland@golang.org>
-TryBot-Result: Go Bot <gobot@golang.org>
-Reviewed-by: Katie Hockman <katie@golang.org>
-Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
-(cherry picked from commit 74242baa4136c7a9132a8ccd9881354442788c8c)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/322949
-Reviewed-by: Filippo Valsorda <filippo@golang.org>
-
-Origin: backport, https://github.com/golang/go/commit/c92adf420a3d9a5510f9aea382d826f0c9216a10
----
- src/archive/zip/reader.go | 10 ++++++-
- src/archive/zip/reader_test.go | 59 ++++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 68 insertions(+), 1 deletion(-)
-
-diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
-index 13ff9dd..2d5151a 100644
---- a/src/archive/zip/reader.go
-+++ b/src/archive/zip/reader.go
-@@ -84,7 +84,15 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
- return err
- }
- z.r = r
-- z.File = make([]*File, 0, end.directoryRecords)
-+ // Since the number of directory records is not validated, it is not
-+ // safe to preallocate z.File without first checking that the specified
-+ // number of files is reasonable, since a malformed archive may
-+ // indicate it contains up to 1 << 128 - 1 files. Since each file has a
-+ // header which will be _at least_ 30 bytes we can safely preallocate
-+ // if (data size / 30) >= end.directoryRecords.
-+ if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
-+ z.File = make([]*File, 0, end.directoryRecords)
-+ }
- z.Comment = end.comment
- rs := io.NewSectionReader(r, 0, size)
- if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil {
-diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
-index adca87a..6f67d2e 100644
---- a/src/archive/zip/reader_test.go
-+++ b/src/archive/zip/reader_test.go
-@@ -1070,3 +1070,62 @@ func TestIssue12449(t *testing.T) {
- t.Errorf("Error reading the archive: %v", err)
- }
- }
-+
-+func TestCVE202133196(t *testing.T) {
-+ // Archive that indicates it has 1 << 128 -1 files,
-+ // this would previously cause a panic due to attempting
-+ // to allocate a slice with 1 << 128 -1 elements.
-+ data := []byte{
-+ 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x08, 0x08,
-+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02,
-+ 0x03, 0x62, 0x61, 0x65, 0x03, 0x04, 0x00, 0x00,
-+ 0xff, 0xff, 0x50, 0x4b, 0x07, 0x08, 0xbe, 0x20,
-+ 0x5c, 0x6c, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00,
-+ 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00,
-+ 0x14, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0xbe, 0x20, 0x5c, 0x6c, 0x09, 0x00,
-+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00,
-+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-+ 0x01, 0x02, 0x03, 0x50, 0x4b, 0x06, 0x06, 0x2c,
-+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d,
-+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
-+ 0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x06, 0x07, 0x00,
-+ 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00,
-+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50,
-+ 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0xff,
-+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-+ 0xff, 0xff, 0xff, 0x00, 0x00,
-+ }
-+ _, err := NewReader(bytes.NewReader(data), int64(len(data)))
-+ if err != ErrFormat {
-+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
-+ }
-+
-+ // Also check that an archive containing a handful of empty
-+ // files doesn't cause an issue
-+ b := bytes.NewBuffer(nil)
-+ w := NewWriter(b)
-+ for i := 0; i < 5; i++ {
-+ _, err := w.Create("")
-+ if err != nil {
-+ t.Fatalf("Writer.Create failed: %s", err)
-+ }
-+ }
-+ if err := w.Close(); err != nil {
-+ t.Fatalf("Writer.Close failed: %s", err)
-+ }
-+ r, err := NewReader(bytes.NewReader(b.Bytes()), int64(b.Len()))
-+ if err != nil {
-+ t.Fatalf("NewReader failed: %s", err)
-+ }
-+ if len(r.File) != 5 {
-+ t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
-+ }
-+}
diff -Nru golang-1.15-1.15.9/debian/patches/0009-CVE-2021-33195-1.patch golang-1.15-1.15.15/debian/patches/0009-CVE-2021-33195-1.patch
--- golang-1.15-1.15.9/debian/patches/0009-CVE-2021-33195-1.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0009-CVE-2021-33195-1.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,369 +0,0 @@
-From 31d60cda1f58b7558fc5725d2b9e4531655d980e Mon Sep 17 00:00:00 2001
-From: Roland Shoemaker <roland@golang.org>
-Date: Thu, 27 May 2021 10:40:06 -0700
-Subject: [PATCH] [release-branch.go1.15] net: verify results from Lookup* are
- valid domain names
-
-For the methods LookupCNAME, LookupSRV, LookupMX, LookupNS, and
-LookupAddr check that the returned domain names are in fact valid DNS
-names using the existing isDomainName function.
-
-Thanks to Philipp Jeitner and Haya Shulman from Fraunhofer SIT for
-reporting this issue.
-
-Updates #46241
-Fixes #46356
-Fixes CVE-2021-33195
-
-Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3
-Reviewed-on: https://go-review.googlesource.com/c/go/+/323131
-Trust: Roland Shoemaker <roland@golang.org>
-Run-TryBot: Roland Shoemaker <roland@golang.org>
-TryBot-Result: Go Bot <gobot@golang.org>
-Reviewed-by: Filippo Valsorda <filippo@golang.org>
-Reviewed-by: Katie Hockman <katie@golang.org>
-(cherry picked from commit cdcd02842da7c004efd023881e3719105209c908)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/323269
----
- src/net/dnsclient_unix_test.go | 157 +++++++++++++++++++++++++++++++++
- src/net/lookup.go | 111 ++++++++++++++++++++---
- 2 files changed, 255 insertions(+), 13 deletions(-)
-
-diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go
-index 06553636eee25..819f20b887ae6 100644
---- a/src/net/dnsclient_unix_test.go
-+++ b/src/net/dnsclient_unix_test.go
-@@ -1799,3 +1799,160 @@ func TestPTRandNonPTR(t *testing.T) {
- t.Errorf("names = %q; want %q", names, want)
- }
- }
-+
-+func TestCVE202133195(t *testing.T) {
-+ fake := fakeDNSServer{
-+ rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
-+ r := dnsmessage.Message{
-+ Header: dnsmessage.Header{
-+ ID: q.Header.ID,
-+ Response: true,
-+ RCode: dnsmessage.RCodeSuccess,
-+ RecursionAvailable: true,
-+ },
-+ Questions: q.Questions,
-+ }
-+ switch q.Questions[0].Type {
-+ case dnsmessage.TypeCNAME:
-+ r.Answers = []dnsmessage.Resource{}
-+ case dnsmessage.TypeA: // CNAME lookup uses a A/AAAA as a proxy
-+ r.Answers = append(r.Answers,
-+ dnsmessage.Resource{
-+ Header: dnsmessage.ResourceHeader{
-+ Name: dnsmessage.MustNewName("<html>.golang.org."),
-+ Type: dnsmessage.TypeA,
-+ Class: dnsmessage.ClassINET,
-+ Length: 4,
-+ },
-+ Body: &dnsmessage.AResource{
-+ A: TestAddr,
-+ },
-+ },
-+ )
-+ case dnsmessage.TypeSRV:
-+ n := q.Questions[0].Name
-+ if n.String() == "_hdr._tcp.golang.org." {
-+ n = dnsmessage.MustNewName("<html>.golang.org.")
-+ }
-+ r.Answers = append(r.Answers,
-+ dnsmessage.Resource{
-+ Header: dnsmessage.ResourceHeader{
-+ Name: n,
-+ Type: dnsmessage.TypeSRV,
-+ Class: dnsmessage.ClassINET,
-+ Length: 4,
-+ },
-+ Body: &dnsmessage.SRVResource{
-+ Target: dnsmessage.MustNewName("<html>.golang.org."),
-+ },
-+ },
-+ )
-+ case dnsmessage.TypeMX:
-+ r.Answers = append(r.Answers,
-+ dnsmessage.Resource{
-+ Header: dnsmessage.ResourceHeader{
-+ Name: dnsmessage.MustNewName("<html>.golang.org."),
-+ Type: dnsmessage.TypeMX,
-+ Class: dnsmessage.ClassINET,
-+ Length: 4,
-+ },
-+ Body: &dnsmessage.MXResource{
-+ MX: dnsmessage.MustNewName("<html>.golang.org."),
-+ },
-+ },
-+ )
-+ case dnsmessage.TypeNS:
-+ r.Answers = append(r.Answers,
-+ dnsmessage.Resource{
-+ Header: dnsmessage.ResourceHeader{
-+ Name: dnsmessage.MustNewName("<html>.golang.org."),
-+ Type: dnsmessage.TypeNS,
-+ Class: dnsmessage.ClassINET,
-+ Length: 4,
-+ },
-+ Body: &dnsmessage.NSResource{
-+ NS: dnsmessage.MustNewName("<html>.golang.org."),
-+ },
-+ },
-+ )
-+ case dnsmessage.TypePTR:
-+ r.Answers = append(r.Answers,
-+ dnsmessage.Resource{
-+ Header: dnsmessage.ResourceHeader{
-+ Name: dnsmessage.MustNewName("<html>.golang.org."),
-+ Type: dnsmessage.TypePTR,
-+ Class: dnsmessage.ClassINET,
-+ Length: 4,
-+ },
-+ Body: &dnsmessage.PTRResource{
-+ PTR: dnsmessage.MustNewName("<html>.golang.org."),
-+ },
-+ },
-+ )
-+ }
-+ return r, nil
-+ },
-+ }
-+
-+ r := Resolver{PreferGo: true, Dial: fake.DialContext}
-+ // Change the default resolver to match our manipulated resolver
-+ originalDefault := DefaultResolver
-+ DefaultResolver = &r
-+ defer func() {
-+ DefaultResolver = originalDefault
-+ }()
-+
-+ _, err := r.LookupCNAME(context.Background(), "golang.org")
-+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, err = LookupCNAME("golang.org")
-+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+
-+ _, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
-+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, _, err = LookupSRV("target", "tcp", "golang.org")
-+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+
-+ _, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org")
-+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, _, err = LookupSRV("hdr", "tcp", "golang.org")
-+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+
-+ _, err = r.LookupMX(context.Background(), "golang.org")
-+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, err = LookupMX("golang.org")
-+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+
-+ _, err = r.LookupNS(context.Background(), "golang.org")
-+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, err = LookupNS("golang.org")
-+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+
-+ _, err = r.LookupAddr(context.Background(), "1.2.3.4")
-+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+ _, err = LookupAddr("1.2.3.4")
-+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
-+ }
-+}
-diff --git a/src/net/lookup.go b/src/net/lookup.go
-index 5f7119872a48d..0660268249bc7 100644
---- a/src/net/lookup.go
-+++ b/src/net/lookup.go
-@@ -389,8 +389,11 @@ func (r *Resolver) LookupPort(ctx context.Context, network, service string) (por
- // LookupCNAME does not return an error if host does not
- // contain DNS "CNAME" records, as long as host resolves to
- // address records.
-+//
-+// The returned canonical name is validated to be a properly
-+// formatted presentation-format domain name.
- func LookupCNAME(host string) (cname string, err error) {
-- return DefaultResolver.lookupCNAME(context.Background(), host)
-+ return DefaultResolver.LookupCNAME(context.Background(), host)
- }
-
- // LookupCNAME returns the canonical name for the given host.
-@@ -403,8 +406,18 @@ func LookupCNAME(host string) (cname string, err error) {
- // LookupCNAME does not return an error if host does not
- // contain DNS "CNAME" records, as long as host resolves to
- // address records.
--func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string, err error) {
-- return r.lookupCNAME(ctx, host)
-+//
-+// The returned canonical name is validated to be a properly
-+// formatted presentation-format domain name.
-+func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error) {
-+ cname, err := r.lookupCNAME(ctx, host)
-+ if err != nil {
-+ return "", err
-+ }
-+ if !isDomainName(cname) {
-+ return "", &DNSError{Err: "CNAME target is invalid", Name: host}
-+ }
-+ return cname, nil
- }
-
- // LookupSRV tries to resolve an SRV query of the given service,
-@@ -416,8 +429,11 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string,
- // That is, it looks up _service._proto.name. To accommodate services
- // publishing SRV records under non-standard names, if both service
- // and proto are empty strings, LookupSRV looks up name directly.
-+//
-+// The returned service names are validated to be properly
-+// formatted presentation-format domain names.
- func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) {
-- return DefaultResolver.lookupSRV(context.Background(), service, proto, name)
-+ return DefaultResolver.LookupSRV(context.Background(), service, proto, name)
- }
-
- // LookupSRV tries to resolve an SRV query of the given service,
-@@ -429,28 +445,82 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
- // That is, it looks up _service._proto.name. To accommodate services
- // publishing SRV records under non-standard names, if both service
- // and proto are empty strings, LookupSRV looks up name directly.
--func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error) {
-- return r.lookupSRV(ctx, service, proto, name)
-+//
-+// The returned service names are validated to be properly
-+// formatted presentation-format domain names.
-+func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) {
-+ cname, addrs, err := r.lookupSRV(ctx, service, proto, name)
-+ if err != nil {
-+ return "", nil, err
-+ }
-+ if cname != "" && !isDomainName(cname) {
-+ return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name}
-+ }
-+ for _, addr := range addrs {
-+ if addr == nil {
-+ continue
-+ }
-+ if !isDomainName(addr.Target) {
-+ return "", nil, &DNSError{Err: "SRV target is invalid", Name: name}
-+ }
-+ }
-+ return cname, addrs, nil
- }
-
- // LookupMX returns the DNS MX records for the given domain name sorted by preference.
-+//
-+// The returned mail server names are validated to be properly
-+// formatted presentation-format domain names.
- func LookupMX(name string) ([]*MX, error) {
-- return DefaultResolver.lookupMX(context.Background(), name)
-+ return DefaultResolver.LookupMX(context.Background(), name)
- }
-
- // LookupMX returns the DNS MX records for the given domain name sorted by preference.
-+//
-+// The returned mail server names are validated to be properly
-+// formatted presentation-format domain names.
- func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
-- return r.lookupMX(ctx, name)
-+ records, err := r.lookupMX(ctx, name)
-+ if err != nil {
-+ return nil, err
-+ }
-+ for _, mx := range records {
-+ if mx == nil {
-+ continue
-+ }
-+ if !isDomainName(mx.Host) {
-+ return nil, &DNSError{Err: "MX target is invalid", Name: name}
-+ }
-+ }
-+ return records, nil
- }
-
- // LookupNS returns the DNS NS records for the given domain name.
-+//
-+// The returned name server names are validated to be properly
-+// formatted presentation-format domain names.
- func LookupNS(name string) ([]*NS, error) {
-- return DefaultResolver.lookupNS(context.Background(), name)
-+ return DefaultResolver.LookupNS(context.Background(), name)
- }
-
- // LookupNS returns the DNS NS records for the given domain name.
-+//
-+// The returned name server names are validated to be properly
-+// formatted presentation-format domain names.
- func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) {
-- return r.lookupNS(ctx, name)
-+ records, err := r.lookupNS(ctx, name)
-+ if err != nil {
-+ return nil, err
-+ }
-+ for _, ns := range records {
-+ if ns == nil {
-+ continue
-+ }
-+ if !isDomainName(ns.Host) {
-+ return nil, &DNSError{Err: "NS target is invalid", Name: name}
-+ }
-+ }
-+ return records, nil
- }
-
- // LookupTXT returns the DNS TXT records for the given domain name.
-@@ -466,14 +536,29 @@ func (r *Resolver) LookupTXT(ctx context.Context, name string) ([]string, error)
- // LookupAddr performs a reverse lookup for the given address, returning a list
- // of names mapping to that address.
- //
-+// The returned names are validated to be properly formatted presentation-format
-+// domain names.
-+//
- // When using the host C library resolver, at most one result will be
- // returned. To bypass the host resolver, use a custom Resolver.
- func LookupAddr(addr string) (names []string, err error) {
-- return DefaultResolver.lookupAddr(context.Background(), addr)
-+ return DefaultResolver.LookupAddr(context.Background(), addr)
- }
-
- // LookupAddr performs a reverse lookup for the given address, returning a list
- // of names mapping to that address.
--func (r *Resolver) LookupAddr(ctx context.Context, addr string) (names []string, err error) {
-- return r.lookupAddr(ctx, addr)
-+//
-+// The returned names are validated to be properly formatted presentation-format
-+// domain names.
-+func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) {
-+ names, err := r.lookupAddr(ctx, addr)
-+ if err != nil {
-+ return nil, err
-+ }
-+ for _, name := range names {
-+ if !isDomainName(name) {
-+ return nil, &DNSError{Err: "PTR target is invalid", Name: addr}
-+ }
-+ }
-+ return names, nil
- }
diff -Nru golang-1.15-1.15.9/debian/patches/0010-CVE-2021-33195-2.patch golang-1.15-1.15.15/debian/patches/0010-CVE-2021-33195-2.patch
--- golang-1.15-1.15.9/debian/patches/0010-CVE-2021-33195-2.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0010-CVE-2021-33195-2.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,111 +0,0 @@
-From 6b411e90d4d017f28c1cc7d442b5ec8c1f9de549 Mon Sep 17 00:00:00 2001
-From: Roland Shoemaker <roland@golang.org>
-Date: Wed, 2 Jun 2021 09:20:22 -0700
-Subject: [PATCH] [release-branch.go1.15] net: don't rely on system hosts in
- TestCVE202133195
-
-Also don't unnecessarily deref the error return.
-
-Updates #46504
-Fixes #46531
-
-Change-Id: I22d14ac76776f8988fa0774bdcb5fcd801ce0185
-Reviewed-on: https://go-review.googlesource.com/c/go/+/324190
-Trust: David Chase <drchase@google.com>
-Trust: Damien Neil <dneil@google.com>
-Run-TryBot: David Chase <drchase@google.com>
-TryBot-Result: Go Bot <gobot@golang.org>
-Reviewed-by: Damien Neil <dneil@google.com>
-(cherry picked from commit dd7ba3ba2c860c40be6d70b63d4a678449cae80f)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/324333
-Reviewed-by: Ian Lance Taylor <iant@golang.org>
----
- src/net/dnsclient_unix_test.go | 39 +++++++++++++++++-----------------
- 1 file changed, 20 insertions(+), 19 deletions(-)
-
-diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go
-index 819f20b887ae6..f646629912a3d 100644
---- a/src/net/dnsclient_unix_test.go
-+++ b/src/net/dnsclient_unix_test.go
-@@ -1898,61 +1898,62 @@ func TestCVE202133195(t *testing.T) {
- // Change the default resolver to match our manipulated resolver
- originalDefault := DefaultResolver
- DefaultResolver = &r
-- defer func() {
-- DefaultResolver = originalDefault
-- }()
-+ defer func() { DefaultResolver = originalDefault }()
-+ // Redirect host file lookups.
-+ defer func(orig string) { testHookHostsPath = orig }(testHookHostsPath)
-+ testHookHostsPath = "testdata/hosts"
-
- _, err := r.LookupCNAME(context.Background(), "golang.org")
- if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err, expected)
- }
- _, err = LookupCNAME("golang.org")
- if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err, expected)
- }
-
- _, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
- if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
- }
- _, _, err = LookupSRV("target", "tcp", "golang.org")
- if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
- }
-
- _, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org")
- if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
- }
- _, _, err = LookupSRV("hdr", "tcp", "golang.org")
- if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
- }
-
- _, err = r.LookupMX(context.Background(), "golang.org")
- if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err, expected)
- }
- _, err = LookupMX("golang.org")
- if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("LookupMX returned unexpected error, got %q, want %q", err, expected)
- }
-
- _, err = r.LookupNS(context.Background(), "golang.org")
- if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err, expected)
- }
- _, err = LookupNS("golang.org")
- if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
-+ t.Errorf("LookupNS returned unexpected error, got %q, want %q", err, expected)
- }
-
-- _, err = r.LookupAddr(context.Background(), "1.2.3.4")
-- if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
-+ _, err = r.LookupAddr(context.Background(), "192.0.2.42")
-+ if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err, expected)
- }
-- _, err = LookupAddr("1.2.3.4")
-- if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
-- t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
-+ _, err = LookupAddr("192.0.2.42")
-+ if expected := "lookup 192.0.2.42: PTR target is invalid"; err == nil || err.Error() != expected {
-+ t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err, expected)
- }
- }
diff -Nru golang-1.15-1.15.9/debian/patches/0011-CVE-2021-33197.patch golang-1.15-1.15.15/debian/patches/0011-CVE-2021-33197.patch
--- golang-1.15-1.15.9/debian/patches/0011-CVE-2021-33197.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0011-CVE-2021-33197.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,147 +0,0 @@
-From cbd1ca84453fecf3825a6bb9f985823e8bc32b76 Mon Sep 17 00:00:00 2001
-From: Filippo Valsorda <filippo@golang.org>
-Date: Fri, 21 May 2021 14:02:30 -0400
-Subject: [PATCH] [release-branch.go1.15] net/http/httputil: always remove
- hop-by-hop headers
-
-Previously, we'd fail to remove the Connection header from a request
-like this:
-
- Connection:
- Connection: x-header
-
-Updates #46313
-Fixes #46314
-Fixes CVE-2021-33197
-
-Change-Id: Ie3009e926ceecfa86dfa6bcc6fe14ff01086be7d
-Reviewed-on: https://go-review.googlesource.com/c/go/+/321929
-Run-TryBot: Filippo Valsorda <filippo@golang.org>
-Reviewed-by: Katie Hockman <katie@golang.org>
-Trust: Katie Hockman <katie@golang.org>
-Trust: Filippo Valsorda <filippo@golang.org>
-TryBot-Result: Go Bot <gobot@golang.org>
-Reviewed-on: https://go-review.googlesource.com/c/go/+/323091
-Run-TryBot: Katie Hockman <katie@golang.org>
----
- src/net/http/httputil/reverseproxy.go | 22 ++++----
- src/net/http/httputil/reverseproxy_test.go | 63 +++++++++++++++++++++-
- 2 files changed, 70 insertions(+), 15 deletions(-)
-
-diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
-index 3f48fab544e91..f49cefbb4f171 100644
---- a/src/net/http/httputil/reverseproxy.go
-+++ b/src/net/http/httputil/reverseproxy.go
-@@ -248,22 +248,18 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
- // important is "Connection" because we want a persistent
- // connection, regardless of what the client sent to us.
- for _, h := range hopHeaders {
-- hv := outreq.Header.Get(h)
-- if hv == "" {
-- continue
-- }
-- if h == "Te" && hv == "trailers" {
-- // Issue 21096: tell backend applications that
-- // care about trailer support that we support
-- // trailers. (We do, but we don't go out of
-- // our way to advertise that unless the
-- // incoming client request thought it was
-- // worth mentioning)
-- continue
-- }
- outreq.Header.Del(h)
- }
-
-+ // Issue 21096: tell backend applications that care about trailer support
-+ // that we support trailers. (We do, but we don't go out of our way to
-+ // advertise that unless the incoming client request thought it was worth
-+ // mentioning.) Note that we look at req.Header, not outreq.Header, since
-+ // the latter has passed through removeConnectionHeaders.
-+ if httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") {
-+ outreq.Header.Set("Te", "trailers")
-+ }
-+
- // After stripping all the hop-by-hop connection headers above, add back any
- // necessary for protocol upgrades, such as for websockets.
- if reqUpType != "" {
-diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
-index 764939fb0f0c2..1f2dfb9867f68 100644
---- a/src/net/http/httputil/reverseproxy_test.go
-+++ b/src/net/http/httputil/reverseproxy_test.go
-@@ -91,8 +91,9 @@ func TestReverseProxy(t *testing.T) {
-
- getReq, _ := http.NewRequest("GET", frontend.URL, nil)
- getReq.Host = "some-name"
-- getReq.Header.Set("Connection", "close")
-- getReq.Header.Set("Te", "trailers")
-+ getReq.Header.Set("Connection", "close, TE")
-+ getReq.Header.Add("Te", "foo")
-+ getReq.Header.Add("Te", "bar, trailers")
- getReq.Header.Set("Proxy-Connection", "should be deleted")
- getReq.Header.Set("Upgrade", "foo")
- getReq.Close = true
-@@ -236,6 +237,64 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) {
- }
- }
-
-+func TestReverseProxyStripEmptyConnection(t *testing.T) {
-+ // See Issue 46313.
-+ const backendResponse = "I am the backend"
-+
-+ // someConnHeader is some arbitrary header to be declared as a hop-by-hop header
-+ // in the Request's Connection header.
-+ const someConnHeader = "X-Some-Conn-Header"
-+
-+ backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-+ if c := r.Header.Values("Connection"); len(c) != 0 {
-+ t.Errorf("handler got header %q = %v; want empty", "Connection", c)
-+ }
-+ if c := r.Header.Get(someConnHeader); c != "" {
-+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
-+ }
-+ w.Header().Add("Connection", "")
-+ w.Header().Add("Connection", someConnHeader)
-+ w.Header().Set(someConnHeader, "should be deleted")
-+ io.WriteString(w, backendResponse)
-+ }))
-+ defer backend.Close()
-+ backendURL, err := url.Parse(backend.URL)
-+ if err != nil {
-+ t.Fatal(err)
-+ }
-+ proxyHandler := NewSingleHostReverseProxy(backendURL)
-+ frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-+ proxyHandler.ServeHTTP(w, r)
-+ if c := r.Header.Get(someConnHeader); c != "should be deleted" {
-+ t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted")
-+ }
-+ }))
-+ defer frontend.Close()
-+
-+ getReq, _ := http.NewRequest("GET", frontend.URL, nil)
-+ getReq.Header.Add("Connection", "")
-+ getReq.Header.Add("Connection", someConnHeader)
-+ getReq.Header.Set(someConnHeader, "should be deleted")
-+ res, err := frontend.Client().Do(getReq)
-+ if err != nil {
-+ t.Fatalf("Get: %v", err)
-+ }
-+ defer res.Body.Close()
-+ bodyBytes, err := ioutil.ReadAll(res.Body)
-+ if err != nil {
-+ t.Fatalf("reading body: %v", err)
-+ }
-+ if got, want := string(bodyBytes), backendResponse; got != want {
-+ t.Errorf("got body %q; want %q", got, want)
-+ }
-+ if c := res.Header.Get("Connection"); c != "" {
-+ t.Errorf("handler got header %q = %q; want empty", "Connection", c)
-+ }
-+ if c := res.Header.Get(someConnHeader); c != "" {
-+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
-+ }
-+}
-+
- func TestXForwardedFor(t *testing.T) {
- const prevForwardedFor = "client ip"
- const backendResponse = "I am the backend"
diff -Nru golang-1.15-1.15.9/debian/patches/0012-CVE-2021-33198.patch golang-1.15-1.15.15/debian/patches/0012-CVE-2021-33198.patch
--- golang-1.15-1.15.9/debian/patches/0012-CVE-2021-33198.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0012-CVE-2021-33198.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,107 +0,0 @@
-From df9ce19db6df32d94eae8760927bdfbc595433c3 Mon Sep 17 00:00:00 2001
-From: Robert Griesemer <gri@golang.org>
-Date: Sun, 2 May 2021 11:27:03 -0700
-Subject: [PATCH] [release-branch.go1.15] math/big: check for excessive
- exponents in Rat.SetString
-
-Found by OSS-Fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33284
-
-Thanks to Emmanuel Odeke for reporting this issue.
-
-Updates #45910
-Fixes #46305
-Fixes CVE-2021-33198
-
-Change-Id: I61e7b04dbd80343420b57eede439e361c0f7b79c
-Reviewed-on: https://go-review.googlesource.com/c/go/+/316149
-Trust: Robert Griesemer <gri@golang.org>
-Trust: Katie Hockman <katie@golang.org>
-Run-TryBot: Robert Griesemer <gri@golang.org>
-TryBot-Result: Go Bot <gobot@golang.org>
-Reviewed-by: Katie Hockman <katie@golang.org>
-Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
-(cherry picked from commit 6c591f79b0b5327549bd4e94970f7a279efb4ab0)
-Reviewed-on: https://go-review.googlesource.com/c/go/+/321831
-Run-TryBot: Katie Hockman <katie@golang.org>
-Reviewed-by: Roland Shoemaker <roland@golang.org>
----
- src/math/big/ratconv.go | 15 ++++++++-------
- src/math/big/ratconv_test.go | 25 +++++++++++++++++++++++++
- 2 files changed, 33 insertions(+), 7 deletions(-)
-
-diff --git a/src/math/big/ratconv.go b/src/math/big/ratconv.go
-index 941139e72d1c4..ac3c8bd11f8a8 100644
---- a/src/math/big/ratconv.go
-+++ b/src/math/big/ratconv.go
-@@ -51,7 +51,8 @@ func (z *Rat) Scan(s fmt.ScanState, ch rune) error {
- // An optional base-10 ``e'' or base-2 ``p'' (or their upper-case variants)
- // exponent may be provided as well, except for hexadecimal floats which
- // only accept an (optional) ``p'' exponent (because an ``e'' or ``E'' cannot
--// be distinguished from a mantissa digit).
-+// be distinguished from a mantissa digit). If the exponent's absolute value
-+// is too large, the operation may fail.
- // The entire string, not just a prefix, must be valid for success. If the
- // operation failed, the value of z is undefined but the returned value is nil.
- func (z *Rat) SetString(s string) (*Rat, bool) {
-@@ -169,6 +170,9 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
- if n < 0 {
- n = -n
- }
-+ if n > 1e6 {
-+ return nil, false // avoid excessively large exponents
-+ }
- pow5 := z.b.abs.expNN(natFive, nat(nil).setWord(Word(n)), nil) // use underlying array of z.b.abs
- if exp5 > 0 {
- z.a.abs = z.a.abs.mul(z.a.abs, pow5)
-@@ -181,15 +185,12 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
- }
-
- // apply exp2 contributions
-+ if exp2 < -1e7 || exp2 > 1e7 {
-+ return nil, false // avoid excessively large exponents
-+ }
- if exp2 > 0 {
-- if int64(uint(exp2)) != exp2 {
-- panic("exponent too large")
-- }
- z.a.abs = z.a.abs.shl(z.a.abs, uint(exp2))
- } else if exp2 < 0 {
-- if int64(uint(-exp2)) != -exp2 {
-- panic("exponent too large")
-- }
- z.b.abs = z.b.abs.shl(z.b.abs, uint(-exp2))
- }
-
-diff --git a/src/math/big/ratconv_test.go b/src/math/big/ratconv_test.go
-index ba0d1ba9e1158..15d206cb386ab 100644
---- a/src/math/big/ratconv_test.go
-+++ b/src/math/big/ratconv_test.go
-@@ -589,3 +589,28 @@ func TestIssue31184(t *testing.T) {
- }
- }
- }
-+
-+func TestIssue45910(t *testing.T) {
-+ var x Rat
-+ for _, test := range []struct {
-+ input string
-+ want bool
-+ }{
-+ {"1e-1000001", false},
-+ {"1e-1000000", true},
-+ {"1e+1000000", true},
-+ {"1e+1000001", false},
-+
-+ {"0p1000000000000", true},
-+ {"1p-10000001", false},
-+ {"1p-10000000", true},
-+ {"1p+10000000", true},
-+ {"1p+10000001", false},
-+ {"1.770p02041010010011001001", false}, // test case from issue
-+ } {
-+ _, got := x.SetString(test.input)
-+ if got != test.want {
-+ t.Errorf("SetString(%s) got ok = %v; want %v", test.input, got, test.want)
-+ }
-+ }
-+}
diff -Nru golang-1.15-1.15.9/debian/patches/0013-CVE-2021-34558.patch golang-1.15-1.15.15/debian/patches/0013-CVE-2021-34558.patch
--- golang-1.15-1.15.9/debian/patches/0013-CVE-2021-34558.patch 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/0013-CVE-2021-34558.patch 1970-01-01 08:00:00.000000000 +0800
@@ -1,46 +0,0 @@
-From c77980bc077f3774276ab2deba78d8e6bfe4b3bd Mon Sep 17 00:00:00 2001
-From: Roland Shoemaker <roland@golang.org>
-Date: Wed, 9 Jun 2021 11:31:27 -0700
-Subject: [PATCH] [release-branch.go1.15] crypto/tls: test key type when
- casting
-
-When casting the certificate public key in generateClientKeyExchange,
-check the type is appropriate. This prevents a panic when a server
-agrees to a RSA based key exchange, but then sends an ECDSA (or
-other) certificate.
-
-Updates #47143
-Fixes #47144
-Fixes CVE-2021-34558
-
-Thanks to Imre Rad for reporting this issue.
-
-Change-Id: Iabccacca6052769a605cccefa1216a9f7b7f6aea
-Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1116723
-Reviewed-by: Filippo Valsorda <valsorda@google.com>
-Reviewed-by: Katie Hockman <katiehockman@google.com>
-Reviewed-on: https://go-review.googlesource.com/c/go/+/334030
-Trust: Filippo Valsorda <filippo@golang.org>
-Run-TryBot: Filippo Valsorda <filippo@golang.org>
-Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
----
- src/crypto/tls/key_agreement.go | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/src/crypto/tls/key_agreement.go b/src/crypto/tls/key_agreement.go
-index 7e6534bd465e3..22f1b2e1f2441 100644
---- a/src/crypto/tls/key_agreement.go
-+++ b/src/crypto/tls/key_agreement.go
-@@ -67,7 +67,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
- return nil, nil, err
- }
-
-- encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
-+ rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
-+ if !ok {
-+ return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
-+ }
-+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
- if err != nil {
- return nil, nil, err
- }
diff -Nru golang-1.15-1.15.9/debian/patches/series golang-1.15-1.15.15/debian/patches/series
--- golang-1.15-1.15.9/debian/patches/series 2021-07-13 13:55:42.000000000 +0800
+++ golang-1.15-1.15.15/debian/patches/series 2021-09-11 15:54:07.000000000 +0800
@@ -4,10 +4,4 @@
0004-cmd-dist-fix-build-failure-of-misc-cgo-test-on-arm64.patch
0005-cmd-dist-increase-default-timeout-scale-for-arm.patch
0006-skip-userns-test-in-schroot-as-well.patch
-0007-CVE-2021-31525.patch
-0008-CVE-2021-33196.patch
-0009-CVE-2021-33195-1.patch
-0010-CVE-2021-33195-2.patch
-0011-CVE-2021-33197.patch
-0012-CVE-2021-33198.patch
-0013-CVE-2021-34558.patch
+0007-CVE-2021-39293.patch
diff -Nru golang-1.15-1.15.9/misc/cgo/testcshared/cshared_test.go golang-1.15-1.15.15/misc/cgo/testcshared/cshared_test.go
--- golang-1.15-1.15.9/misc/cgo/testcshared/cshared_test.go 2021-03-10 22:29:31.000000000 +0800
+++ golang-1.15-1.15.15/misc/cgo/testcshared/cshared_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -7,6 +7,8 @@
import (
"bytes"
"debug/elf"
+ "debug/pe"
+ "encoding/binary"
"flag"
"fmt"
"io/ioutil"
@@ -355,6 +357,101 @@
}
}
+func checkNumberOfExportedFunctionsWindows(t *testing.T, exportAllSymbols bool) {
+ const prog = `
+package main
+
+import "C"
+
+//export GoFunc
+func GoFunc() {
+ println(42)
+}
+
+//export GoFunc2
+func GoFunc2() {
+ println(24)
+}
+
+func main() {
+}
+`
+
+ tmpdir := t.TempDir()
+
+ srcfile := filepath.Join(tmpdir, "test.go")
+ objfile := filepath.Join(tmpdir, "test.dll")
+ if err := ioutil.WriteFile(srcfile, []byte(prog), 0666); err != nil {
+ t.Fatal(err)
+ }
+ argv := []string{"build", "-buildmode=c-shared"}
+ if exportAllSymbols {
+ argv = append(argv, "-ldflags", "-extldflags=-Wl,--export-all-symbols")
+ }
+ argv = append(argv, "-o", objfile, srcfile)
+ out, err := exec.Command("go", argv...).CombinedOutput()
+ if err != nil {
+ t.Fatalf("build failure: %s\n%s\n", err, string(out))
+ }
+
+ f, err := pe.Open(objfile)
+ if err != nil {
+ t.Fatalf("pe.Open failed: %v", err)
+ }
+ defer f.Close()
+ section := f.Section(".edata")
+ if section == nil {
+ t.Fatalf(".edata section is not present")
+ }
+
+ // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go
+ type IMAGE_EXPORT_DIRECTORY struct {
+ _ [2]uint32
+ _ [2]uint16
+ _ [2]uint32
+ NumberOfFunctions uint32
+ NumberOfNames uint32
+ _ [3]uint32
+ }
+ var e IMAGE_EXPORT_DIRECTORY
+ if err := binary.Read(section.Open(), binary.LittleEndian, &e); err != nil {
+ t.Fatalf("binary.Read failed: %v", err)
+ }
+
+ // Only the two exported functions and _cgo_dummy_export should be exported
+ expectedNumber := uint32(3)
+
+ if exportAllSymbols {
+ if e.NumberOfFunctions <= expectedNumber {
+ t.Fatalf("missing exported functions: %v", e.NumberOfFunctions)
+ }
+ if e.NumberOfNames <= expectedNumber {
+ t.Fatalf("missing exported names: %v", e.NumberOfNames)
+ }
+ } else {
+ if e.NumberOfFunctions != expectedNumber {
+ t.Fatalf("got %d exported functions; want %d", e.NumberOfFunctions, expectedNumber)
+ }
+ if e.NumberOfNames != expectedNumber {
+ t.Fatalf("got %d exported names; want %d", e.NumberOfNames, expectedNumber)
+ }
+ }
+}
+
+func TestNumberOfExportedFunctions(t *testing.T) {
+ if GOOS != "windows" {
+ t.Skip("skipping windows only test")
+ }
+ t.Parallel()
+
+ t.Run("OnlyExported", func(t *testing.T) {
+ checkNumberOfExportedFunctionsWindows(t, false)
+ })
+ t.Run("All", func(t *testing.T) {
+ checkNumberOfExportedFunctionsWindows(t, true)
+ })
+}
+
// test1: shared library can be dynamically loaded and exported symbols are accessible.
func TestExportedSymbolsWithDynamicLoad(t *testing.T) {
t.Parallel()
diff -Nru golang-1.15-1.15.9/src/archive/zip/reader.go golang-1.15-1.15.15/src/archive/zip/reader.go
--- golang-1.15-1.15.9/src/archive/zip/reader.go 2021-03-10 22:29:31.000000000 +0800
+++ golang-1.15-1.15.15/src/archive/zip/reader.go 2021-08-05 05:20:40.000000000 +0800
@@ -84,7 +84,15 @@
return err
}
z.r = r
- z.File = make([]*File, 0, end.directoryRecords)
+ // Since the number of directory records is not validated, it is not
+ // safe to preallocate z.File without first checking that the specified
+ // number of files is reasonable, since a malformed archive may
+ // indicate it contains up to 1 << 128 - 1 files. Since each file has a
+ // header which will be _at least_ 30 bytes we can safely preallocate
+ // if (data size / 30) >= end.directoryRecords.
+ if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
+ z.File = make([]*File, 0, end.directoryRecords)
+ }
z.Comment = end.comment
rs := io.NewSectionReader(r, 0, size)
if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil {
diff -Nru golang-1.15-1.15.9/src/archive/zip/reader_test.go golang-1.15-1.15.15/src/archive/zip/reader_test.go
--- golang-1.15-1.15.9/src/archive/zip/reader_test.go 2021-03-10 22:29:31.000000000 +0800
+++ golang-1.15-1.15.15/src/archive/zip/reader_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -1070,3 +1070,62 @@
t.Errorf("Error reading the archive: %v", err)
}
}
+
+func TestCVE202133196(t *testing.T) {
+ // Archive that indicates it has 1 << 128 -1 files,
+ // this would previously cause a panic due to attempting
+ // to allocate a slice with 1 << 128 -1 elements.
+ data := []byte{
+ 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x08, 0x08,
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02,
+ 0x03, 0x62, 0x61, 0x65, 0x03, 0x04, 0x00, 0x00,
+ 0xff, 0xff, 0x50, 0x4b, 0x07, 0x08, 0xbe, 0x20,
+ 0x5c, 0x6c, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00,
+ 0x14, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xbe, 0x20, 0x5c, 0x6c, 0x09, 0x00,
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x02, 0x03, 0x50, 0x4b, 0x06, 0x06, 0x2c,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d,
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x06, 0x07, 0x00,
+ 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50,
+ 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0x00,
+ }
+ _, err := NewReader(bytes.NewReader(data), int64(len(data)))
+ if err != ErrFormat {
+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
+ }
+
+ // Also check that an archive containing a handful of empty
+ // files doesn't cause an issue
+ b := bytes.NewBuffer(nil)
+ w := NewWriter(b)
+ for i := 0; i < 5; i++ {
+ _, err := w.Create("")
+ if err != nil {
+ t.Fatalf("Writer.Create failed: %s", err)
+ }
+ }
+ if err := w.Close(); err != nil {
+ t.Fatalf("Writer.Close failed: %s", err)
+ }
+ r, err := NewReader(bytes.NewReader(b.Bytes()), int64(b.Len()))
+ if err != nil {
+ t.Fatalf("NewReader failed: %s", err)
+ }
+ if len(r.File) != 5 {
+ t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
+ }
+}
diff -Nru golang-1.15-1.15.9/src/cmd/cgo/out.go golang-1.15-1.15.15/src/cmd/cgo/out.go
--- golang-1.15-1.15.9/src/cmd/cgo/out.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/cgo/out.go 2021-08-05 05:20:40.000000000 +0800
@@ -961,7 +961,11 @@
}
// Build the wrapper function compiled by gcc.
- s := fmt.Sprintf("%s %s(", gccResult, exp.ExpName)
+ gccExport := ""
+ if goos == "windows" {
+ gccExport = "__declspec(dllexport) "
+ }
+ s := fmt.Sprintf("%s%s %s(", gccExport, gccResult, exp.ExpName)
if fn.Recv != nil {
s += p.cgoType(fn.Recv.List[0].Type).C.String()
s += " recv"
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/gc/escape.go golang-1.15-1.15.15/src/cmd/compile/internal/gc/escape.go
--- golang-1.15-1.15.9/src/cmd/compile/internal/gc/escape.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/gc/escape.go 2021-08-05 05:20:40.000000000 +0800
@@ -1379,9 +1379,10 @@
// leak records that parameter l leaks to sink.
func (l *EscLocation) leakTo(sink *EscLocation, derefs int) {
- // If sink is a result parameter and we can fit return bits
- // into the escape analysis tag, then record a return leak.
- if sink.isName(PPARAMOUT) && sink.curfn == l.curfn {
+ // If sink is a result parameter that doesn't escape (#44614)
+ // and we can fit return bits into the escape analysis tag,
+ // then record as a result leak.
+ if !sink.escapes && sink.isName(PPARAMOUT) && sink.curfn == l.curfn {
// TODO(mdempsky): Eliminate dependency on Vargen here.
ri := int(sink.n.Name.Vargen) - 1
if ri < numEscResults {
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/ssa/gen/ARM64Ops.go golang-1.15-1.15.15/src/cmd/compile/internal/ssa/gen/ARM64Ops.go
--- golang-1.15-1.15.9/src/cmd/compile/internal/ssa/gen/ARM64Ops.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/ssa/gen/ARM64Ops.go 2021-08-05 05:20:40.000000000 +0800
@@ -498,13 +498,14 @@
// auxint = offset into duffzero code to start executing
// returns mem
// R20 changed as side effect
+ // R16 and R17 may be clobbered by linker trampoline.
{
name: "DUFFZERO",
aux: "Int64",
argLength: 2,
reg: regInfo{
inputs: []regMask{buildReg("R20")},
- clobbers: buildReg("R20 R30"),
+ clobbers: buildReg("R16 R17 R20 R30"),
},
faultOnNilArg0: true,
},
@@ -537,13 +538,14 @@
// auxint = offset into duffcopy code to start executing
// returns mem
// R20, R21 changed as side effect
+ // R16 and R17 may be clobbered by linker trampoline.
{
name: "DUFFCOPY",
aux: "Int64",
argLength: 3,
reg: regInfo{
inputs: []regMask{buildReg("R21"), buildReg("R20")},
- clobbers: buildReg("R20 R21 R26 R30"),
+ clobbers: buildReg("R16 R17 R20 R21 R26 R30"),
},
faultOnNilArg0: true,
faultOnNilArg1: true,
@@ -664,7 +666,8 @@
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
// It saves all GP registers if necessary,
// but clobbers R30 (LR) because it's a call.
- {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R30")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
+ // R16 and R17 may be clobbered by linker trampoline.
+ {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R16 R17 R30")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
// There are three of these functions so that they can have three different register inputs.
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/ssa/gen/ARM.rules golang-1.15-1.15.15/src/cmd/compile/internal/ssa/gen/ARM.rules
--- golang-1.15-1.15.9/src/cmd/compile/internal/ssa/gen/ARM.rules 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/ssa/gen/ARM.rules 2021-08-05 05:20:40.000000000 +0800
@@ -1369,38 +1369,38 @@
(LE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftLLreg x y z) yes no)
(LE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRLreg x y z) yes no)
(LE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (CMNshiftRAreg x y z) yes no)
-(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LT (TST x y) yes no)
-(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LT (TSTconst [c] x) yes no)
-(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftLL x y [c]) yes no)
-(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRL x y [c]) yes no)
-(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TSTshiftRA x y [c]) yes no)
-(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftLLreg x y z) yes no)
-(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRLreg x y z) yes no)
-(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TSTshiftRAreg x y z) yes no)
-(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LE (TST x y) yes no)
-(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LE (TSTconst [c] x) yes no)
-(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftLL x y [c]) yes no)
-(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRL x y [c]) yes no)
-(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TSTshiftRA x y [c]) yes no)
-(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftLLreg x y z) yes no)
-(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRLreg x y z) yes no)
-(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TSTshiftRAreg x y z) yes no)
-(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LT (TEQ x y) yes no)
-(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LT (TEQconst [c] x) yes no)
-(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftLL x y [c]) yes no)
-(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRL x y [c]) yes no)
-(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LT (TEQshiftRA x y [c]) yes no)
-(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftLLreg x y z) yes no)
-(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRLreg x y z) yes no)
-(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LT (TEQshiftRAreg x y z) yes no)
-(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LE (TEQ x y) yes no)
-(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LE (TEQconst [c] x) yes no)
-(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftLL x y [c]) yes no)
-(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRL x y [c]) yes no)
-(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LE (TEQshiftRA x y [c]) yes no)
-(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftLLreg x y z) yes no)
-(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRLreg x y z) yes no)
-(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LE (TEQshiftRAreg x y z) yes no)
+(LT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LTnoov (TST x y) yes no)
+(LT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TSTconst [c] x) yes no)
+(LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLL x y [c]) yes no)
+(LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRL x y [c]) yes no)
+(LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRA x y [c]) yes no)
+(LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftLLreg x y z) yes no)
+(LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRLreg x y z) yes no)
+(LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TSTshiftRAreg x y z) yes no)
+(LE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (LEnoov (TST x y) yes no)
+(LE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TSTconst [c] x) yes no)
+(LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLL x y [c]) yes no)
+(LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRL x y [c]) yes no)
+(LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRA x y [c]) yes no)
+(LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftLLreg x y z) yes no)
+(LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRLreg x y z) yes no)
+(LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TSTshiftRAreg x y z) yes no)
+(LT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LTnoov (TEQ x y) yes no)
+(LT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LTnoov (TEQconst [c] x) yes no)
+(LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLL x y [c]) yes no)
+(LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRL x y [c]) yes no)
+(LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRA x y [c]) yes no)
+(LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftLLreg x y z) yes no)
+(LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRLreg x y z) yes no)
+(LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LTnoov (TEQshiftRAreg x y z) yes no)
+(LE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (LEnoov (TEQ x y) yes no)
+(LE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (LEnoov (TEQconst [c] x) yes no)
+(LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLL x y [c]) yes no)
+(LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRL x y [c]) yes no)
+(LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRA x y [c]) yes no)
+(LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftLLreg x y z) yes no)
+(LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRLreg x y z) yes no)
+(LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (LEnoov (TEQshiftRAreg x y z) yes no)
(GT (CMPconst [0] l:(SUB x y)) yes no) && l.Uses==1 -> (GTnoov (CMP x y) yes no)
(GT (CMPconst [0] l:(MULS x y a)) yes no) && l.Uses==1 -> (GTnoov (CMP a (MUL <x.Type> x y)) yes no)
(GT (CMPconst [0] l:(SUBconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (CMPconst [c] x) yes no)
@@ -1436,39 +1436,39 @@
(GE (CMPconst [0] l:(ADDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftLLreg x y z) yes no)
(GE (CMPconst [0] l:(ADDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRLreg x y z) yes no)
(GE (CMPconst [0] l:(ADDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (CMNshiftRAreg x y z) yes no)
-(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GT (TST x y) yes no)
(GT (CMPconst [0] l:(MULA x y a)) yes no) && l.Uses==1 -> (GTnoov (CMN a (MUL <x.Type> x y)) yes no)
-(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GT (TSTconst [c] x) yes no)
-(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftLL x y [c]) yes no)
-(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRL x y [c]) yes no)
-(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TSTshiftRA x y [c]) yes no)
-(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftLLreg x y z) yes no)
-(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRLreg x y z) yes no)
-(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TSTshiftRAreg x y z) yes no)
-(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GE (TST x y) yes no)
-(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GE (TSTconst [c] x) yes no)
-(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftLL x y [c]) yes no)
-(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRL x y [c]) yes no)
-(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TSTshiftRA x y [c]) yes no)
-(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftLLreg x y z) yes no)
-(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRLreg x y z) yes no)
-(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TSTshiftRAreg x y z) yes no)
-(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GT (TEQ x y) yes no)
-(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GT (TEQconst [c] x) yes no)
-(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftLL x y [c]) yes no)
-(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRL x y [c]) yes no)
-(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GT (TEQshiftRA x y [c]) yes no)
-(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftLLreg x y z) yes no)
-(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRLreg x y z) yes no)
-(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GT (TEQshiftRAreg x y z) yes no)
-(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GE (TEQ x y) yes no)
-(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GE (TEQconst [c] x) yes no)
-(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftLL x y [c]) yes no)
-(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRL x y [c]) yes no)
-(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GE (TEQshiftRA x y [c]) yes no)
-(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftLLreg x y z) yes no)
-(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRLreg x y z) yes no)
-(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GE (TEQshiftRAreg x y z) yes no)
+(GT (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GTnoov (TST x y) yes no)
+(GT (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TSTconst [c] x) yes no)
+(GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLL x y [c]) yes no)
+(GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRL x y [c]) yes no)
+(GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRA x y [c]) yes no)
+(GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftLLreg x y z) yes no)
+(GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRLreg x y z) yes no)
+(GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TSTshiftRAreg x y z) yes no)
+(GE (CMPconst [0] l:(AND x y)) yes no) && l.Uses==1 -> (GEnoov (TST x y) yes no)
+(GE (CMPconst [0] l:(ANDconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TSTconst [c] x) yes no)
+(GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLL x y [c]) yes no)
+(GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRL x y [c]) yes no)
+(GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRA x y [c]) yes no)
+(GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftLLreg x y z) yes no)
+(GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRLreg x y z) yes no)
+(GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TSTshiftRAreg x y z) yes no)
+(GT (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GTnoov (TEQ x y) yes no)
+(GT (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GTnoov (TEQconst [c] x) yes no)
+(GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLL x y [c]) yes no)
+(GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRL x y [c]) yes no)
+(GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRA x y [c]) yes no)
+(GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftLLreg x y z) yes no)
+(GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRLreg x y z) yes no)
+(GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GTnoov (TEQshiftRAreg x y z) yes no)
+(GE (CMPconst [0] l:(XOR x y)) yes no) && l.Uses==1 -> (GEnoov (TEQ x y) yes no)
+(GE (CMPconst [0] l:(XORconst [c] x)) yes no) && l.Uses==1 -> (GEnoov (TEQconst [c] x) yes no)
+(GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLL x y [c]) yes no)
+(GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRL x y [c]) yes no)
+(GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRA x y [c]) yes no)
+(GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftLLreg x y z) yes no)
+(GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRLreg x y z) yes no)
+(GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no) && l.Uses==1 -> (GEnoov (TEQshiftRAreg x y z) yes no)
(MOVBUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read8(sym, off))])
(MOVHUload [off] {sym} (SB) _) && symIsRO(sym) -> (MOVWconst [int64(read16(sym, off, config.ctxt.Arch.ByteOrder))])
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/ssa/opGen.go golang-1.15-1.15.15/src/cmd/compile/internal/ssa/opGen.go
--- golang-1.15-1.15.9/src/cmd/compile/internal/ssa/opGen.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/ssa/opGen.go 2021-08-05 05:20:40.000000000 +0800
@@ -20738,7 +20738,7 @@
inputs: []inputInfo{
{0, 1048576}, // R20
},
- clobbers: 537919488, // R20 R30
+ clobbers: 538116096, // R16 R17 R20 R30
},
},
{
@@ -20765,7 +20765,7 @@
{0, 2097152}, // R21
{1, 1048576}, // R20
},
- clobbers: 607125504, // R20 R21 R26 R30
+ clobbers: 607322112, // R16 R17 R20 R21 R26 R30
},
},
{
@@ -21090,7 +21090,7 @@
{0, 4}, // R2
{1, 8}, // R3
},
- clobbers: 9223372035244163072, // R30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
+ clobbers: 9223372035244359680, // R16 R17 R30 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
},
},
{
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/ssa/rewriteARM.go golang-1.15-1.15.15/src/cmd/compile/internal/ssa/rewriteARM.go
--- golang-1.15-1.15.9/src/cmd/compile/internal/ssa/rewriteARM.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/ssa/rewriteARM.go 2021-08-05 05:20:40.000000000 +0800
@@ -17278,7 +17278,7 @@
}
// match: (GE (CMPconst [0] l:(AND x y)) yes no)
// cond: l.Uses==1
- // result: (GE (TST x y) yes no)
+ // result: (GEnoov (TST x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17299,14 +17299,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
break
}
// match: (GE (CMPconst [0] l:(ANDconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (GE (TSTconst [c] x) yes no)
+ // result: (GEnoov (TSTconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17324,12 +17324,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftLL x y [c]) yes no)
+ // result: (GEnoov (TSTshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17348,12 +17348,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftRL x y [c]) yes no)
+ // result: (GEnoov (TSTshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17372,12 +17372,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftRA x y [c]) yes no)
+ // result: (GEnoov (TSTshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17396,12 +17396,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftLLreg x y z) yes no)
+ // result: (GEnoov (TSTshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17419,12 +17419,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftRLreg x y z) yes no)
+ // result: (GEnoov (TSTshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17442,12 +17442,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TSTshiftRAreg x y z) yes no)
+ // result: (GEnoov (TSTshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17465,12 +17465,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XOR x y)) yes no)
// cond: l.Uses==1
- // result: (GE (TEQ x y) yes no)
+ // result: (GEnoov (TEQ x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17491,14 +17491,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
break
}
// match: (GE (CMPconst [0] l:(XORconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (GE (TEQconst [c] x) yes no)
+ // result: (GEnoov (TEQconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17516,12 +17516,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftLL x y [c]) yes no)
+ // result: (GEnoov (TEQshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17540,12 +17540,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftRL x y [c]) yes no)
+ // result: (GEnoov (TEQshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17564,12 +17564,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftRA x y [c]) yes no)
+ // result: (GEnoov (TEQshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17588,12 +17588,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftLLreg x y z) yes no)
+ // result: (GEnoov (TEQshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17611,12 +17611,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftRLreg x y z) yes no)
+ // result: (GEnoov (TEQshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17634,12 +17634,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
// match: (GE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GE (TEQshiftRAreg x y z) yes no)
+ // result: (GEnoov (TEQshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -17657,7 +17657,7 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGE, v0)
+ b.resetWithControl(BlockARMGEnoov, v0)
return true
}
case BlockARMGEnoov:
@@ -18131,9 +18131,34 @@
b.resetWithControl(BlockARMGTnoov, v0)
return true
}
+ // match: (GT (CMPconst [0] l:(MULA x y a)) yes no)
+ // cond: l.Uses==1
+ // result: (GTnoov (CMN a (MUL <x.Type> x y)) yes no)
+ for b.Controls[0].Op == OpARMCMPconst {
+ v_0 := b.Controls[0]
+ if v_0.AuxInt != 0 {
+ break
+ }
+ l := v_0.Args[0]
+ if l.Op != OpARMMULA {
+ break
+ }
+ a := l.Args[2]
+ x := l.Args[0]
+ y := l.Args[1]
+ if !(l.Uses == 1) {
+ break
+ }
+ v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags)
+ v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type)
+ v1.AddArg2(x, y)
+ v0.AddArg2(a, v1)
+ b.resetWithControl(BlockARMGTnoov, v0)
+ return true
+ }
// match: (GT (CMPconst [0] l:(AND x y)) yes no)
// cond: l.Uses==1
- // result: (GT (TST x y) yes no)
+ // result: (GTnoov (TST x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18154,39 +18179,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
break
}
- // match: (GT (CMPconst [0] l:(MULA x y a)) yes no)
- // cond: l.Uses==1
- // result: (GTnoov (CMN a (MUL <x.Type> x y)) yes no)
- for b.Controls[0].Op == OpARMCMPconst {
- v_0 := b.Controls[0]
- if v_0.AuxInt != 0 {
- break
- }
- l := v_0.Args[0]
- if l.Op != OpARMMULA {
- break
- }
- a := l.Args[2]
- x := l.Args[0]
- y := l.Args[1]
- if !(l.Uses == 1) {
- break
- }
- v0 := b.NewValue0(v_0.Pos, OpARMCMN, types.TypeFlags)
- v1 := b.NewValue0(v_0.Pos, OpARMMUL, x.Type)
- v1.AddArg2(x, y)
- v0.AddArg2(a, v1)
- b.resetWithControl(BlockARMGTnoov, v0)
- return true
- }
// match: (GT (CMPconst [0] l:(ANDconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (GT (TSTconst [c] x) yes no)
+ // result: (GTnoov (TSTconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18204,12 +18204,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftLL x y [c]) yes no)
+ // result: (GTnoov (TSTshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18228,12 +18228,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftRL x y [c]) yes no)
+ // result: (GTnoov (TSTshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18252,12 +18252,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftRA x y [c]) yes no)
+ // result: (GTnoov (TSTshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18276,12 +18276,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftLLreg x y z) yes no)
+ // result: (GTnoov (TSTshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18299,12 +18299,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftRLreg x y z) yes no)
+ // result: (GTnoov (TSTshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18322,12 +18322,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TSTshiftRAreg x y z) yes no)
+ // result: (GTnoov (TSTshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18345,12 +18345,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XOR x y)) yes no)
// cond: l.Uses==1
- // result: (GT (TEQ x y) yes no)
+ // result: (GTnoov (TEQ x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18371,14 +18371,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
break
}
// match: (GT (CMPconst [0] l:(XORconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (GT (TEQconst [c] x) yes no)
+ // result: (GTnoov (TEQconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18396,12 +18396,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftLL x y [c]) yes no)
+ // result: (GTnoov (TEQshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18420,12 +18420,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftRL x y [c]) yes no)
+ // result: (GTnoov (TEQshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18444,12 +18444,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftRA x y [c]) yes no)
+ // result: (GTnoov (TEQshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18468,12 +18468,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftLLreg x y z) yes no)
+ // result: (GTnoov (TEQshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18491,12 +18491,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftRLreg x y z) yes no)
+ // result: (GTnoov (TEQshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18514,12 +18514,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
// match: (GT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (GT (TEQshiftRAreg x y z) yes no)
+ // result: (GTnoov (TEQshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -18537,7 +18537,7 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMGT, v0)
+ b.resetWithControl(BlockARMGTnoov, v0)
return true
}
case BlockARMGTnoov:
@@ -19129,7 +19129,7 @@
}
// match: (LE (CMPconst [0] l:(AND x y)) yes no)
// cond: l.Uses==1
- // result: (LE (TST x y) yes no)
+ // result: (LEnoov (TST x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19150,14 +19150,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
break
}
// match: (LE (CMPconst [0] l:(ANDconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (LE (TSTconst [c] x) yes no)
+ // result: (LEnoov (TSTconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19175,12 +19175,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftLL x y [c]) yes no)
+ // result: (LEnoov (TSTshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19199,12 +19199,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftRL x y [c]) yes no)
+ // result: (LEnoov (TSTshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19223,12 +19223,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftRA x y [c]) yes no)
+ // result: (LEnoov (TSTshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19247,12 +19247,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftLLreg x y z) yes no)
+ // result: (LEnoov (TSTshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19270,12 +19270,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftRLreg x y z) yes no)
+ // result: (LEnoov (TSTshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19293,12 +19293,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TSTshiftRAreg x y z) yes no)
+ // result: (LEnoov (TSTshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19316,12 +19316,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XOR x y)) yes no)
// cond: l.Uses==1
- // result: (LE (TEQ x y) yes no)
+ // result: (LEnoov (TEQ x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19342,14 +19342,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
break
}
// match: (LE (CMPconst [0] l:(XORconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (LE (TEQconst [c] x) yes no)
+ // result: (LEnoov (TEQconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19367,12 +19367,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftLL x y [c]) yes no)
+ // result: (LEnoov (TEQshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19391,12 +19391,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftRL x y [c]) yes no)
+ // result: (LEnoov (TEQshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19415,12 +19415,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftRA x y [c]) yes no)
+ // result: (LEnoov (TEQshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19439,12 +19439,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftLLreg x y z) yes no)
+ // result: (LEnoov (TEQshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19462,12 +19462,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftRLreg x y z) yes no)
+ // result: (LEnoov (TEQshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19485,12 +19485,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
// match: (LE (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LE (TEQshiftRAreg x y z) yes no)
+ // result: (LEnoov (TEQshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -19508,7 +19508,7 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLE, v0)
+ b.resetWithControl(BlockARMLEnoov, v0)
return true
}
case BlockARMLEnoov:
@@ -20009,7 +20009,7 @@
}
// match: (LT (CMPconst [0] l:(AND x y)) yes no)
// cond: l.Uses==1
- // result: (LT (TST x y) yes no)
+ // result: (LTnoov (TST x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20030,14 +20030,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTST, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
break
}
// match: (LT (CMPconst [0] l:(ANDconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (LT (TSTconst [c] x) yes no)
+ // result: (LTnoov (TSTconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20055,12 +20055,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftLL x y [c]) yes no)
+ // result: (LTnoov (TSTshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20079,12 +20079,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftRL x y [c]) yes no)
+ // result: (LTnoov (TSTshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20103,12 +20103,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftRA x y [c]) yes no)
+ // result: (LTnoov (TSTshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20127,12 +20127,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftLLreg x y z) yes no)
+ // result: (LTnoov (TSTshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20150,12 +20150,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftRLreg x y z) yes no)
+ // result: (LTnoov (TSTshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20173,12 +20173,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(ANDshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TSTshiftRAreg x y z) yes no)
+ // result: (LTnoov (TSTshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20196,12 +20196,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTSTshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XOR x y)) yes no)
// cond: l.Uses==1
- // result: (LT (TEQ x y) yes no)
+ // result: (LTnoov (TEQ x y) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20222,14 +20222,14 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQ, types.TypeFlags)
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
break
}
// match: (LT (CMPconst [0] l:(XORconst [c] x)) yes no)
// cond: l.Uses==1
- // result: (LT (TEQconst [c] x) yes no)
+ // result: (LTnoov (TEQconst [c] x) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20247,12 +20247,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQconst, types.TypeFlags)
v0.AuxInt = c
v0.AddArg(x)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftLL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftLL x y [c]) yes no)
+ // result: (LTnoov (TEQshiftLL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20271,12 +20271,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftRL x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftRL x y [c]) yes no)
+ // result: (LTnoov (TEQshiftRL x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20295,12 +20295,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRL, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftRA x y [c])) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftRA x y [c]) yes no)
+ // result: (LTnoov (TEQshiftRA x y [c]) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20319,12 +20319,12 @@
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRA, types.TypeFlags)
v0.AuxInt = c
v0.AddArg2(x, y)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftLLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftLLreg x y z) yes no)
+ // result: (LTnoov (TEQshiftLLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20342,12 +20342,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftLLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftRLreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftRLreg x y z) yes no)
+ // result: (LTnoov (TEQshiftRLreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20365,12 +20365,12 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRLreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
// match: (LT (CMPconst [0] l:(XORshiftRAreg x y z)) yes no)
// cond: l.Uses==1
- // result: (LT (TEQshiftRAreg x y z) yes no)
+ // result: (LTnoov (TEQshiftRAreg x y z) yes no)
for b.Controls[0].Op == OpARMCMPconst {
v_0 := b.Controls[0]
if v_0.AuxInt != 0 {
@@ -20388,7 +20388,7 @@
}
v0 := b.NewValue0(v_0.Pos, OpARMTEQshiftRAreg, types.TypeFlags)
v0.AddArg3(x, y, z)
- b.resetWithControl(BlockARMLT, v0)
+ b.resetWithControl(BlockARMLTnoov, v0)
return true
}
case BlockARMLTnoov:
diff -Nru golang-1.15-1.15.9/src/cmd/compile/internal/ssa/shortcircuit.go golang-1.15-1.15.15/src/cmd/compile/internal/ssa/shortcircuit.go
--- golang-1.15-1.15.9/src/cmd/compile/internal/ssa/shortcircuit.go 2021-03-10 22:29:32.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/compile/internal/ssa/shortcircuit.go 2021-08-05 05:20:40.000000000 +0800
@@ -138,6 +138,24 @@
if len(b.Values) != nval+nOtherPhi {
return false
}
+ if nOtherPhi > 0 {
+ // Check for any phi which is the argument of another phi.
+ // These cases are tricky, as substitutions done by replaceUses
+ // are no longer trivial to do in any ordering. See issue 45175.
+ m := make(map[*Value]bool, 1+nOtherPhi)
+ for _, v := range b.Values {
+ if v.Op == OpPhi {
+ m[v] = true
+ }
+ }
+ for v := range m {
+ for _, a := range v.Args {
+ if a != v && m[a] {
+ return false
+ }
+ }
+ }
+ }
// Locate index of first const phi arg.
cidx := -1
diff -Nru golang-1.15-1.15.9/src/cmd/go/go_test.go golang-1.15-1.15.15/src/cmd/go/go_test.go
--- golang-1.15-1.15.9/src/cmd/go/go_test.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/go_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -9,6 +9,7 @@
"debug/elf"
"debug/macho"
"debug/pe"
+ "encoding/binary"
"flag"
"fmt"
"go/format"
@@ -2166,6 +2167,38 @@
if (dc & pe.IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) == 0 {
t.Error("IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag is not set")
}
+ if useCgo {
+ // Test that only one symbol is exported (#40795).
+ // PIE binaries don´t require .edata section but unfortunately
+ // binutils doesn´t generate a .reloc section unless there is
+ // at least one symbol exported.
+ // See https://sourceware.org/bugzilla/show_bug.cgi?id=19011
+ section := f.Section(".edata")
+ if section == nil {
+ t.Fatalf(".edata section is not present")
+ }
+ // TODO: deduplicate this struct from cmd/link/internal/ld/pe.go
+ type IMAGE_EXPORT_DIRECTORY struct {
+ _ [2]uint32
+ _ [2]uint16
+ _ [2]uint32
+ NumberOfFunctions uint32
+ NumberOfNames uint32
+ _ [3]uint32
+ }
+ var e IMAGE_EXPORT_DIRECTORY
+ if err := binary.Read(section.Open(), binary.LittleEndian, &e); err != nil {
+ t.Fatalf("binary.Read failed: %v", err)
+ }
+
+ // Only _cgo_dummy_export should be exported
+ if e.NumberOfFunctions != 1 {
+ t.Fatalf("got %d exported functions; want 1", e.NumberOfFunctions)
+ }
+ if e.NumberOfNames != 1 {
+ t.Fatalf("got %d exported names; want 1", e.NumberOfNames)
+ }
+ }
default:
panic("unreachable")
}
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/load/pkg.go golang-1.15-1.15.15/src/cmd/go/internal/load/pkg.go
--- golang-1.15-1.15.9/src/cmd/go/internal/load/pkg.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/load/pkg.go 2021-08-05 05:20:40.000000000 +0800
@@ -1280,6 +1280,11 @@
Err: errors.New("import cycle not allowed"),
IsImportCycle: true,
}
+ } else if !p.Error.IsImportCycle {
+ // If the error is already set, but it does not indicate that
+ // we are in an import cycle, set IsImportCycle so that we don't
+ // end up stuck in a loop down the road.
+ p.Error.IsImportCycle = true
}
p.Incomplete = true
}
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modcmd/tidy.go golang-1.15-1.15.15/src/cmd/go/internal/modcmd/tidy.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modcmd/tidy.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modcmd/tidy.go 2021-08-05 05:20:40.000000000 +0800
@@ -42,6 +42,8 @@
base.Fatalf("go mod tidy: no arguments allowed")
}
+ modload.SilenceMissingStdImports = true
+ modload.CheckTidyVersion()
modload.LoadALL()
modload.TidyBuildList()
modTidyGoSum() // updates memory copy; WriteGoMod on next line flushes it out
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modcmd/vendor.go golang-1.15-1.15.15/src/cmd/go/internal/modcmd/vendor.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modcmd/vendor.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modcmd/vendor.go 2021-08-05 05:20:40.000000000 +0800
@@ -10,6 +10,7 @@
"io"
"io/ioutil"
"os"
+ "path"
"path/filepath"
"sort"
"strings"
@@ -47,6 +48,7 @@
if len(args) != 0 {
base.Fatalf("go mod vendor: vendor takes no arguments")
}
+ modload.SilenceMissingStdImports = true
pkgs := modload.LoadVendor()
vdir := filepath.Join(modload.ModRoot(), "vendor")
@@ -191,7 +193,7 @@
if modPath == pkg {
break
}
- pkg = filepath.Dir(pkg)
+ pkg = path.Dir(pkg)
dst = filepath.Dir(dst)
src = filepath.Dir(src)
}
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modfetch/cache.go golang-1.15-1.15.15/src/cmd/go/internal/modfetch/cache.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modfetch/cache.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modfetch/cache.go 2021-08-05 05:20:40.000000000 +0800
@@ -83,6 +83,7 @@
return "", err
}
+ // Check whether the directory itself exists.
dir := filepath.Join(cfg.GOMODCACHE, enc+"@"+encVer)
if fi, err := os.Stat(dir); os.IsNotExist(err) {
return dir, err
@@ -91,6 +92,9 @@
} else if !fi.IsDir() {
return dir, &DownloadDirPartialError{dir, errors.New("not a directory")}
}
+
+ // Check if a .partial file exists. This is created at the beginning of
+ // a download and removed after the zip is extracted.
partialPath, err := CachePath(m, "partial")
if err != nil {
return dir, err
@@ -100,6 +104,19 @@
} else if !os.IsNotExist(err) {
return dir, err
}
+
+ // Check if a .ziphash file exists. It should be created before the
+ // zip is extracted, but if it was deleted (by another program?), we need
+ // to re-calculate it.
+ ziphashPath, err := CachePath(m, "ziphash")
+ if err != nil {
+ return dir, err
+ }
+ if _, err := os.Stat(ziphashPath); os.IsNotExist(err) {
+ return dir, &DownloadDirPartialError{dir, errors.New("ziphash file is missing")}
+ } else if err != nil {
+ return dir, err
+ }
return dir, nil
}
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modfetch/fetch.go golang-1.15-1.15.15/src/cmd/go/internal/modfetch/fetch.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modfetch/fetch.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modfetch/fetch.go 2021-08-05 05:20:40.000000000 +0800
@@ -206,13 +206,16 @@
if err != nil {
return cached{"", err}
}
+ ziphashfile := zipfile + "hash"
- // Skip locking if the zipfile already exists.
+ // Return without locking if the zip and ziphash files exist.
if _, err := os.Stat(zipfile); err == nil {
- return cached{zipfile, nil}
+ if _, err := os.Stat(ziphashfile); err == nil {
+ return cached{zipfile, nil}
+ }
}
- // The zip file does not exist. Acquire the lock and create it.
+ // The zip or ziphash file does not exist. Acquire the lock and create them.
if cfg.CmdName != "mod download" {
fmt.Fprintf(os.Stderr, "go: downloading %s %s\n", mod.Path, mod.Version)
}
@@ -222,14 +225,6 @@
}
defer unlock()
- // Double-check that the zipfile was not created while we were waiting for
- // the lock.
- if _, err := os.Stat(zipfile); err == nil {
- return cached{zipfile, nil}
- }
- if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil {
- return cached{"", err}
- }
if err := downloadZip(mod, zipfile); err != nil {
return cached{"", err}
}
@@ -239,6 +234,25 @@
}
func downloadZip(mod module.Version, zipfile string) (err error) {
+ // Double-check that the zipfile was not created while we were waiting for
+ // the lock in DownloadZip.
+ ziphashfile := zipfile + "hash"
+ var zipExists, ziphashExists bool
+ if _, err := os.Stat(zipfile); err == nil {
+ zipExists = true
+ }
+ if _, err := os.Stat(ziphashfile); err == nil {
+ ziphashExists = true
+ }
+ if zipExists && ziphashExists {
+ return nil
+ }
+
+ // Create parent directories.
+ if err := os.MkdirAll(filepath.Dir(zipfile), 0777); err != nil {
+ return err
+ }
+
// Clean up any remaining tempfiles from previous runs.
// This is only safe to do because the lock file ensures that their
// writers are no longer active.
@@ -250,6 +264,12 @@
}
}
+ // If the zip file exists, the ziphash file must have been deleted
+ // or lost after a file system crash. Re-hash the zip without downloading.
+ if zipExists {
+ return hashZip(mod, zipfile, ziphashfile)
+ }
+
// From here to the os.Rename call below is functionally almost equivalent to
// renameio.WriteToFile, with one key difference: we want to validate the
// contents of the file (by hashing it) before we commit it. Because the file
@@ -306,15 +326,7 @@
}
// Hash the zip file and check the sum before renaming to the final location.
- hash, err := dirhash.HashZip(f.Name(), dirhash.DefaultHash)
- if err != nil {
- return err
- }
- if err := checkModSum(mod, hash); err != nil {
- return err
- }
-
- if err := renameio.WriteFile(zipfile+"hash", []byte(hash), 0666); err != nil {
+ if err := hashZip(mod, f.Name(), ziphashfile); err != nil {
return err
}
if err := os.Rename(f.Name(), zipfile); err != nil {
@@ -326,6 +338,22 @@
return nil
}
+// hashZip reads the zip file opened in f, then writes the hash to ziphashfile,
+// overwriting that file if it exists.
+//
+// If the hash does not match go.sum (or the sumdb if enabled), hashZip returns
+// an error and does not write ziphashfile.
+func hashZip(mod module.Version, zipfile, ziphashfile string) error {
+ hash, err := dirhash.HashZip(zipfile, dirhash.DefaultHash)
+ if err != nil {
+ return err
+ }
+ if err := checkModSum(mod, hash); err != nil {
+ return err
+ }
+ return renameio.WriteFile(ziphashfile, []byte(hash), 0666)
+}
+
// makeDirsReadOnly makes a best-effort attempt to remove write permissions for dir
// and its transitive contents.
func makeDirsReadOnly(dir string) {
@@ -457,11 +485,6 @@
// checkMod checks the given module's checksum.
func checkMod(mod module.Version) {
- if cfg.GOMODCACHE == "" {
- // Do not use current directory.
- return
- }
-
// Do the file I/O before acquiring the go.sum lock.
ziphash, err := CachePath(mod, "ziphash")
if err != nil {
@@ -469,10 +492,6 @@
}
data, err := renameio.ReadFile(ziphash)
if err != nil {
- if errors.Is(err, os.ErrNotExist) {
- // This can happen if someone does rm -rf GOPATH/src/cache/download. So it goes.
- return
- }
base.Fatalf("verifying %v", module.VersionError(mod, err))
}
h := strings.TrimSpace(string(data))
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modload/init.go golang-1.15-1.15.15/src/cmd/go/internal/modload/init.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modload/init.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modload/init.go 2021-08-05 05:20:40.000000000 +0800
@@ -56,6 +56,12 @@
CmdModModule string // module argument for 'go mod init'
allowMissingModuleImports bool
+
+ // SilenceMissingStdImports indicates that LoadALL should not print an error
+ // or terminate the process if an imported package is missing, and the import
+ // path looks like it might be in the standard library (perhaps in a future
+ // Go version).
+ SilenceMissingStdImports bool
)
// ModFile returns the parsed go.mod file.
diff -Nru golang-1.15-1.15.9/src/cmd/go/internal/modload/load.go golang-1.15-1.15.15/src/cmd/go/internal/modload/load.go
--- golang-1.15-1.15.9/src/cmd/go/internal/modload/load.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/internal/modload/load.go 2021-08-05 05:20:40.000000000 +0800
@@ -24,7 +24,9 @@
"sort"
"strings"
+ "golang.org/x/mod/modfile"
"golang.org/x/mod/module"
+ "golang.org/x/mod/semver"
)
// buildList is the list of modules to use for building packages.
@@ -433,6 +435,11 @@
var paths []string
for _, pkg := range loaded.pkgs {
if pkg.err != nil {
+ if impErr := (*ImportMissingError)(nil); SilenceMissingStdImports &&
+ errors.As(pkg.err, &impErr) &&
+ search.IsStandardImportPath(impErr.Path) {
+ continue
+ }
base.Errorf("%s: %v", pkg.stackText(), pkg.err)
continue
}
@@ -473,6 +480,31 @@
buildList = append([]module.Version{}, list...)
}
+// CheckTidyVersion reports an error to stderr if the Go version indicated by
+// the go.mod file is not supported by this version of the 'go' command.
+//
+// If allowError is false, such an error terminates the program.
+func CheckTidyVersion() {
+ InitMod()
+ mf := ModFile()
+ if mf.Go == nil || mf.Go.Version == "" {
+ return
+ }
+ goVersionV := "v" + mf.Go.Version
+
+ tags := build.Default.ReleaseTags
+ maxGo := tags[len(tags)-1]
+ if !strings.HasPrefix(maxGo, "go") || !modfile.GoVersionRE.MatchString(maxGo[2:]) {
+ base.Fatalf("go: unrecognized go version %q", maxGo)
+ }
+ max := maxGo[2:]
+
+ if semver.Compare(goVersionV, "v"+max) > 0 {
+ have := goVersionV[1:]
+ base.Fatalf("go mod tidy: go.mod file indicates go %s, but maximum supported version is %s\n", have, max)
+ }
+}
+
// TidyBuildList trims the build list to the minimal requirements needed to
// retain the same versions of all packages from the preceding Load* or
// ImportPaths* call.
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/list_err_cycle.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/list_err_cycle.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/list_err_cycle.txt 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/list_err_cycle.txt 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,15 @@
+# Check that we don't get infinite recursion when loading a package with
+# an import cycle and another error. Verifies #25830.
+! go list
+stderr 'found packages a \(a.go\) and b \(b.go\)'
+
+-- go.mod --
+module errcycle
+
+go 1.16
+-- a.go --
+package a
+
+import _ "errcycle"
+-- b.go --
+package b
\ No newline at end of file
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_get_missing_ziphash.txt 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,55 @@
+# Test that if the module cache contains an extracted source directory but not
+# a ziphash, 'go build' complains about a missing sum, and 'go get' adds
+# the sum. Verifies #44749.
+
+# With a tidy go.sum, go build succeeds. This also populates the module cache.
+cp go.sum.tidy go.sum
+go build -n use
+env GOPROXY=off
+env GOSUMDB=off
+
+# Control case: if we delete the hash for rsc.io/quote v1.5.2,
+# 'go build' reports an error. 'go get' adds the sum.
+cp go.sum.bug go.sum
+! go build -n -mod=readonly use
+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$'
+go get -d use
+cmp go.sum go.sum.tidy
+go build -n use
+
+# If we delete the hash *and* the ziphash file, we should see the same behavior.
+cp go.sum.bug go.sum
+rm $WORK/gopath/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.2.ziphash
+! go build -n -mod=readonly use
+stderr '^go: updates to go.sum needed, disabled by -mod=readonly$'
+go get -d use
+cmp go.sum go.sum.tidy
+go build -n use
+
+-- go.mod --
+module use
+
+go 1.17
+
+require rsc.io/quote v1.5.2
+-- go.sum.tidy --
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64=
+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY=
+-- go.sum.bug --
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
+rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
+rsc.io/testonly v1.0.0 h1:K/VWHdO+Jv7woUXG0GzVNx1czBXUt3Ib1deaMn+xk64=
+rsc.io/testonly v1.0.0/go.mod h1:OqmGbIFOcF+XrFReLOGZ6BhMM7uMBiQwZsyNmh74SzY=
+-- use.go --
+package use
+
+import _ "rsc.io/quote"
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_readonly.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_readonly.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_readonly.txt 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_readonly.txt 2021-08-05 05:20:40.000000000 +0800
@@ -64,7 +64,7 @@
-- go.mod --
module m
-go 1.20
+go 1.15
-- x.go --
package x
@@ -79,7 +79,7 @@
-- go.mod.redundant --
module m
-go 1.20
+go 1.15
require (
rsc.io/quote v1.5.2
@@ -89,7 +89,7 @@
-- go.mod.indirect --
module m
-go 1.20
+go 1.15
require (
rsc.io/quote v1.5.2 // indirect
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_tidy_error.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_tidy_error.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_tidy_error.txt 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_tidy_error.txt 2021-08-05 05:20:40.000000000 +0800
@@ -4,12 +4,12 @@
# 'go mod tidy' and 'go mod vendor' should not hide loading errors.
! go mod tidy
-stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)'
+! stderr 'package nonexist is not in GOROOT'
stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com'
stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist'
! go mod vendor
-stderr '^issue27063 imports\n\tnonexist: package nonexist is not in GOROOT \(.*\)'
+! stderr 'package nonexist is not in GOROOT'
stderr '^issue27063 imports\n\tnonexist.example.com: cannot find module providing package nonexist.example.com'
stderr '^issue27063 imports\n\tissue27063/other imports\n\tother.example.com/nonexist: cannot find module providing package other.example.com/nonexist'
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_tidy_too_new.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_tidy_too_new.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_tidy_too_new.txt 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_tidy_too_new.txt 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,31 @@
+# https://golang.org/issue/46142: 'go mod tidy' should error out if the version
+# in the go.mod file is newer than the most recent supported version.
+
+cp go.mod go.mod.orig
+
+
+# If the go.mod file specifies an unsupported Go version, 'go mod tidy' should
+# refuse to edit it: we don't know what a tidy go.mod file for that version
+# would look like.
+
+! go mod tidy
+stderr 'go mod tidy: go.mod file indicates go 2000.0, but maximum supported version is '$goversion'$'
+cmp go.mod go.mod.orig
+
+
+-- go.mod --
+module example.net/from/the/future
+
+go 2000.0
+
+replace example.net/m v0.0.0 => ./m
+-- x.go --
+package x
+
+import "example.net/m"
+-- m/go.mod --
+module example.net/m
+
+go 1.17
+-- m/m.go --
+package m
diff -Nru golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_verify.txt golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_verify.txt
--- golang-1.15-1.15.9/src/cmd/go/testdata/script/mod_verify.txt 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/go/testdata/script/mod_verify.txt 2021-08-05 05:20:40.000000000 +0800
@@ -50,10 +50,13 @@
grep '^rsc.io/quote v1.1.0/go.mod ' go.sum
grep '^rsc.io/quote v1.1.0 ' go.sum
-# sync should ignore missing ziphash; verify should not
+# verify should fail on a missing ziphash. tidy should restore it.
rm $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
-go mod tidy
! go mod verify
+stderr '^rsc.io/quote v1.1.0: missing ziphash: open '$GOPATH'[/\\]pkg[/\\]mod[/\\]cache[/\\]download[/\\]rsc.io[/\\]quote[/\\]@v[/\\]v1.1.0.ziphash'
+go mod tidy
+exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.1.0.ziphash
+go mod verify
# Packages below module root should not be mentioned in go.sum.
rm go.sum
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/arm/asm.go golang-1.15-1.15.15/src/cmd/link/internal/arm/asm.go
--- golang-1.15-1.15.9/src/cmd/link/internal/arm/asm.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/arm/asm.go 2021-08-05 05:20:40.000000000 +0800
@@ -373,10 +373,16 @@
r := relocs.At2(ri)
switch r.Type() {
case objabi.R_CALLARM:
- // r.Add is the instruction
- // low 24-bit encodes the target address
- t := (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4
- if t > 0x7fffff || t < -0x800000 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
+ var t int64
+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet
+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages
+ // in dependency order.
+ if ldr.SymValue(rs) != 0 {
+ // r.Add is the instruction
+ // low 24-bit encodes the target address
+ t = (ldr.SymValue(rs) + int64(signext24(r.Add()&0xffffff)*4) - (ldr.SymValue(s) + int64(r.Off()))) / 4
+ }
+ if t > 0x7fffff || t < -0x800000 || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
// direct call too far, need to insert trampoline.
// look up existing trampolines first. if we found one within the range
// of direct call, we can reuse it. otherwise create a new one.
@@ -447,7 +453,7 @@
arch.ByteOrder.PutUint32(P[8:], o3)
tramp.SetData(P)
- if linkmode == ld.LinkExternal {
+ if linkmode == ld.LinkExternal || ldr.SymValue(target) == 0 {
r := loader.Reloc{
Off: 8,
Type: objabi.R_ADDR,
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/ld/data.go golang-1.15-1.15.15/src/cmd/link/internal/ld/data.go
--- golang-1.15-1.15.9/src/cmd/link/internal/ld/data.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/ld/data.go 2021-08-05 05:20:40.000000000 +0800
@@ -105,14 +105,12 @@
}
rs = ldr.ResolveABIAlias(rs)
if ldr.SymValue(rs) == 0 && (ldr.SymType(rs) != sym.SDYNIMPORT && ldr.SymType(rs) != sym.SUNDEFEXT) {
- if ldr.SymPkg(rs) != ldr.SymPkg(s) {
- if !isRuntimeDepPkg(ldr.SymPkg(s)) || !isRuntimeDepPkg(ldr.SymPkg(rs)) {
- ctxt.Errorf(s, "unresolved inter-package jump to %s(%s) from %s", ldr.SymName(rs), ldr.SymPkg(rs), ldr.SymPkg(s))
- }
- // runtime and its dependent packages may call to each other.
- // they are fine, as they will be laid down together.
+ if ldr.SymPkg(rs) == ldr.SymPkg(s) {
+ continue // symbols in the same package are laid out together
+ }
+ if isRuntimeDepPkg(ldr.SymPkg(s)) && isRuntimeDepPkg(ldr.SymPkg(rs)) {
+ continue // runtime packages are laid out together
}
- continue
}
thearch.Trampoline(ctxt, ldr, ri, rs, s)
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/ld/elf.go golang-1.15-1.15.15/src/cmd/link/internal/ld/elf.go
--- golang-1.15-1.15.9/src/cmd/link/internal/ld/elf.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/ld/elf.go 2021-08-05 05:20:40.000000000 +0800
@@ -1400,7 +1400,7 @@
}
ldr := ctxt.loader
- eaddr := int32(sect.Vaddr + sect.Length)
+ eaddr := sect.Vaddr + sect.Length
for _, s := range syms {
if !s.Attr.Reachable() {
continue
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/ld/lib.go golang-1.15-1.15.15/src/cmd/link/internal/ld/lib.go
--- golang-1.15-1.15.9/src/cmd/link/internal/ld/lib.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/ld/lib.go 2021-08-05 05:20:40.000000000 +0800
@@ -1423,9 +1423,6 @@
if ctxt.Arch.PtrSize >= 8 {
argv = append(argv, "-Wl,--high-entropy-va")
}
- // Work around binutils limitation that strips relocation table for dynamicbase.
- // See https://sourceware.org/bugzilla/show_bug.cgi?id=19011
- argv = append(argv, "-Wl,--export-all-symbols")
default:
// ELF.
if ctxt.UseRelro() {
@@ -1558,7 +1555,7 @@
}
const compressDWARF = "-Wl,--compress-debug-sections=zlib-gnu"
- if ctxt.compressDWARF && linkerFlagSupported(argv[0], altLinker, compressDWARF) {
+ if ctxt.compressDWARF && linkerFlagSupported(ctxt.Arch, argv[0], altLinker, compressDWARF) {
argv = append(argv, compressDWARF)
}
@@ -1648,7 +1645,7 @@
if ctxt.BuildMode == BuildModeExe && !ctxt.linkShared {
// GCC uses -no-pie, clang uses -nopie.
for _, nopie := range []string{"-no-pie", "-nopie"} {
- if linkerFlagSupported(argv[0], altLinker, nopie) {
+ if linkerFlagSupported(ctxt.Arch, argv[0], altLinker, nopie) {
argv = append(argv, nopie)
break
}
@@ -1749,7 +1746,7 @@
var createTrivialCOnce sync.Once
-func linkerFlagSupported(linker, altLinker, flag string) bool {
+func linkerFlagSupported(arch *sys.Arch, linker, altLinker, flag string) bool {
createTrivialCOnce.Do(func() {
src := filepath.Join(*flagTmpdir, "trivial.c")
if err := ioutil.WriteFile(src, []byte("int main() { return 0; }"), 0666); err != nil {
@@ -1783,7 +1780,7 @@
"-target",
}
- var flags []string
+ flags := hostlinkArchArgs(arch)
keep := false
skip := false
extldflags := strings.Fields(*flagExtldflags)
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/ld/macho.go golang-1.15-1.15.15/src/cmd/link/internal/ld/macho.go
--- golang-1.15-1.15.9/src/cmd/link/internal/ld/macho.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/ld/macho.go 2021-08-05 05:20:40.000000000 +0800
@@ -1044,7 +1044,7 @@
}
}
- eaddr := int32(sect.Vaddr + sect.Length)
+ eaddr := sect.Vaddr + sect.Length
for _, s := range syms {
if !s.Attr.Reachable() {
continue
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/loader/loader.go golang-1.15-1.15.15/src/cmd/link/internal/loader/loader.go
--- golang-1.15-1.15.9/src/cmd/link/internal/loader/loader.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/loader/loader.go 2021-08-05 05:20:40.000000000 +0800
@@ -434,7 +434,17 @@
if l.flags&FlagStrictDups != 0 {
l.checkdup(name, r, li, oldi)
}
- return oldi, false
+ // Fix for issue #46656 -- given two dupok symbols with
+ // different sizes, favor symbol with larger size.
+ szdup := l.SymSize(oldi)
+ sz := int64(r.Sym(li).Siz())
+ if szdup >= sz {
+ return oldi, false
+ } else {
+ // new symbol overwrites old symbol.
+ l.objSyms[oldi] = objSym{r, li}
+ return oldi, true
+ }
}
oldr, oldli := l.toLocal(oldi)
oldsym := oldr.Sym(oldli)
diff -Nru golang-1.15-1.15.9/src/cmd/link/internal/ppc64/asm.go golang-1.15-1.15.15/src/cmd/link/internal/ppc64/asm.go
--- golang-1.15-1.15.9/src/cmd/link/internal/ppc64/asm.go 2021-03-10 22:29:33.000000000 +0800
+++ golang-1.15-1.15.15/src/cmd/link/internal/ppc64/asm.go 2021-08-05 05:20:40.000000000 +0800
@@ -658,6 +658,16 @@
return int64(o2)<<32 | int64(o1)
}
+// Determine if the code was compiled so that the TOC register R2 is initialized and maintained
+func r2Valid(ctxt *ld.Link) bool {
+ switch ctxt.BuildMode {
+ case ld.BuildModeCArchive, ld.BuildModeCShared, ld.BuildModePIE, ld.BuildModeShared, ld.BuildModePlugin:
+ return true
+ }
+ // -linkshared option
+ return ctxt.IsSharedGoLink()
+}
+
// resolve direct jump relocation r in s, and add trampoline if necessary
func trampoline(ctxt *ld.Link, ldr *loader.Loader, ri int, rs, s loader.Sym) {
@@ -665,20 +675,26 @@
// For internal linking, trampolines are always created for long calls.
// For external linking, the linker can insert a call stub to handle a long call, but depends on having the TOC address in
// r2. For those build modes with external linking where the TOC address is not maintained in r2, trampolines must be created.
- if ctxt.IsExternal() && (ctxt.DynlinkingGo() || ctxt.BuildMode == ld.BuildModeCArchive || ctxt.BuildMode == ld.BuildModeCShared || ctxt.BuildMode == ld.BuildModePIE) {
+ if ctxt.IsExternal() && r2Valid(ctxt) {
// No trampolines needed since r2 contains the TOC
return
}
relocs := ldr.Relocs(s)
r := relocs.At2(ri)
- t := ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off()))
+ var t int64
+ // ldr.SymValue(rs) == 0 indicates a cross-package jump to a function that is not yet
+ // laid out. Conservatively use a trampoline. This should be rare, as we lay out packages
+ // in dependency order.
+ if ldr.SymValue(rs) != 0 {
+ t = ldr.SymValue(rs) + r.Add() - (ldr.SymValue(s) + int64(r.Off()))
+ }
switch r.Type() {
case objabi.R_CALLPOWER:
// If branch offset is too far then create a trampoline.
- if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
+ if (ctxt.IsExternal() && ldr.SymSect(s) != ldr.SymSect(rs)) || (ctxt.IsInternal() && int64(int32(t<<6)>>6) != t) || ldr.SymValue(rs) == 0 || (*ld.FlagDebugTramp > 1 && ldr.SymPkg(s) != ldr.SymPkg(rs)) {
var tramp loader.Sym
for i := 0; ; i++ {
@@ -713,7 +729,7 @@
}
}
if ldr.SymType(tramp) == 0 {
- if ctxt.DynlinkingGo() || ctxt.BuildMode == ld.BuildModeCArchive || ctxt.BuildMode == ld.BuildModeCShared || ctxt.BuildMode == ld.BuildModePIE {
+ if r2Valid(ctxt) {
// Should have returned for above cases
ctxt.Errorf(s, "unexpected trampoline for shared or dynamic linking")
} else {
@@ -769,7 +785,7 @@
// With external linking, the target address must be
// relocated using LO and HA
- if ctxt.IsExternal() {
+ if ctxt.IsExternal() || ldr.SymValue(target) == 0 {
r := loader.Reloc{
Off: 0,
Type: objabi.R_ADDRPOWER,
diff -Nru golang-1.15-1.15.9/src/crypto/tls/key_agreement.go golang-1.15-1.15.15/src/crypto/tls/key_agreement.go
--- golang-1.15-1.15.9/src/crypto/tls/key_agreement.go 2021-03-10 22:29:34.000000000 +0800
+++ golang-1.15-1.15.15/src/crypto/tls/key_agreement.go 2021-08-05 05:20:40.000000000 +0800
@@ -67,7 +67,11 @@
return nil, nil, err
}
- encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
+ rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
+ if !ok {
+ return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
+ }
+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
if err != nil {
return nil, nil, err
}
diff -Nru golang-1.15-1.15.9/src/database/sql/sql.go golang-1.15-1.15.15/src/database/sql/sql.go
--- golang-1.15-1.15.9/src/database/sql/sql.go 2021-03-10 22:29:35.000000000 +0800
+++ golang-1.15-1.15.15/src/database/sql/sql.go 2021-08-05 05:20:40.000000000 +0800
@@ -2080,10 +2080,10 @@
// that has already been committed or rolled back.
var ErrTxDone = errors.New("sql: transaction has already been committed or rolled back")
-// closeLocked returns the connection to the pool and
+// close returns the connection to the pool and
// must only be called by Tx.rollback or Tx.Commit while
-// closemu is Locked and tx already canceled.
-func (tx *Tx) closeLocked(err error) {
+// tx is already canceled and won't be executed concurrently.
+func (tx *Tx) close(err error) {
tx.releaseConn(err)
tx.dc = nil
tx.txi = nil
@@ -2157,7 +2157,7 @@
// to ensure no other connection has an active query.
tx.cancel()
tx.closemu.Lock()
- defer tx.closemu.Unlock()
+ tx.closemu.Unlock()
var err error
withLock(tx.dc, func() {
@@ -2166,7 +2166,7 @@
if err != driver.ErrBadConn {
tx.closePrepared()
}
- tx.closeLocked(err)
+ tx.close(err)
return err
}
@@ -2189,7 +2189,7 @@
// to ensure no other connection has an active query.
tx.cancel()
tx.closemu.Lock()
- defer tx.closemu.Unlock()
+ tx.closemu.Unlock()
var err error
withLock(tx.dc, func() {
@@ -2201,7 +2201,7 @@
if discardConn {
err = driver.ErrBadConn
}
- tx.closeLocked(err)
+ tx.close(err)
return err
}
diff -Nru golang-1.15-1.15.9/src/database/sql/sql_test.go golang-1.15-1.15.15/src/database/sql/sql_test.go
--- golang-1.15-1.15.9/src/database/sql/sql_test.go 2021-03-10 22:29:35.000000000 +0800
+++ golang-1.15-1.15.15/src/database/sql/sql_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -2810,6 +2810,34 @@
}
}
+// Issue 40985 transaction statement deadlock while context cancel.
+func TestTxStmtDeadlock(t *testing.T) {
+ db := newTestDB(t, "people")
+ defer closeDB(t, db)
+
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
+ defer cancel()
+ tx, err := db.BeginTx(ctx, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ stmt, err := tx.Prepare("SELECT|people|name,age|age=?")
+ if err != nil {
+ t.Fatal(err)
+ }
+ // Run number of stmt queries to reproduce deadlock from context cancel
+ for i := 0; i < 1e3; i++ {
+ // Encounter any close related errors (e.g.. ErrTxDone, stmt is closed)
+ // is expected due to context cancel.
+ _, err = stmt.Query(1)
+ if err != nil {
+ break
+ }
+ }
+ _ = tx.Rollback()
+}
+
// Issue32530 encounters an issue where a connection may
// expire right after it comes out of a used connection pool
// even when a new connection is requested.
diff -Nru golang-1.15-1.15.9/src/go.mod golang-1.15-1.15.15/src/go.mod
--- golang-1.15-1.15.9/src/go.mod 2021-03-10 22:29:35.000000000 +0800
+++ golang-1.15-1.15.15/src/go.mod 2021-08-05 05:20:40.000000000 +0800
@@ -4,7 +4,7 @@
require (
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
- golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91
+ golang.org/x/net v0.0.0-20210428183841-261fb518b1ed
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
golang.org/x/text v0.3.3-0.20200430171850-afb9336c4530 // indirect
)
diff -Nru golang-1.15-1.15.9/src/go.sum golang-1.15-1.15.15/src/go.sum
--- golang-1.15-1.15.9/src/go.sum 2021-03-10 22:29:35.000000000 +0800
+++ golang-1.15-1.15.15/src/go.sum 2021-08-05 05:20:40.000000000 +0800
@@ -2,8 +2,8 @@
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4=
-golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20210428183841-261fb518b1ed h1:aunM0N/jnRHvQgZo3kYkfaAGet2kIMFOPIbopG5BhYw=
+golang.org/x/net v0.0.0-20210428183841-261fb518b1ed/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff -Nru golang-1.15-1.15.9/src/internal/poll/copy_file_range_linux.go golang-1.15-1.15.15/src/internal/poll/copy_file_range_linux.go
--- golang-1.15-1.15.9/src/internal/poll/copy_file_range_linux.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/internal/poll/copy_file_range_linux.go 2021-08-05 05:20:40.000000000 +0800
@@ -112,7 +112,15 @@
return 0, false, nil
case nil:
if n == 0 {
- // src is at EOF, which means we are done.
+ // If we did not read any bytes at all,
+ // then this file may be in a file system
+ // where copy_file_range silently fails.
+ // https://lore.kernel.org/linux-fsdevel/20210126233840.GG4626@dread.disaster.area/T/#m05753578c7f7882f6e9ffe01f981bc223edef2b0
+ if written == 0 {
+ return 0, false, nil
+ }
+ // Otherwise src is at EOF, which means
+ // we are done.
return written, true, nil
}
remain -= n
diff -Nru golang-1.15-1.15.9/src/internal/poll/sendfile_bsd.go golang-1.15-1.15.15/src/internal/poll/sendfile_bsd.go
--- golang-1.15-1.15.9/src/internal/poll/sendfile_bsd.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/internal/poll/sendfile_bsd.go 2021-08-05 05:20:40.000000000 +0800
@@ -18,6 +18,10 @@
return 0, err
}
defer dstFD.writeUnlock()
+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
+ return 0, err
+ }
+
dst := int(dstFD.Sysfd)
var written int64
var err error
diff -Nru golang-1.15-1.15.9/src/internal/poll/sendfile_linux.go golang-1.15-1.15.15/src/internal/poll/sendfile_linux.go
--- golang-1.15-1.15.9/src/internal/poll/sendfile_linux.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/internal/poll/sendfile_linux.go 2021-08-05 05:20:40.000000000 +0800
@@ -16,6 +16,9 @@
return 0, err
}
defer dstFD.writeUnlock()
+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
+ return 0, err
+ }
dst := int(dstFD.Sysfd)
var written int64
diff -Nru golang-1.15-1.15.9/src/internal/poll/sendfile_solaris.go golang-1.15-1.15.15/src/internal/poll/sendfile_solaris.go
--- golang-1.15-1.15.9/src/internal/poll/sendfile_solaris.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/internal/poll/sendfile_solaris.go 2021-08-05 05:20:40.000000000 +0800
@@ -20,6 +20,9 @@
return 0, err
}
defer dstFD.writeUnlock()
+ if err := dstFD.pd.prepareWrite(dstFD.isFile); err != nil {
+ return 0, err
+ }
dst := int(dstFD.Sysfd)
var written int64
diff -Nru golang-1.15-1.15.9/src/math/big/arith_s390x.s golang-1.15-1.15.15/src/math/big/arith_s390x.s
--- golang-1.15-1.15.9/src/math/big/arith_s390x.s 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/math/big/arith_s390x.s 2021-08-05 05:20:40.000000000 +0800
@@ -702,199 +702,11 @@
// func shlVU(z, x []Word, s uint) (c Word)
TEXT ·shlVU(SB), NOSPLIT, $0
- MOVD z_len+8(FP), R5
- MOVD $0, R0
- SUB $1, R5 // n--
- BLT X8b // n < 0 (n <= 0)
+ BR ·shlVU_g(SB)
- // n > 0
- MOVD s+48(FP), R4
- CMPBEQ R0, R4, Z80 // handle 0 case beq
- MOVD $64, R6
- CMPBEQ R6, R4, Z864 // handle 64 case beq
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
- SUB R4, R6, R7
- MOVD (R8)(R5*1), R10 // w1 = x[i-1]
- SRD R7, R10, R3
- MOVD R3, c+56(FP)
-
- MOVD $0, R1 // i = 0
- BR E8
-
- // i < n-1
-L8:
- MOVD R10, R3 // w = w1
- MOVD -8(R8)(R5*1), R10 // w1 = x[i+1]
-
- SLD R4, R3 // w<<s | w1>>ŝ
- SRD R7, R10, R6
- OR R6, R3
- MOVD R3, (R2)(R5*1) // z[i] = w<<s | w1>>ŝ
- SUB $8, R5 // i--
-
-E8:
- CMPBGT R5, R0, L8 // i < n-1
-
- // i >= n-1
-X8a:
- SLD R4, R10 // w1<<s
- MOVD R10, (R2) // z[0] = w1<<s
- RET
-
-X8b:
- MOVD R0, c+56(FP)
- RET
-
-Z80:
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
-
- MOVD (R8), R10
- MOVD $0, R3
- MOVD R3, c+56(FP)
-
- MOVD $0, R1 // i = 0
- BR E8Z
-
- // i < n-1
-L8Z:
- MOVD R10, R3
- MOVD 8(R8)(R1*1), R10
-
- MOVD R3, (R2)(R1*1)
- ADD $8, R1
-
-E8Z:
- CMPBLT R1, R5, L8Z
-
- // i >= n-1
- MOVD R10, (R2)(R5*1)
- RET
-
-Z864:
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
- MOVD (R8)(R5*1), R3 // w1 = x[n-1]
- MOVD R3, c+56(FP) // z[i] = x[n-1]
-
- BR E864
-
- // i < n-1
-L864:
- MOVD -8(R8)(R5*1), R3
-
- MOVD R3, (R2)(R5*1) // z[i] = x[n-1]
- SUB $8, R5 // i--
-
-E864:
- CMPBGT R5, R0, L864 // i < n-1
-
- MOVD R0, (R2) // z[n-1] = 0
- RET
-
-// CX = R4, r8 = r8, r10 = r2 , r11 = r5, DX = r3, AX = r10 , BX = R1 , 64-count = r7 (R0 set to 0) temp = R6
// func shrVU(z, x []Word, s uint) (c Word)
TEXT ·shrVU(SB), NOSPLIT, $0
- MOVD z_len+8(FP), R5
- MOVD $0, R0
- SUB $1, R5 // n--
- BLT X9b // n < 0 (n <= 0)
-
- // n > 0
- MOVD s+48(FP), R4
- CMPBEQ R0, R4, ZB0 // handle 0 case beq
- MOVD $64, R6
- CMPBEQ R6, R4, ZB64 // handle 64 case beq
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
- SUB R4, R6, R7
- MOVD (R8), R10 // w1 = x[0]
- SLD R7, R10, R3
- MOVD R3, c+56(FP)
-
- MOVD $0, R1 // i = 0
- BR E9
-
- // i < n-1
-L9:
- MOVD R10, R3 // w = w1
- MOVD 8(R8)(R1*1), R10 // w1 = x[i+1]
-
- SRD R4, R3 // w>>s | w1<<s
- SLD R7, R10, R6
- OR R6, R3
- MOVD R3, (R2)(R1*1) // z[i] = w>>s | w1<<s
- ADD $8, R1 // i++
-
-E9:
- CMPBLT R1, R5, L9 // i < n-1
-
- // i >= n-1
-X9a:
- SRD R4, R10 // w1>>s
- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s
- RET
-
-X9b:
- MOVD R0, c+56(FP)
- RET
-
-ZB0:
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
-
- MOVD (R8), R10 // w1 = x[0]
- MOVD $0, R3 // R10 << 64
- MOVD R3, c+56(FP)
-
- MOVD $0, R1 // i = 0
- BR E9Z
-
- // i < n-1
-L9Z:
- MOVD R10, R3 // w = w1
- MOVD 8(R8)(R1*1), R10 // w1 = x[i+1]
-
- MOVD R3, (R2)(R1*1) // z[i] = w>>s | w1<<s
- ADD $8, R1 // i++
-
-E9Z:
- CMPBLT R1, R5, L9Z // i < n-1
-
- // i >= n-1
- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s
- RET
-
-ZB64:
- MOVD z+0(FP), R2
- MOVD x+24(FP), R8
- SLD $3, R5 // n = n*8
- MOVD (R8), R3 // w1 = x[0]
- MOVD R3, c+56(FP)
-
- MOVD $0, R1 // i = 0
- BR E964
-
- // i < n-1
-L964:
- MOVD 8(R8)(R1*1), R3 // w1 = x[i+1]
-
- MOVD R3, (R2)(R1*1) // z[i] = w>>s | w1<<s
- ADD $8, R1 // i++
-
-E964:
- CMPBLT R1, R5, L964 // i < n-1
-
- // i >= n-1
- MOVD $0, R10 // w1>>s
- MOVD R10, (R2)(R5*1) // z[n-1] = w1>>s
- RET
+ BR ·shrVU_g(SB)
// CX = R4, r8 = r8, r9=r9, r10 = r2 , r11 = r5, DX = r3, AX = r6 , BX = R1 , (R0 set to 0) + use R11 + use R7 for i
// func mulAddVWW(z, x []Word, y, r Word) (c Word)
diff -Nru golang-1.15-1.15.9/src/math/big/arith_test.go golang-1.15-1.15.15/src/math/big/arith_test.go
--- golang-1.15-1.15.9/src/math/big/arith_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/math/big/arith_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -224,13 +224,36 @@
m string // message.
}
+var argshlVUIn = []Word{1, 2, 4, 8, 16, 32, 64, 0, 0, 0}
+var argshlVUr0 = []Word{1, 2, 4, 8, 16, 32, 64}
+var argshlVUr1 = []Word{2, 4, 8, 16, 32, 64, 128}
+var argshlVUrWm1 = []Word{1 << (_W - 1), 0, 1, 2, 4, 8, 16}
+
var argshlVU = []argVU{
// test cases for shlVU
{[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0}, 7, 0, 0, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "complete overlap of shlVU"},
{[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0}, 7, 0, 3, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "partial overlap by half of shlVU"},
{[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0, 0, 0, 0}, 7, 0, 6, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "partial overlap by 1 Word of shlVU"},
{[]Word{1, _M, _M, _M, _M, _M, 3 << (_W - 2), 0, 0, 0, 0, 0, 0, 0, 0}, 7, 0, 7, 1, []Word{2, _M - 1, _M, _M, _M, _M, 1<<(_W-1) + 1}, 1, "no overlap of shlVU"},
-}
+ // additional test cases with shift values of 0, 1 and (_W-1)
+ {argshlVUIn, 7, 0, 0, 0, argshlVUr0, 0, "complete overlap of shlVU and shift of 0"},
+ {argshlVUIn, 7, 0, 0, 1, argshlVUr1, 0, "complete overlap of shlVU and shift of 1"},
+ {argshlVUIn, 7, 0, 0, _W - 1, argshlVUrWm1, 32, "complete overlap of shlVU and shift of _W - 1"},
+ {argshlVUIn, 7, 0, 1, 0, argshlVUr0, 0, "partial overlap by 6 Words of shlVU and shift of 0"},
+ {argshlVUIn, 7, 0, 1, 1, argshlVUr1, 0, "partial overlap by 6 Words of shlVU and shift of 1"},
+ {argshlVUIn, 7, 0, 1, _W - 1, argshlVUrWm1, 32, "partial overlap by 6 Words of shlVU and shift of _W - 1"},
+ {argshlVUIn, 7, 0, 2, 0, argshlVUr0, 0, "partial overlap by 5 Words of shlVU and shift of 0"},
+ {argshlVUIn, 7, 0, 2, 1, argshlVUr1, 0, "partial overlap by 5 Words of shlVU and shift of 1"},
+ {argshlVUIn, 7, 0, 2, _W - 1, argshlVUrWm1, 32, "partial overlap by 5 Words of shlVU abd shift of _W - 1"},
+ {argshlVUIn, 7, 0, 3, 0, argshlVUr0, 0, "partial overlap by 4 Words of shlVU and shift of 0"},
+ {argshlVUIn, 7, 0, 3, 1, argshlVUr1, 0, "partial overlap by 4 Words of shlVU and shift of 1"},
+ {argshlVUIn, 7, 0, 3, _W - 1, argshlVUrWm1, 32, "partial overlap by 4 Words of shlVU and shift of _W - 1"},
+}
+
+var argshrVUIn = []Word{0, 0, 0, 1, 2, 4, 8, 16, 32, 64}
+var argshrVUr0 = []Word{1, 2, 4, 8, 16, 32, 64}
+var argshrVUr1 = []Word{0, 1, 2, 4, 8, 16, 32}
+var argshrVUrWm1 = []Word{4, 8, 16, 32, 64, 128, 0}
var argshrVU = []argVU{
// test cases for shrVU
@@ -238,23 +261,36 @@
{[]Word{0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 4, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "partial overlap by half of shrVU"},
{[]Word{0, 0, 0, 0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 7, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "partial overlap by 1 Word of shrVU"},
{[]Word{0, 0, 0, 0, 0, 0, 0, 0, 3, _M, _M, _M, _M, _M, 1 << (_W - 1)}, 7, 8, 1, 1, []Word{1<<(_W-1) + 1, _M, _M, _M, _M, _M >> 1, 1 << (_W - 2)}, 1 << (_W - 1), "no overlap of shrVU"},
+ // additional test cases with shift values of 0, 1 and (_W-1)
+ {argshrVUIn, 7, 3, 3, 0, argshrVUr0, 0, "complete overlap of shrVU and shift of 0"},
+ {argshrVUIn, 7, 3, 3, 1, argshrVUr1, 1 << (_W - 1), "complete overlap of shrVU and shift of 1"},
+ {argshrVUIn, 7, 3, 3, _W - 1, argshrVUrWm1, 2, "complete overlap of shrVU and shift of _W - 1"},
+ {argshrVUIn, 7, 3, 2, 0, argshrVUr0, 0, "partial overlap by 6 Words of shrVU and shift of 0"},
+ {argshrVUIn, 7, 3, 2, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 6 Words of shrVU and shift of 1"},
+ {argshrVUIn, 7, 3, 2, _W - 1, argshrVUrWm1, 2, "partial overlap by 6 Words of shrVU and shift of _W - 1"},
+ {argshrVUIn, 7, 3, 1, 0, argshrVUr0, 0, "partial overlap by 5 Words of shrVU and shift of 0"},
+ {argshrVUIn, 7, 3, 1, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 5 Words of shrVU and shift of 1"},
+ {argshrVUIn, 7, 3, 1, _W - 1, argshrVUrWm1, 2, "partial overlap by 5 Words of shrVU and shift of _W - 1"},
+ {argshrVUIn, 7, 3, 0, 0, argshrVUr0, 0, "partial overlap by 4 Words of shrVU and shift of 0"},
+ {argshrVUIn, 7, 3, 0, 1, argshrVUr1, 1 << (_W - 1), "partial overlap by 4 Words of shrVU and shift of 1"},
+ {argshrVUIn, 7, 3, 0, _W - 1, argshrVUrWm1, 2, "partial overlap by 4 Words of shrVU and shift of _W - 1"},
}
func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) {
- // save a.d for error message, or it will be overwritten.
+ // work on copy of a.d to preserve the original data.
b := make([]Word, len(a.d))
copy(b, a.d)
- z := a.d[a.zp : a.zp+a.l]
- x := a.d[a.xp : a.xp+a.l]
+ z := b[a.zp : a.zp+a.l]
+ x := b[a.xp : a.xp+a.l]
c := f(z, x, a.s)
for i, zi := range z {
if zi != a.r[i] {
- t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i])
+ t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i])
break
}
}
if c != a.c {
- t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c)
+ t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c)
}
}
@@ -274,11 +310,24 @@
// compute 10^n via 5^n << n.
const n = 165
p := nat(nil).expNN(nat{5}, nat{n}, nil)
- p = p.shl(p, uint(n))
+ p = p.shl(p, n)
got := string(p.utoa(10))
want := "1" + strings.Repeat("0", n)
if got != want {
- t.Errorf("shl(%v, %v)\n\tgot %s; want %s\n", p, uint(n), got, want)
+ t.Errorf("shl(%v, %v)\n\tgot %s\n\twant %s", p, n, got, want)
+ }
+}
+
+const issue42838Value = "159309191113245227702888039776771180559110455519261878607388585338616290151305816094308987472018268594098344692611135542392730712890625"
+
+func TestIssue42838(t *testing.T) {
+ const s = 192
+ z, _, _, _ := nat(nil).scan(strings.NewReader(issue42838Value), 0, false)
+ z = z.shl(z, s)
+ got := string(z.utoa(10))
+ want := "1" + strings.Repeat("0", s)
+ if got != want {
+ t.Errorf("shl(%v, %v)\n\tgot %s\n\twant %s", z, s, got, want)
}
}
diff -Nru golang-1.15-1.15.9/src/math/big/ratconv.go golang-1.15-1.15.15/src/math/big/ratconv.go
--- golang-1.15-1.15.9/src/math/big/ratconv.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/math/big/ratconv.go 2021-08-05 05:20:40.000000000 +0800
@@ -51,7 +51,8 @@
// An optional base-10 ``e'' or base-2 ``p'' (or their upper-case variants)
// exponent may be provided as well, except for hexadecimal floats which
// only accept an (optional) ``p'' exponent (because an ``e'' or ``E'' cannot
-// be distinguished from a mantissa digit).
+// be distinguished from a mantissa digit). If the exponent's absolute value
+// is too large, the operation may fail.
// The entire string, not just a prefix, must be valid for success. If the
// operation failed, the value of z is undefined but the returned value is nil.
func (z *Rat) SetString(s string) (*Rat, bool) {
@@ -169,6 +170,9 @@
if n < 0 {
n = -n
}
+ if n > 1e6 {
+ return nil, false // avoid excessively large exponents
+ }
pow5 := z.b.abs.expNN(natFive, nat(nil).setWord(Word(n)), nil) // use underlying array of z.b.abs
if exp5 > 0 {
z.a.abs = z.a.abs.mul(z.a.abs, pow5)
@@ -181,15 +185,12 @@
}
// apply exp2 contributions
+ if exp2 < -1e7 || exp2 > 1e7 {
+ return nil, false // avoid excessively large exponents
+ }
if exp2 > 0 {
- if int64(uint(exp2)) != exp2 {
- panic("exponent too large")
- }
z.a.abs = z.a.abs.shl(z.a.abs, uint(exp2))
} else if exp2 < 0 {
- if int64(uint(-exp2)) != -exp2 {
- panic("exponent too large")
- }
z.b.abs = z.b.abs.shl(z.b.abs, uint(-exp2))
}
diff -Nru golang-1.15-1.15.9/src/math/big/ratconv_test.go golang-1.15-1.15.15/src/math/big/ratconv_test.go
--- golang-1.15-1.15.9/src/math/big/ratconv_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/math/big/ratconv_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -589,3 +589,28 @@
}
}
}
+
+func TestIssue45910(t *testing.T) {
+ var x Rat
+ for _, test := range []struct {
+ input string
+ want bool
+ }{
+ {"1e-1000001", false},
+ {"1e-1000000", true},
+ {"1e+1000000", true},
+ {"1e+1000001", false},
+
+ {"0p1000000000000", true},
+ {"1p-10000001", false},
+ {"1p-10000000", true},
+ {"1p+10000000", true},
+ {"1p+10000001", false},
+ {"1.770p02041010010011001001", false}, // test case from issue
+ } {
+ _, got := x.SetString(test.input)
+ if got != test.want {
+ t.Errorf("SetString(%s) got ok = %v; want %v", test.input, got, test.want)
+ }
+ }
+}
diff -Nru golang-1.15-1.15.9/src/net/dnsclient_unix_test.go golang-1.15-1.15.15/src/net/dnsclient_unix_test.go
--- golang-1.15-1.15.9/src/net/dnsclient_unix_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/dnsclient_unix_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -1799,3 +1799,324 @@
t.Errorf("names = %q; want %q", names, want)
}
}
+
+func TestCVE202133195(t *testing.T) {
+ fake := fakeDNSServer{
+ rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
+ r := dnsmessage.Message{
+ Header: dnsmessage.Header{
+ ID: q.Header.ID,
+ Response: true,
+ RCode: dnsmessage.RCodeSuccess,
+ RecursionAvailable: true,
+ },
+ Questions: q.Questions,
+ }
+ switch q.Questions[0].Type {
+ case dnsmessage.TypeCNAME:
+ r.Answers = []dnsmessage.Resource{}
+ case dnsmessage.TypeA: // CNAME lookup uses a A/AAAA as a proxy
+ r.Answers = append(r.Answers,
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
+ Type: dnsmessage.TypeA,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.AResource{
+ A: TestAddr,
+ },
+ },
+ )
+ case dnsmessage.TypeSRV:
+ n := q.Questions[0].Name
+ if n.String() == "_hdr._tcp.golang.org." {
+ n = dnsmessage.MustNewName("<html>.golang.org.")
+ }
+ r.Answers = append(r.Answers,
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: n,
+ Type: dnsmessage.TypeSRV,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.SRVResource{
+ Target: dnsmessage.MustNewName("<html>.golang.org."),
+ },
+ },
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: n,
+ Type: dnsmessage.TypeSRV,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.SRVResource{
+ Target: dnsmessage.MustNewName("good.golang.org."),
+ },
+ },
+ )
+ case dnsmessage.TypeMX:
+ r.Answers = append(r.Answers,
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
+ Type: dnsmessage.TypeMX,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.MXResource{
+ MX: dnsmessage.MustNewName("<html>.golang.org."),
+ },
+ },
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("good.golang.org."),
+ Type: dnsmessage.TypeMX,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.MXResource{
+ MX: dnsmessage.MustNewName("good.golang.org."),
+ },
+ },
+ )
+ case dnsmessage.TypeNS:
+ r.Answers = append(r.Answers,
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
+ Type: dnsmessage.TypeNS,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.NSResource{
+ NS: dnsmessage.MustNewName("<html>.golang.org."),
+ },
+ },
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("good.golang.org."),
+ Type: dnsmessage.TypeNS,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.NSResource{
+ NS: dnsmessage.MustNewName("good.golang.org."),
+ },
+ },
+ )
+ case dnsmessage.TypePTR:
+ r.Answers = append(r.Answers,
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
+ Type: dnsmessage.TypePTR,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.PTRResource{
+ PTR: dnsmessage.MustNewName("<html>.golang.org."),
+ },
+ },
+ dnsmessage.Resource{
+ Header: dnsmessage.ResourceHeader{
+ Name: dnsmessage.MustNewName("good.golang.org."),
+ Type: dnsmessage.TypePTR,
+ Class: dnsmessage.ClassINET,
+ Length: 4,
+ },
+ Body: &dnsmessage.PTRResource{
+ PTR: dnsmessage.MustNewName("good.golang.org."),
+ },
+ },
+ )
+ }
+ return r, nil
+ },
+ }
+
+ r := Resolver{PreferGo: true, Dial: fake.DialContext}
+ // Change the default resolver to match our manipulated resolver
+ originalDefault := DefaultResolver
+ DefaultResolver = &r
+ defer func() { DefaultResolver = originalDefault }()
+ // Redirect host file lookups.
+ defer func(orig string) { testHookHostsPath = orig }(testHookHostsPath)
+ testHookHostsPath = "testdata/hosts"
+
+ tests := []struct {
+ name string
+ f func(*testing.T)
+ }{
+ {
+ name: "CNAME",
+ f: func(t *testing.T) {
+ expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
+ _, err := r.LookupCNAME(context.Background(), "golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ _, err = LookupCNAME("golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ },
+ },
+ {
+ name: "SRV (bad record)",
+ f: func(t *testing.T) {
+ expected := []*SRV{
+ {
+ Target: "good.golang.org.",
+ },
+ }
+ expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
+ _, records, err := r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ _, records, err = LookupSRV("target", "tcp", "golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Errorf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ },
+ },
+ {
+ name: "SRV (bad header)",
+ f: func(t *testing.T) {
+ _, _, err := r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org.")
+ if expected := "lookup golang.org.: SRV header name is invalid"; err == nil || err.Error() != expected {
+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err, expected)
+ }
+ _, _, err = LookupSRV("hdr", "tcp", "golang.org.")
+ if expected := "lookup golang.org.: SRV header name is invalid"; err == nil || err.Error() != expected {
+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err, expected)
+ }
+ },
+ },
+ {
+ name: "MX",
+ f: func(t *testing.T) {
+ expected := []*MX{
+ {
+ Host: "good.golang.org.",
+ },
+ }
+ expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
+ records, err := r.LookupMX(context.Background(), "golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ records, err = LookupMX("golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ },
+ },
+ {
+ name: "NS",
+ f: func(t *testing.T) {
+ expected := []*NS{
+ {
+ Host: "good.golang.org.",
+ },
+ }
+ expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "golang.org"}
+ records, err := r.LookupNS(context.Background(), "golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ records, err = LookupNS("golang.org")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ },
+ },
+ {
+ name: "Addr",
+ f: func(t *testing.T) {
+ expected := []string{"good.golang.org."}
+ expectedErr := &DNSError{Err: errMalformedDNSRecordsDetail, Name: "192.0.2.42"}
+ records, err := r.LookupAddr(context.Background(), "192.0.2.42")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ records, err = LookupAddr("192.0.2.42")
+ if err.Error() != expectedErr.Error() {
+ t.Fatalf("unexpected error: %s", err)
+ }
+ if !reflect.DeepEqual(records, expected) {
+ t.Error("Unexpected record set")
+ }
+ },
+ },
+ }
+
+ for _, tc := range tests {
+ t.Run(tc.name, tc.f)
+ }
+}
+
+func TestNullMX(t *testing.T) {
+ fake := fakeDNSServer{
+ rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
+ r := dnsmessage.Message{
+ Header: dnsmessage.Header{
+ ID: q.Header.ID,
+ Response: true,
+ RCode: dnsmessage.RCodeSuccess,
+ },
+ Questions: q.Questions,
+ Answers: []dnsmessage.Resource{
+ {
+ Header: dnsmessage.ResourceHeader{
+ Name: q.Questions[0].Name,
+ Type: dnsmessage.TypeMX,
+ Class: dnsmessage.ClassINET,
+ },
+ Body: &dnsmessage.MXResource{
+ MX: dnsmessage.MustNewName("."),
+ },
+ },
+ },
+ }
+ return r, nil
+ },
+ }
+ r := Resolver{PreferGo: true, Dial: fake.DialContext}
+ rrset, err := r.LookupMX(context.Background(), "golang.org")
+ if err != nil {
+ t.Fatalf("LookupMX: %v", err)
+ }
+ if want := []*MX{&MX{Host: "."}}; !reflect.DeepEqual(rrset, want) {
+ records := []string{}
+ for _, rr := range rrset {
+ records = append(records, fmt.Sprintf("%v", rr))
+ }
+ t.Errorf("records = [%v]; want [%v]", strings.Join(records, " "), want[0])
+ }
+}
diff -Nru golang-1.15-1.15.9/src/net/http/h2_bundle.go golang-1.15-1.15.15/src/net/http/h2_bundle.go
--- golang-1.15-1.15.9/src/net/http/h2_bundle.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/h2_bundle.go 2021-08-05 05:20:40.000000000 +0800
@@ -8985,6 +8985,8 @@
type http2erringRoundTripper struct{ err error }
+func (rt http2erringRoundTripper) RoundTripErr() error { return rt.err }
+
func (rt http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { return nil, rt.err }
// gzipReader wraps a response body so it can lazily
diff -Nru golang-1.15-1.15.9/src/net/http/httputil/reverseproxy.go golang-1.15-1.15.15/src/net/http/httputil/reverseproxy.go
--- golang-1.15-1.15.9/src/net/http/httputil/reverseproxy.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/httputil/reverseproxy.go 2021-08-05 05:20:40.000000000 +0800
@@ -234,6 +234,15 @@
if req.ContentLength == 0 {
outreq.Body = nil // Issue 16036: nil Body for http.Transport retries
}
+ if outreq.Body != nil {
+ // Reading from the request body after returning from a handler is not
+ // allowed, and the RoundTrip goroutine that reads the Body can outlive
+ // this handler. This can lead to a crash if the handler panics (see
+ // Issue 46866). Although calling Close doesn't guarantee there isn't
+ // any Read in flight after the handle returns, in practice it's safe to
+ // read after closing it.
+ defer outreq.Body.Close()
+ }
if outreq.Header == nil {
outreq.Header = make(http.Header) // Issue 33142: historical behavior was to always allocate
}
@@ -248,22 +257,18 @@
// important is "Connection" because we want a persistent
// connection, regardless of what the client sent to us.
for _, h := range hopHeaders {
- hv := outreq.Header.Get(h)
- if hv == "" {
- continue
- }
- if h == "Te" && hv == "trailers" {
- // Issue 21096: tell backend applications that
- // care about trailer support that we support
- // trailers. (We do, but we don't go out of
- // our way to advertise that unless the
- // incoming client request thought it was
- // worth mentioning)
- continue
- }
outreq.Header.Del(h)
}
+ // Issue 21096: tell backend applications that care about trailer support
+ // that we support trailers. (We do, but we don't go out of our way to
+ // advertise that unless the incoming client request thought it was worth
+ // mentioning.) Note that we look at req.Header, not outreq.Header, since
+ // the latter has passed through removeConnectionHeaders.
+ if httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") {
+ outreq.Header.Set("Te", "trailers")
+ }
+
// After stripping all the hop-by-hop connection headers above, add back any
// necessary for protocol upgrades, such as for websockets.
if reqUpType != "" {
diff -Nru golang-1.15-1.15.9/src/net/http/httputil/reverseproxy_test.go golang-1.15-1.15.15/src/net/http/httputil/reverseproxy_test.go
--- golang-1.15-1.15.9/src/net/http/httputil/reverseproxy_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/httputil/reverseproxy_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -91,8 +91,9 @@
getReq, _ := http.NewRequest("GET", frontend.URL, nil)
getReq.Host = "some-name"
- getReq.Header.Set("Connection", "close")
- getReq.Header.Set("Te", "trailers")
+ getReq.Header.Set("Connection", "close, TE")
+ getReq.Header.Add("Te", "foo")
+ getReq.Header.Add("Te", "bar, trailers")
getReq.Header.Set("Proxy-Connection", "should be deleted")
getReq.Header.Set("Upgrade", "foo")
getReq.Close = true
@@ -236,6 +237,64 @@
}
}
+func TestReverseProxyStripEmptyConnection(t *testing.T) {
+ // See Issue 46313.
+ const backendResponse = "I am the backend"
+
+ // someConnHeader is some arbitrary header to be declared as a hop-by-hop header
+ // in the Request's Connection header.
+ const someConnHeader = "X-Some-Conn-Header"
+
+ backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ if c := r.Header.Values("Connection"); len(c) != 0 {
+ t.Errorf("handler got header %q = %v; want empty", "Connection", c)
+ }
+ if c := r.Header.Get(someConnHeader); c != "" {
+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
+ }
+ w.Header().Add("Connection", "")
+ w.Header().Add("Connection", someConnHeader)
+ w.Header().Set(someConnHeader, "should be deleted")
+ io.WriteString(w, backendResponse)
+ }))
+ defer backend.Close()
+ backendURL, err := url.Parse(backend.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ proxyHandler := NewSingleHostReverseProxy(backendURL)
+ frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ proxyHandler.ServeHTTP(w, r)
+ if c := r.Header.Get(someConnHeader); c != "should be deleted" {
+ t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted")
+ }
+ }))
+ defer frontend.Close()
+
+ getReq, _ := http.NewRequest("GET", frontend.URL, nil)
+ getReq.Header.Add("Connection", "")
+ getReq.Header.Add("Connection", someConnHeader)
+ getReq.Header.Set(someConnHeader, "should be deleted")
+ res, err := frontend.Client().Do(getReq)
+ if err != nil {
+ t.Fatalf("Get: %v", err)
+ }
+ defer res.Body.Close()
+ bodyBytes, err := ioutil.ReadAll(res.Body)
+ if err != nil {
+ t.Fatalf("reading body: %v", err)
+ }
+ if got, want := string(bodyBytes), backendResponse; got != want {
+ t.Errorf("got body %q; want %q", got, want)
+ }
+ if c := res.Header.Get("Connection"); c != "" {
+ t.Errorf("handler got header %q = %q; want empty", "Connection", c)
+ }
+ if c := res.Header.Get(someConnHeader); c != "" {
+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
+ }
+}
+
func TestXForwardedFor(t *testing.T) {
const prevForwardedFor = "client ip"
const backendResponse = "I am the backend"
@@ -1063,6 +1122,45 @@
rproxy.ServeHTTP(httptest.NewRecorder(), req)
}
+// Issue #46866: panic without closing incoming request body causes a panic
+func TestReverseProxy_PanicClosesIncomingBody(t *testing.T) {
+ backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ out := "this call was relayed by the reverse proxy"
+ // Coerce a wrong content length to induce io.ErrUnexpectedEOF
+ w.Header().Set("Content-Length", fmt.Sprintf("%d", len(out)*2))
+ fmt.Fprintln(w, out)
+ }))
+ defer backend.Close()
+ backendURL, err := url.Parse(backend.URL)
+ if err != nil {
+ t.Fatal(err)
+ }
+ proxyHandler := NewSingleHostReverseProxy(backendURL)
+ proxyHandler.ErrorLog = log.New(ioutil.Discard, "", 0) // quiet for tests
+ frontend := httptest.NewServer(proxyHandler)
+ defer frontend.Close()
+ frontendClient := frontend.Client()
+
+ var wg sync.WaitGroup
+ for i := 0; i < 2; i++ {
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ for j := 0; j < 10; j++ {
+ const reqLen = 6 * 1024 * 1024
+ req, _ := http.NewRequest("POST", frontend.URL, &io.LimitedReader{R: neverEnding('x'), N: reqLen})
+ req.ContentLength = reqLen
+ resp, _ := frontendClient.Transport.RoundTrip(req)
+ if resp != nil {
+ io.Copy(ioutil.Discard, resp.Body)
+ resp.Body.Close()
+ }
+ }
+ }()
+ }
+ wg.Wait()
+}
+
func TestSelectFlushInterval(t *testing.T) {
tests := []struct {
name string
diff -Nru golang-1.15-1.15.9/src/net/http/omithttp2.go golang-1.15-1.15.15/src/net/http/omithttp2.go
--- golang-1.15-1.15.9/src/net/http/omithttp2.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/omithttp2.go 2021-08-05 05:20:40.000000000 +0800
@@ -32,10 +32,6 @@
func (*http2Transport) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
func (*http2Transport) CloseIdleConnections() {}
-type http2erringRoundTripper struct{ err error }
-
-func (http2erringRoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
-
type http2noDialH2RoundTripper struct{}
func (http2noDialH2RoundTripper) RoundTrip(*Request) (*Response, error) { panic(noHTTP2) }
diff -Nru golang-1.15-1.15.9/src/net/http/transport.go golang-1.15-1.15.15/src/net/http/transport.go
--- golang-1.15-1.15.9/src/net/http/transport.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/transport.go 2021-08-05 05:20:40.000000000 +0800
@@ -766,7 +766,8 @@
}
// Cancel an in-flight request, recording the error value.
-func (t *Transport) cancelRequest(key cancelKey, err error) {
+// Returns whether the request was canceled.
+func (t *Transport) cancelRequest(key cancelKey, err error) bool {
t.reqMu.Lock()
cancel := t.reqCanceler[key]
delete(t.reqCanceler, key)
@@ -774,6 +775,8 @@
if cancel != nil {
cancel(err)
}
+
+ return cancel != nil
}
//
@@ -1528,6 +1531,10 @@
return nil
}
+type erringRoundTripper interface {
+ RoundTripErr() error
+}
+
func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *persistConn, err error) {
pconn = &persistConn{
t: t,
@@ -1694,9 +1701,9 @@
if s := pconn.tlsState; s != nil && s.NegotiatedProtocolIsMutual && s.NegotiatedProtocol != "" {
if next, ok := t.TLSNextProto[s.NegotiatedProtocol]; ok {
alt := next(cm.targetAddr, pconn.conn.(*tls.Conn))
- if e, ok := alt.(http2erringRoundTripper); ok {
+ if e, ok := alt.(erringRoundTripper); ok {
// pconn.conn was closed by next (http2configureTransport.upgradeFn).
- return nil, e.err
+ return nil, e.RoundTripErr()
}
return &persistConn{t: t, cacheKey: pconn.cacheKey, alt: alt}, nil
}
@@ -2087,18 +2094,17 @@
}
if !hasBody || bodyWritable {
- pc.t.setReqCanceler(rc.cancelKey, nil)
+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil)
// Put the idle conn back into the pool before we send the response
// so if they process it quickly and make another request, they'll
// get this same conn. But we use the unbuffered channel 'rc'
// to guarantee that persistConn.roundTrip got out of its select
// potentially waiting for this persistConn to close.
- // but after
alive = alive &&
!pc.sawEOF &&
pc.wroteRequest() &&
- tryPutIdleConn(trace)
+ replaced && tryPutIdleConn(trace)
if bodyWritable {
closeErr = errCallerOwnsConn
@@ -2160,12 +2166,12 @@
// reading the response body. (or for cancellation or death)
select {
case bodyEOF := <-waitForBodyRead:
- pc.t.setReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool
+ replaced := pc.t.replaceReqCanceler(rc.cancelKey, nil) // before pc might return to idle pool
alive = alive &&
bodyEOF &&
!pc.sawEOF &&
pc.wroteRequest() &&
- tryPutIdleConn(trace)
+ replaced && tryPutIdleConn(trace)
if bodyEOF {
eofc <- struct{}{}
}
@@ -2560,6 +2566,8 @@
var respHeaderTimer <-chan time.Time
cancelChan := req.Request.Cancel
ctxDoneChan := req.Context().Done()
+ pcClosed := pc.closech
+ canceled := false
for {
testHookWaitResLoop()
select {
@@ -2579,11 +2587,14 @@
defer timer.Stop() // prevent leaks
respHeaderTimer = timer.C
}
- case <-pc.closech:
- if debugRoundTrip {
- req.logf("closech recv: %T %#v", pc.closed, pc.closed)
+ case <-pcClosed:
+ pcClosed = nil
+ if canceled || pc.t.replaceReqCanceler(req.cancelKey, nil) {
+ if debugRoundTrip {
+ req.logf("closech recv: %T %#v", pc.closed, pc.closed)
+ }
+ return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed)
}
- return nil, pc.mapRoundTripError(req, startBytesWritten, pc.closed)
case <-respHeaderTimer:
if debugRoundTrip {
req.logf("timeout waiting for response headers.")
@@ -2602,10 +2613,10 @@
}
return re.res, nil
case <-cancelChan:
- pc.t.cancelRequest(req.cancelKey, errRequestCanceled)
+ canceled = pc.t.cancelRequest(req.cancelKey, errRequestCanceled)
cancelChan = nil
case <-ctxDoneChan:
- pc.t.cancelRequest(req.cancelKey, req.Context().Err())
+ canceled = pc.t.cancelRequest(req.cancelKey, req.Context().Err())
cancelChan = nil
ctxDoneChan = nil
}
diff -Nru golang-1.15-1.15.9/src/net/http/transport_test.go golang-1.15-1.15.15/src/net/http/transport_test.go
--- golang-1.15-1.15.9/src/net/http/transport_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/http/transport_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -5270,7 +5270,6 @@
ln := newLocalListener(t)
addr := ln.Addr().String()
- shutdown := make(chan bool, 1)
done := make(chan bool)
fullAddrURL := fmt.Sprintf("http://%s", addr)
raw := "HTTP/1.1 400\r\n" +
@@ -5282,10 +5281,7 @@
"Aloha Olaa"
go func() {
- defer func() {
- ln.Close()
- close(done)
- }()
+ defer close(done)
conn, _ := ln.Accept()
if conn != nil {
@@ -5316,7 +5312,7 @@
t.Errorf("got=%v want=%q", err, want)
}
- close(shutdown)
+ ln.Close()
<-done
}
@@ -6289,3 +6285,79 @@
t.Fatalf("Error mismatch\nGot: %q\nWanted substring: %q", got, want)
}
}
+
+// Issue 41600
+// Test that a new request which uses the connection of an active request
+// cannot cause it to be canceled as well.
+func TestCancelRequestWhenSharingConnection(t *testing.T) {
+ reqc := make(chan chan struct{}, 2)
+ ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, req *Request) {
+ ch := make(chan struct{}, 1)
+ reqc <- ch
+ <-ch
+ w.Header().Add("Content-Length", "0")
+ }))
+ defer ts.Close()
+
+ client := ts.Client()
+ transport := client.Transport.(*Transport)
+ transport.MaxIdleConns = 1
+ transport.MaxConnsPerHost = 1
+
+ var wg sync.WaitGroup
+
+ wg.Add(1)
+ putidlec := make(chan chan struct{})
+ go func() {
+ defer wg.Done()
+ ctx := httptrace.WithClientTrace(context.Background(), &httptrace.ClientTrace{
+ PutIdleConn: func(error) {
+ // Signal that the idle conn has been returned to the pool,
+ // and wait for the order to proceed.
+ ch := make(chan struct{})
+ putidlec <- ch
+ <-ch
+ },
+ })
+ req, _ := NewRequestWithContext(ctx, "GET", ts.URL, nil)
+ res, err := client.Do(req)
+ if err == nil {
+ res.Body.Close()
+ }
+ if err != nil {
+ t.Errorf("request 1: got err %v, want nil", err)
+ }
+ }()
+
+ // Wait for the first request to receive a response and return the
+ // connection to the idle pool.
+ r1c := <-reqc
+ close(r1c)
+ idlec := <-putidlec
+
+ wg.Add(1)
+ cancelctx, cancel := context.WithCancel(context.Background())
+ go func() {
+ defer wg.Done()
+ req, _ := NewRequestWithContext(cancelctx, "GET", ts.URL, nil)
+ res, err := client.Do(req)
+ if err == nil {
+ res.Body.Close()
+ }
+ if !errors.Is(err, context.Canceled) {
+ t.Errorf("request 2: got err %v, want Canceled", err)
+ }
+ }()
+
+ // Wait for the second request to arrive at the server, and then cancel
+ // the request context.
+ r2c := <-reqc
+ cancel()
+
+ // Give the cancelation a moment to take effect, and then unblock the first request.
+ time.Sleep(1 * time.Millisecond)
+ close(idlec)
+
+ close(r2c)
+ wg.Wait()
+}
diff -Nru golang-1.15-1.15.9/src/net/lookup.go golang-1.15-1.15.15/src/net/lookup.go
--- golang-1.15-1.15.9/src/net/lookup.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/lookup.go 2021-08-05 05:20:40.000000000 +0800
@@ -389,8 +389,11 @@
// LookupCNAME does not return an error if host does not
// contain DNS "CNAME" records, as long as host resolves to
// address records.
+//
+// The returned canonical name is validated to be a properly
+// formatted presentation-format domain name.
func LookupCNAME(host string) (cname string, err error) {
- return DefaultResolver.lookupCNAME(context.Background(), host)
+ return DefaultResolver.LookupCNAME(context.Background(), host)
}
// LookupCNAME returns the canonical name for the given host.
@@ -403,8 +406,18 @@
// LookupCNAME does not return an error if host does not
// contain DNS "CNAME" records, as long as host resolves to
// address records.
-func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string, err error) {
- return r.lookupCNAME(ctx, host)
+//
+// The returned canonical name is validated to be a properly
+// formatted presentation-format domain name.
+func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error) {
+ cname, err := r.lookupCNAME(ctx, host)
+ if err != nil {
+ return "", err
+ }
+ if !isDomainName(cname) {
+ return "", &DNSError{Err: errMalformedDNSRecordsDetail, Name: host}
+ }
+ return cname, nil
}
// LookupSRV tries to resolve an SRV query of the given service,
@@ -416,8 +429,13 @@
// That is, it looks up _service._proto.name. To accommodate services
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
+//
+// The returned service names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) {
- return DefaultResolver.lookupSRV(context.Background(), service, proto, name)
+ return DefaultResolver.LookupSRV(context.Background(), service, proto, name)
}
// LookupSRV tries to resolve an SRV query of the given service,
@@ -429,28 +447,115 @@
// That is, it looks up _service._proto.name. To accommodate services
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
-func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error) {
- return r.lookupSRV(ctx, service, proto, name)
+//
+// The returned service names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
+func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) {
+ cname, addrs, err := r.lookupSRV(ctx, service, proto, name)
+ if err != nil {
+ return "", nil, err
+ }
+ if cname != "" && !isDomainName(cname) {
+ return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name}
+ }
+ filteredAddrs := make([]*SRV, 0, len(addrs))
+ for _, addr := range addrs {
+ if addr == nil {
+ continue
+ }
+ if !isDomainName(addr.Target) {
+ continue
+ }
+ filteredAddrs = append(filteredAddrs, addr)
+ }
+ if len(addrs) != len(filteredAddrs) {
+ return cname, filteredAddrs, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
+ }
+ return cname, filteredAddrs, nil
}
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
+//
+// The returned mail server names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
+//
+// LookupMX uses context.Background internally; to specify the context, use
+// Resolver.LookupMX.
func LookupMX(name string) ([]*MX, error) {
- return DefaultResolver.lookupMX(context.Background(), name)
+ return DefaultResolver.LookupMX(context.Background(), name)
}
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
+//
+// The returned mail server names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
- return r.lookupMX(ctx, name)
+ records, err := r.lookupMX(ctx, name)
+ if err != nil {
+ return nil, err
+ }
+ filteredMX := make([]*MX, 0, len(records))
+ for _, mx := range records {
+ if mx == nil {
+ continue
+ }
+ // Bypass the hostname validity check for targets which contain only a dot,
+ // as this is used to represent a 'Null' MX record.
+ if mx.Host != "." && !isDomainName(mx.Host) {
+ continue
+ }
+ filteredMX = append(filteredMX, mx)
+ }
+ if len(records) != len(filteredMX) {
+ return filteredMX, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
+ }
+ return filteredMX, nil
}
// LookupNS returns the DNS NS records for the given domain name.
+//
+// The returned name server names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
+//
+// LookupNS uses context.Background internally; to specify the context, use
+// Resolver.LookupNS.
func LookupNS(name string) ([]*NS, error) {
- return DefaultResolver.lookupNS(context.Background(), name)
+ return DefaultResolver.LookupNS(context.Background(), name)
}
// LookupNS returns the DNS NS records for the given domain name.
+//
+// The returned name server names are validated to be properly
+// formatted presentation-format domain names. If the response contains
+// invalid names, those records are filtered out and an error
+// will be returned alongside the the remaining results, if any.
func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) {
- return r.lookupNS(ctx, name)
+ records, err := r.lookupNS(ctx, name)
+ if err != nil {
+ return nil, err
+ }
+ filteredNS := make([]*NS, 0, len(records))
+ for _, ns := range records {
+ if ns == nil {
+ continue
+ }
+ if !isDomainName(ns.Host) {
+ continue
+ }
+ filteredNS = append(filteredNS, ns)
+ }
+ if len(records) != len(filteredNS) {
+ return filteredNS, &DNSError{Err: errMalformedDNSRecordsDetail, Name: name}
+ }
+ return filteredNS, nil
}
// LookupTXT returns the DNS TXT records for the given domain name.
@@ -466,14 +571,40 @@
// LookupAddr performs a reverse lookup for the given address, returning a list
// of names mapping to that address.
//
+// The returned names are validated to be properly formatted presentation-format
+// domain names. If the response contains invalid names, those records are filtered
+// out and an error will be returned alongside the the remaining results, if any.
+//
// When using the host C library resolver, at most one result will be
// returned. To bypass the host resolver, use a custom Resolver.
func LookupAddr(addr string) (names []string, err error) {
- return DefaultResolver.lookupAddr(context.Background(), addr)
+ return DefaultResolver.LookupAddr(context.Background(), addr)
}
// LookupAddr performs a reverse lookup for the given address, returning a list
// of names mapping to that address.
-func (r *Resolver) LookupAddr(ctx context.Context, addr string) (names []string, err error) {
- return r.lookupAddr(ctx, addr)
-}
+//
+// The returned names are validated to be properly formatted presentation-format
+// domain names. If the response contains invalid names, those records are filtered
+// out and an error will be returned alongside the the remaining results, if any.
+func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) {
+ names, err := r.lookupAddr(ctx, addr)
+ if err != nil {
+ return nil, err
+ }
+ filteredNames := make([]string, 0, len(names))
+ for _, name := range names {
+ if isDomainName(name) {
+ filteredNames = append(filteredNames, name)
+ }
+ }
+ if len(names) != len(filteredNames) {
+ return filteredNames, &DNSError{Err: errMalformedDNSRecordsDetail, Name: addr}
+ }
+ return filteredNames, nil
+}
+
+// errMalformedDNSRecordsDetail is the DNSError detail which is returned when a Resolver.Lookup...
+// method recieves DNS records which contain invalid DNS names. This may be returned alongside
+// results which have had the malformed records filtered out.
+var errMalformedDNSRecordsDetail = "DNS response contained records which contain invalid names"
diff -Nru golang-1.15-1.15.9/src/net/sendfile_test.go golang-1.15-1.15.15/src/net/sendfile_test.go
--- golang-1.15-1.15.9/src/net/sendfile_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/net/sendfile_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -10,6 +10,7 @@
"bytes"
"crypto/sha256"
"encoding/hex"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -314,3 +315,66 @@
wg.Wait()
}
+
+// Issue 43822: tests that returns EOF when conn write timeout.
+func TestSendfileOnWriteTimeoutExceeded(t *testing.T) {
+ ln, err := newLocalListener("tcp")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer ln.Close()
+
+ errc := make(chan error, 1)
+ go func(ln Listener) (retErr error) {
+ defer func() {
+ errc <- retErr
+ close(errc)
+ }()
+
+ conn, err := ln.Accept()
+ if err != nil {
+ return err
+ }
+ defer conn.Close()
+
+ // Set the write deadline in the past(1h ago). It makes
+ // sure that it is always write timeout.
+ if err := conn.SetWriteDeadline(time.Now().Add(-1 * time.Hour)); err != nil {
+ return err
+ }
+
+ f, err := os.Open(newton)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ _, err = io.Copy(conn, f)
+ if errors.Is(err, os.ErrDeadlineExceeded) {
+ return nil
+ }
+
+ if err == nil {
+ err = fmt.Errorf("expected ErrDeadlineExceeded, but got nil")
+ }
+ return err
+ }(ln)
+
+ conn, err := Dial("tcp", ln.Addr().String())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer conn.Close()
+
+ n, err := io.Copy(ioutil.Discard, conn)
+ if err != nil {
+ t.Fatalf("expected nil error, but got %v", err)
+ }
+ if n != 0 {
+ t.Fatalf("expected receive zero, but got %d byte(s)", n)
+ }
+
+ if err := <-errc; err != nil {
+ t.Fatal(err)
+ }
+}
diff -Nru golang-1.15-1.15.9/src/os/readfrom_linux_test.go golang-1.15-1.15.15/src/os/readfrom_linux_test.go
--- golang-1.15-1.15.9/src/os/readfrom_linux_test.go 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/os/readfrom_linux_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -361,3 +361,35 @@
func (h *copyFileRangeHook) uninstall() {
*PollCopyFileRangeP = h.original
}
+
+// On some kernels copy_file_range fails on files in /proc.
+func TestProcCopy(t *testing.T) {
+ const cmdlineFile = "/proc/self/cmdline"
+ cmdline, err := ioutil.ReadFile(cmdlineFile)
+ if err != nil {
+ t.Skipf("can't read /proc file: %v", err)
+ }
+ in, err := Open(cmdlineFile)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer in.Close()
+ outFile := filepath.Join(t.TempDir(), "cmdline")
+ out, err := Create(outFile)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := io.Copy(out, in); err != nil {
+ t.Fatal(err)
+ }
+ if err := out.Close(); err != nil {
+ t.Fatal(err)
+ }
+ copy, err := ioutil.ReadFile(outFile)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(cmdline, copy) {
+ t.Errorf("copy of %q got %q want %q\n", cmdlineFile, copy, cmdline)
+ }
+}
diff -Nru golang-1.15-1.15.9/src/run.bash golang-1.15-1.15.15/src/run.bash
--- golang-1.15-1.15.9/src/run.bash 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/run.bash 2021-08-05 05:20:40.000000000 +0800
@@ -23,15 +23,7 @@
eval $(../bin/go env)
export GOROOT # The api test requires GOROOT to be set, so set it to match ../bin/go.
-
-# We disallow local import for non-local packages, if $GOROOT happens
-# to be under $GOPATH, then some tests below will fail. $GOPATH needs
-# to be set to a non-empty string, else Go will set a default value
-# that may also conflict with $GOROOT. The $GOPATH value doesn't need
-# to point to an actual directory, it just needs to pass the semantic
-# checks performed by Go. Use $GOROOT to define $GOPATH so that we
-# don't blunder into a user-defined symbolic link.
-export GOPATH=/dev/null
+export GOPATH=/nonexist-gopath
unset CDPATH # in case user has it set
export GOBIN=$GOROOT/bin # Issue 14340
diff -Nru golang-1.15-1.15.9/src/run.bat golang-1.15-1.15.15/src/run.bat
--- golang-1.15-1.15.9/src/run.bat 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/run.bat 2021-08-05 05:20:40.000000000 +0800
@@ -18,9 +18,7 @@
set GOBUILDFAIL=0
-:: we disallow local import for non-local packages, if %GOROOT% happens
-:: to be under %GOPATH%, then some tests below will fail
-set GOPATH=
+set GOPATH=c:\nonexist-gopath
:: Issue 14340: ignore GOBIN during all.bat.
set GOBIN=
set GOFLAGS=
diff -Nru golang-1.15-1.15.9/src/run.rc golang-1.15-1.15.15/src/run.rc
--- golang-1.15-1.15.9/src/run.rc 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/run.rc 2021-08-05 05:20:40.000000000 +0800
@@ -12,10 +12,9 @@
eval `{../bin/go env}
-GOPATH = () # we disallow local import for non-local packages, if $GOROOT happens
- # to be under $GOPATH, then some tests below will fail
-GOBIN = () # Issue 14340
-GOFLAGS = ()
-GO111MODULE = ()
+GOPATH=/nonexist-gopath
+GOBIN=() # Issue 14340
+GOFLAGS=()
+GO111MODULE=()
exec ../bin/go tool dist test -rebuild $*
diff -Nru golang-1.15-1.15.9/src/runtime/asm_arm64.s golang-1.15-1.15.15/src/runtime/asm_arm64.s
--- golang-1.15-1.15.9/src/runtime/asm_arm64.s 2021-03-10 22:29:36.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/asm_arm64.s 2021-08-05 05:20:40.000000000 +0800
@@ -1161,10 +1161,10 @@
// It does not clobber any general-purpose registers,
// but may clobber others (e.g., floating point registers)
// The act of CALLing gcWriteBarrier will clobber R30 (LR).
-TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$216
+TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$200
// Save the registers clobbered by the fast path.
- MOVD R0, 200(RSP)
- MOVD R1, 208(RSP)
+ MOVD R0, 184(RSP)
+ MOVD R1, 192(RSP)
MOVD g_m(g), R0
MOVD m_p(R0), R0
MOVD (p_wbBuf+wbBuf_next)(R0), R1
@@ -1180,8 +1180,8 @@
// Is the buffer full? (flags set in CMP above)
BEQ flush
ret:
- MOVD 200(RSP), R0
- MOVD 208(RSP), R1
+ MOVD 184(RSP), R0
+ MOVD 192(RSP), R1
// Do the write.
MOVD R3, (R2)
RET
@@ -1205,17 +1205,16 @@
MOVD R13, 96(RSP)
MOVD R14, 104(RSP)
MOVD R15, 112(RSP)
- MOVD R16, 120(RSP)
- MOVD R17, 128(RSP)
+ // R16, R17 may be clobbered by linker trampoline
// R18 is unused.
- MOVD R19, 136(RSP)
- MOVD R20, 144(RSP)
- MOVD R21, 152(RSP)
- MOVD R22, 160(RSP)
- MOVD R23, 168(RSP)
- MOVD R24, 176(RSP)
- MOVD R25, 184(RSP)
- MOVD R26, 192(RSP)
+ MOVD R19, 120(RSP)
+ MOVD R20, 128(RSP)
+ MOVD R21, 136(RSP)
+ MOVD R22, 144(RSP)
+ MOVD R23, 152(RSP)
+ MOVD R24, 160(RSP)
+ MOVD R25, 168(RSP)
+ MOVD R26, 176(RSP)
// R27 is temp register.
// R28 is g.
// R29 is frame pointer (unused).
@@ -1239,16 +1238,14 @@
MOVD 96(RSP), R13
MOVD 104(RSP), R14
MOVD 112(RSP), R15
- MOVD 120(RSP), R16
- MOVD 128(RSP), R17
- MOVD 136(RSP), R19
- MOVD 144(RSP), R20
- MOVD 152(RSP), R21
- MOVD 160(RSP), R22
- MOVD 168(RSP), R23
- MOVD 176(RSP), R24
- MOVD 184(RSP), R25
- MOVD 192(RSP), R26
+ MOVD 120(RSP), R19
+ MOVD 128(RSP), R20
+ MOVD 136(RSP), R21
+ MOVD 144(RSP), R22
+ MOVD 152(RSP), R23
+ MOVD 160(RSP), R24
+ MOVD 168(RSP), R25
+ MOVD 176(RSP), R26
JMP ret
// Note: these functions use a special calling convention to save generated code space.
diff -Nru golang-1.15-1.15.9/src/runtime/cgo/gcc_windows_386.c golang-1.15-1.15.15/src/runtime/cgo/gcc_windows_386.c
--- golang-1.15-1.15.9/src/runtime/cgo/gcc_windows_386.c 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/cgo/gcc_windows_386.c 2021-08-05 05:20:40.000000000 +0800
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <errno.h>
#include "libcgo.h"
+#include "libcgo_windows.h"
static void threadentry(void*);
diff -Nru golang-1.15-1.15.9/src/runtime/cgo/gcc_windows_amd64.c golang-1.15-1.15.15/src/runtime/cgo/gcc_windows_amd64.c
--- golang-1.15-1.15.9/src/runtime/cgo/gcc_windows_amd64.c 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/cgo/gcc_windows_amd64.c 2021-08-05 05:20:40.000000000 +0800
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <errno.h>
#include "libcgo.h"
+#include "libcgo_windows.h"
static void threadentry(void*);
diff -Nru golang-1.15-1.15.9/src/runtime/cgo/libcgo_windows.h golang-1.15-1.15.15/src/runtime/cgo/libcgo_windows.h
--- golang-1.15-1.15.9/src/runtime/cgo/libcgo_windows.h 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/cgo/libcgo_windows.h 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,12 @@
+// Copyright 2020 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.
+
+// Ensure there's one symbol marked __declspec(dllexport).
+// If there are no exported symbols, the unfortunate behavior of
+// the binutils linker is to also strip the relocations table,
+// resulting in non-PIE binary. The other option is the
+// --export-all-symbols flag, but we don't need to export all symbols
+// and this may overflow the export table (#40795).
+// See https://sourceware.org/bugzilla/show_bug.cgi?id=19011
+__declspec(dllexport) int _cgo_dummy_export;
diff -Nru golang-1.15-1.15.9/src/runtime/pprof/pprof_test.go golang-1.15-1.15.15/src/runtime/pprof/pprof_test.go
--- golang-1.15-1.15.9/src/runtime/pprof/pprof_test.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/pprof/pprof_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -280,7 +280,8 @@
broken := false
switch runtime.GOOS {
- case "darwin", "dragonfly", "netbsd", "illumos", "solaris":
+ // See https://golang.org/issue/45170 for AIX.
+ case "darwin", "dragonfly", "netbsd", "illumos", "solaris", "aix":
broken = true
case "openbsd":
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
diff -Nru golang-1.15-1.15.9/src/runtime/signal_unix.go golang-1.15-1.15.15/src/runtime/signal_unix.go
--- golang-1.15-1.15.9/src/runtime/signal_unix.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/signal_unix.go 2021-08-05 05:20:40.000000000 +0800
@@ -393,7 +393,7 @@
//go:nosplit
func sigFetchG(c *sigctxt) *g {
switch GOARCH {
- case "arm", "arm64":
+ case "arm", "arm64", "ppc64", "ppc64le":
if !iscgo && inVDSOPage(c.sigpc()) {
// When using cgo, we save the g on TLS and load it from there
// in sigtramp. Just use that.
diff -Nru golang-1.15-1.15.9/src/runtime/symtab.go golang-1.15-1.15.15/src/runtime/symtab.go
--- golang-1.15-1.15.9/src/runtime/symtab.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/symtab.go 2021-08-05 05:20:40.000000000 +0800
@@ -102,7 +102,9 @@
name := funcname(funcInfo)
if inldata := funcdata(funcInfo, _FUNCDATA_InlTree); inldata != nil {
inltree := (*[1 << 20]inlinedCall)(inldata)
- ix := pcdatavalue(funcInfo, _PCDATA_InlTreeIndex, pc, nil)
+ // Non-strict as cgoTraceback may have added bogus PCs
+ // with a valid funcInfo but invalid PCDATA.
+ ix := pcdatavalue1(funcInfo, _PCDATA_InlTreeIndex, pc, nil, false)
if ix >= 0 {
// Note: entry is not modified. It always refers to a real frame, not an inlined one.
f = nil
@@ -183,7 +185,9 @@
var cache pcvalueCache
inltree := (*[1 << 20]inlinedCall)(inldata)
for {
- ix := pcdatavalue(f, _PCDATA_InlTreeIndex, tracepc, &cache)
+ // Non-strict as cgoTraceback may have added bogus PCs
+ // with a valid funcInfo but invalid PCDATA.
+ ix := pcdatavalue1(f, _PCDATA_InlTreeIndex, tracepc, &cache, false)
if ix < 0 {
break
}
diff -Nru golang-1.15-1.15.9/src/runtime/symtab_test.go golang-1.15-1.15.15/src/runtime/symtab_test.go
--- golang-1.15-1.15.9/src/runtime/symtab_test.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/symtab_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -8,6 +8,7 @@
"runtime"
"strings"
"testing"
+ "unsafe"
)
func TestCaller(t *testing.T) {
@@ -165,3 +166,87 @@
t.Errorf("Name() = %q, want %q", got, "")
}
}
+
+var dummy int
+
+func inlined() {
+ // Side effect to prevent elimination of this entire function.
+ dummy = 42
+}
+
+// A function with an InlTree. Returns a PC within the function body.
+//
+// No inline to ensure this complete function appears in output.
+//
+//go:noinline
+func tracebackFunc(t *testing.T) uintptr {
+ // This body must be more complex than a single call to inlined to get
+ // an inline tree.
+ inlined()
+ inlined()
+
+ // Acquire a PC in this function.
+ pc, _, _, ok := runtime.Caller(0)
+ if !ok {
+ t.Fatalf("Caller(0) got ok false, want true")
+ }
+
+ return pc
+}
+
+// Test that CallersFrames handles PCs in the alignment region between
+// functions (int 3 on amd64) without crashing.
+//
+// Go will never generate a stack trace containing such an address, as it is
+// not a valid call site. However, the cgo traceback function passed to
+// runtime.SetCgoTraceback may not be completely accurate and may incorrect
+// provide PCs in Go code or the alignement region between functions.
+//
+// Go obviously doesn't easily expose the problematic PCs to running programs,
+// so this test is a bit fragile. Some details:
+//
+// * tracebackFunc is our target function. We want to get a PC in the
+// alignment region following this function. This function also has other
+// functions inlined into it to ensure it has an InlTree (this was the source
+// of the bug in issue 44971).
+//
+// * We acquire a PC in tracebackFunc, walking forwards until FuncForPC says
+// we're in a new function. The last PC of the function according to FuncForPC
+// should be in the alignment region (assuming the function isn't already
+// perfectly aligned).
+//
+// This is a regression test for issue 44971.
+func TestFunctionAlignmentTraceback(t *testing.T) {
+ pc := tracebackFunc(t)
+
+ // Double-check we got the right PC.
+ f := runtime.FuncForPC(pc)
+ if !strings.HasSuffix(f.Name(), "tracebackFunc") {
+ t.Fatalf("Caller(0) = %+v, want tracebackFunc", f)
+ }
+
+ // Iterate forward until we find a different function. Back up one
+ // instruction is (hopefully) an alignment instruction.
+ for runtime.FuncForPC(pc) == f {
+ pc++
+ }
+ pc--
+
+ // Is this an alignment region filler instruction? We only check this
+ // on amd64 for simplicity. If this function has no filler, then we may
+ // get a false negative, but will never get a false positive.
+ if runtime.GOARCH == "amd64" {
+ code := *(*uint8)(unsafe.Pointer(pc))
+ if code != 0xcc { // INT $3
+ t.Errorf("PC %v code got %#x want 0xcc", pc, code)
+ }
+ }
+
+ // Finally ensure that Frames.Next doesn't crash when processing this
+ // PC.
+ frames := runtime.CallersFrames([]uintptr{pc})
+ frame, _ := frames.Next()
+ if frame.Func != f {
+ t.Errorf("frames.Next() got %+v want %+v", frame.Func, f)
+ }
+}
diff -Nru golang-1.15-1.15.9/src/runtime/sys_linux_ppc64x.s golang-1.15-1.15.15/src/runtime/sys_linux_ppc64x.s
--- golang-1.15-1.15.9/src/runtime/sys_linux_ppc64x.s 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/sys_linux_ppc64x.s 2021-08-05 05:20:40.000000000 +0800
@@ -215,15 +215,45 @@
MOVD (g_sched+gobuf_sp)(R7), R1 // Set SP to g0 stack
noswitch:
- SUB $16, R1 // Space for results
- RLDICR $0, R1, $59, R1 // Align for C code
+ SUB $16, R1 // Space for results
+ RLDICR $0, R1, $59, R1 // Align for C code
MOVD R12, CTR
MOVD R1, R4
- BL (CTR) // Call from VDSO
- MOVD $0, R0 // Restore R0
- MOVD 0(R1), R3 // sec
- MOVD 8(R1), R5 // nsec
- MOVD R15, R1 // Restore SP
+
+ // 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.
+ // 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.
+ MOVBZ runtime·iscgo(SB), R22
+ CMP R22, $0
+ BNE nosaveg
+ MOVD m_gsignal(R21), R22 // g.m.gsignal
+ CMP R22, $0
+ BEQ nosaveg
+
+ CMP g, R22
+ BEQ nosaveg
+ MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
+ MOVD g, (R22)
+
+ BL (CTR) // Call from VDSO
+
+ MOVD $0, (R22) // clear g slot, R22 is unchanged by C code
+
+ JMP finish
+
+nosaveg:
+ BL (CTR) // Call from VDSO
+
+finish:
+ MOVD $0, R0 // Restore R0
+ MOVD 0(R1), R3 // sec
+ MOVD 8(R1), R5 // nsec
+ MOVD R15, R1 // Restore SP
// Restore vdsoPC, vdsoSP
// We don't worry about being signaled between the two stores.
@@ -235,7 +265,7 @@
MOVD 32(R1), R6
MOVD R6, m_vdsoPC(R21)
-finish:
+return:
MOVD R3, sec+0(FP)
MOVW R5, nsec+8(FP)
RET
@@ -246,7 +276,7 @@
SYSCALL $SYS_clock_gettime
MOVD 32(R1), R3
MOVD 40(R1), R5
- JMP finish
+ JMP return
TEXT runtime·nanotime1(SB),NOSPLIT,$16-8
MOVD $1, R3 // CLOCK_MONOTONIC
@@ -282,7 +312,37 @@
RLDICR $0, R1, $59, R1 // Align for C code
MOVD R12, CTR
MOVD R1, R4
- BL (CTR) // Call from VDSO
+
+ // 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.
+ // 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.
+ MOVBZ runtime·iscgo(SB), R22
+ CMP R22, $0
+ BNE nosaveg
+ MOVD m_gsignal(R21), R22 // g.m.gsignal
+ CMP R22, $0
+ BEQ nosaveg
+
+ CMP g, R22
+ BEQ nosaveg
+ MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo
+ MOVD g, (R22)
+
+ BL (CTR) // Call from VDSO
+
+ MOVD $0, (R22) // clear g slot, R22 is unchanged by C code
+
+ JMP finish
+
+nosaveg:
+ BL (CTR) // Call from VDSO
+
+finish:
MOVD $0, R0 // Restore R0
MOVD 0(R1), R3 // sec
MOVD 8(R1), R5 // nsec
@@ -298,7 +358,7 @@
MOVD 32(R1), R6
MOVD R6, m_vdsoPC(R21)
-finish:
+return:
// sec is in R3, nsec in R5
// return nsec in R3
MOVD $1000000000, R4
@@ -313,7 +373,7 @@
SYSCALL $SYS_clock_gettime
MOVD 32(R1), R3
MOVD 40(R1), R5
- JMP finish
+ JMP return
TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28
MOVW how+0(FP), R3
@@ -366,7 +426,7 @@
// this might be called in external code context,
// where g is not set.
MOVBZ runtime·iscgo(SB), R6
- CMP R6, $0
+ CMP R6, $0
BEQ 2(PC)
BL runtime·load_g(SB)
diff -Nru golang-1.15-1.15.9/src/runtime/time.go golang-1.15-1.15.15/src/runtime/time.go
--- golang-1.15-1.15.9/src/runtime/time.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/runtime/time.go 2021-08-05 05:20:40.000000000 +0800
@@ -254,6 +254,9 @@
when := t.when
+ // Disable preemption while using pp to avoid changing another P's heap.
+ mp := acquirem()
+
pp := getg().m.p.ptr()
lock(&pp.timersLock)
cleantimers(pp)
@@ -261,6 +264,8 @@
unlock(&pp.timersLock)
wakeNetPoller(when)
+
+ releasem(mp)
}
// doaddtimer adds t to the current P's heap.
diff -Nru golang-1.15-1.15.9/src/syscall/exec_linux_test.go golang-1.15-1.15.15/src/syscall/exec_linux_test.go
--- golang-1.15-1.15.9/src/syscall/exec_linux_test.go 2021-03-10 22:29:37.000000000 +0800
+++ golang-1.15-1.15.15/src/syscall/exec_linux_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -318,6 +318,7 @@
"uid=0(root) gid=0(root) groups=0(root),65534",
"uid=0(root) gid=0(root) groups=0(root),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody),65534(nobody)", // Alpine; see https://golang.org/issue/19938
"uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // CentOS with SELinux context, see https://golang.org/issue/34547
+ "uid=0(root) gid=0(root) groups=0(root),65534(nobody) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", // Fedora with SElinux context, see https://golang.org/issue/46752
}
for _, e := range expected {
if strOut == e {
diff -Nru golang-1.15-1.15.9/src/syscall/syscall_windows.go golang-1.15-1.15.15/src/syscall/syscall_windows.go
--- golang-1.15-1.15.9/src/syscall/syscall_windows.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/syscall/syscall_windows.go 2021-08-05 05:20:40.000000000 +0800
@@ -213,9 +213,9 @@
//sys SetEndOfFile(handle Handle) (err error)
//sys GetSystemTimeAsFileTime(time *Filetime)
//sys GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) [failretval==0xffffffff]
-//sys CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error)
-//sys GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error)
-//sys PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error)
+//sys createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) = CreateIoCompletionPort
+//sys getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) = GetQueuedCompletionStatus
+//sys postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) = PostQueuedCompletionStatus
//sys CancelIo(s Handle) (err error)
//sys CancelIoEx(s Handle, o *Overlapped) (err error)
//sys CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) = CreateProcessW
@@ -1209,3 +1209,31 @@
return n, nil
}
+
+// Deprecated: CreateIoCompletionPort has the wrong function signature. Use x/sys/windows.CreateIoCompletionPort.
+func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (Handle, error) {
+ return createIoCompletionPort(filehandle, cphandle, uintptr(key), threadcnt)
+}
+
+// Deprecated: GetQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.GetQueuedCompletionStatus.
+func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) error {
+ var ukey uintptr
+ var pukey *uintptr
+ if key != nil {
+ ukey = uintptr(*key)
+ pukey = &ukey
+ }
+ err := getQueuedCompletionStatus(cphandle, qty, pukey, overlapped, timeout)
+ if key != nil {
+ *key = uint32(ukey)
+ if uintptr(*key) != ukey && err == nil {
+ err = errorspkg.New("GetQueuedCompletionStatus returned key overflow")
+ }
+ }
+ return err
+}
+
+// Deprecated: PostQueuedCompletionStatus has the wrong function signature. Use x/sys/windows.PostQueuedCompletionStatus.
+func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) error {
+ return postQueuedCompletionStatus(cphandle, qty, uintptr(key), overlapped)
+}
diff -Nru golang-1.15-1.15.9/src/syscall/zsyscall_windows.go golang-1.15-1.15.15/src/syscall/zsyscall_windows.go
--- golang-1.15-1.15.9/src/syscall/zsyscall_windows.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/syscall/zsyscall_windows.go 2021-08-05 05:20:40.000000000 +0800
@@ -539,7 +539,7 @@
return
}
-func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
+func createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) {
r0, _, e1 := Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
handle = Handle(r0)
if handle == 0 {
@@ -552,7 +552,7 @@
return
}
-func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
+func getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) {
r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
if r1 == 0 {
if e1 != 0 {
@@ -564,7 +564,7 @@
return
}
-func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
+func postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
if r1 == 0 {
if e1 != 0 {
diff -Nru golang-1.15-1.15.9/src/time/sleep_test.go golang-1.15-1.15.15/src/time/sleep_test.go
--- golang-1.15-1.15.9/src/time/sleep_test.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/time/sleep_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -501,3 +501,19 @@
var tr Timer
tr.Stop()
}
+
+// Test that zero duration timers aren't missed by the scheduler. Regression test for issue 44868.
+func TestZeroTimer(t *testing.T) {
+ if testing.Short() {
+ t.Skip("-short")
+ }
+
+ for i := 0; i < 1000000; i++ {
+ s := Now()
+ ti := NewTimer(0)
+ <-ti.C
+ if diff := Since(s); diff > 2*Second {
+ t.Errorf("Expected time to get value from Timer channel in less than 2 sec, took %v", diff)
+ }
+ }
+}
diff -Nru golang-1.15-1.15.9/src/time/zoneinfo.go golang-1.15-1.15.15/src/time/zoneinfo.go
--- golang-1.15-1.15.9/src/time/zoneinfo.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/time/zoneinfo.go 2021-08-05 05:20:40.000000000 +0800
@@ -178,7 +178,7 @@
// If we're at the end of the known zone transitions,
// try the extend string.
if lo == len(tx)-1 && l.extend != "" {
- if ename, eoffset, estart, eend, ok := tzset(l.extend, end, sec); ok {
+ if ename, eoffset, estart, eend, _, ok := tzset(l.extend, end, sec); ok {
return ename, eoffset, estart, eend
}
}
@@ -244,7 +244,7 @@
// We call this a tzset string since in C the function tzset reads TZ.
// The return values are as for lookup, plus ok which reports whether the
// parse succeeded.
-func tzset(s string, initEnd, sec int64) (name string, offset int, start, end int64, ok bool) {
+func tzset(s string, initEnd, sec int64) (name string, offset int, start, end int64, isDST, ok bool) {
var (
stdName, dstName string
stdOffset, dstOffset int
@@ -255,7 +255,7 @@
stdOffset, s, ok = tzsetOffset(s)
}
if !ok {
- return "", 0, 0, 0, false
+ return "", 0, 0, 0, false, false
}
// The numbers in the tzset string are added to local time to get UTC,
@@ -265,7 +265,7 @@
if len(s) == 0 || s[0] == ',' {
// No daylight savings time.
- return stdName, stdOffset, initEnd, omega, true
+ return stdName, stdOffset, initEnd, omega, false, true
}
dstName, s, ok = tzsetName(s)
@@ -278,7 +278,7 @@
}
}
if !ok {
- return "", 0, 0, 0, false
+ return "", 0, 0, 0, false, false
}
if len(s) == 0 {
@@ -287,19 +287,19 @@
}
// The TZ definition does not mention ';' here but tzcode accepts it.
if s[0] != ',' && s[0] != ';' {
- return "", 0, 0, 0, false
+ return "", 0, 0, 0, false, false
}
s = s[1:]
var startRule, endRule rule
startRule, s, ok = tzsetRule(s)
if !ok || len(s) == 0 || s[0] != ',' {
- return "", 0, 0, 0, false
+ return "", 0, 0, 0, false, false
}
s = s[1:]
endRule, s, ok = tzsetRule(s)
if !ok || len(s) > 0 {
- return "", 0, 0, 0, false
+ return "", 0, 0, 0, false, false
}
year, _, _, yday := absDate(uint64(sec+unixToInternal+internalToAbsolute), false)
@@ -313,10 +313,15 @@
startSec := int64(tzruleTime(year, startRule, stdOffset))
endSec := int64(tzruleTime(year, endRule, dstOffset))
+ dstIsDST, stdIsDST := true, false
+ // Note: this is a flipping of "DST" and "STD" while retaining the labels
+ // This happens in southern hemispheres. The labelling here thus is a little
+ // inconsistent with the goal.
if endSec < startSec {
startSec, endSec = endSec, startSec
stdName, dstName = dstName, stdName
stdOffset, dstOffset = dstOffset, stdOffset
+ stdIsDST, dstIsDST = dstIsDST, stdIsDST
}
// The start and end values that we return are accurate
@@ -324,11 +329,11 @@
// just the start and end of the year. That suffices for
// the only caller that cares, which is Date.
if ysec < startSec {
- return stdName, stdOffset, abs, startSec + abs, true
+ return stdName, stdOffset, abs, startSec + abs, stdIsDST, true
} else if ysec >= endSec {
- return stdName, stdOffset, endSec + abs, abs + 365*secondsPerDay, true
+ return stdName, stdOffset, endSec + abs, abs + 365*secondsPerDay, stdIsDST, true
} else {
- return dstName, dstOffset, startSec + abs, endSec + abs, true
+ return dstName, dstOffset, startSec + abs, endSec + abs, dstIsDST, true
}
}
@@ -377,8 +382,10 @@
neg = true
}
+ // The tzdata code permits values up to 24 * 7 here,
+ // although POSIX does not.
var hours int
- hours, s, ok = tzsetNum(s, 0, 24)
+ hours, s, ok = tzsetNum(s, 0, 24*7)
if !ok {
return 0, "", false
}
@@ -487,7 +494,7 @@
}
offset, s, ok := tzsetOffset(s[1:])
- if !ok || offset < 0 {
+ if !ok {
return rule{}, "", false
}
r.time = offset
diff -Nru golang-1.15-1.15.9/src/time/zoneinfo_read.go golang-1.15-1.15.15/src/time/zoneinfo_read.go
--- golang-1.15-1.15.9/src/time/zoneinfo_read.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/time/zoneinfo_read.go 2021-08-05 05:20:40.000000000 +0800
@@ -247,8 +247,8 @@
// This also avoids a panic later when we add and then use a fake transition (golang.org/issue/29437).
return nil, badData
}
- zone := make([]zone, nzone)
- for i := range zone {
+ zones := make([]zone, nzone)
+ for i := range zones {
var ok bool
var n uint32
if n, ok = zonedata.big4(); !ok {
@@ -257,22 +257,22 @@
if uint32(int(n)) != n {
return nil, badData
}
- zone[i].offset = int(int32(n))
+ zones[i].offset = int(int32(n))
var b byte
if b, ok = zonedata.byte(); !ok {
return nil, badData
}
- zone[i].isDST = b != 0
+ zones[i].isDST = b != 0
if b, ok = zonedata.byte(); !ok || int(b) >= len(abbrev) {
return nil, badData
}
- zone[i].name = byteString(abbrev[b:])
+ zones[i].name = byteString(abbrev[b:])
if runtime.GOOS == "aix" && len(name) > 8 && (name[:8] == "Etc/GMT+" || name[:8] == "Etc/GMT-") {
// There is a bug with AIX 7.2 TL 0 with files in Etc,
// GMT+1 will return GMT-1 instead of GMT+1 or -01.
if name != "Etc/GMT+0" {
// GMT+0 is OK
- zone[i].name = name[4:]
+ zones[i].name = name[4:]
}
}
}
@@ -295,7 +295,7 @@
}
}
tx[i].when = n
- if int(txzones[i]) >= len(zone) {
+ if int(txzones[i]) >= len(zones) {
return nil, badData
}
tx[i].index = txzones[i]
@@ -314,7 +314,7 @@
}
// Committed to succeed.
- l := &Location{zone: zone, tx: tx, name: name, extend: extend}
+ l := &Location{zone: zones, tx: tx, name: name, extend: extend}
// Fill in the cache with information about right now,
// since that will be the most common lookup.
@@ -323,26 +323,27 @@
if tx[i].when <= sec && (i+1 == len(tx) || sec < tx[i+1].when) {
l.cacheStart = tx[i].when
l.cacheEnd = omega
- zoneIdx := tx[i].index
+ l.cacheZone = &l.zone[tx[i].index]
if i+1 < len(tx) {
l.cacheEnd = tx[i+1].when
} else if l.extend != "" {
// If we're at the end of the known zone transitions,
// try the extend string.
- if name, _, estart, eend, ok := tzset(l.extend, l.cacheEnd, sec); ok {
+ if name, offset, estart, eend, isDST, ok := tzset(l.extend, l.cacheEnd, sec); ok {
l.cacheStart = estart
l.cacheEnd = eend
- // Find the zone that is returned by tzset,
- // the last transition is not always the correct zone.
- for i, z := range l.zone {
- if z.name == name {
- zoneIdx = uint8(i)
- break
+ // Find the zone that is returned by tzset to avoid allocation if possible.
+ if zoneIdx := findZone(l.zone, name, offset, isDST); zoneIdx != -1 {
+ l.cacheZone = &l.zone[zoneIdx]
+ } else {
+ l.cacheZone = &zone{
+ name: name,
+ offset: offset,
+ isDST: isDST,
}
}
}
}
- l.cacheZone = &l.zone[zoneIdx]
break
}
}
@@ -350,6 +351,15 @@
return l, nil
}
+func findZone(zones []zone, name string, offset int, isDST bool) int {
+ for i, z := range zones {
+ if z.name == name && z.offset == offset && z.isDST == isDST {
+ return i
+ }
+ }
+ return -1
+}
+
// loadTzinfoFromDirOrZip returns the contents of the file with the given name
// in dir. dir can either be an uncompressed zip file, or a directory.
func loadTzinfoFromDirOrZip(dir, name string) ([]byte, error) {
diff -Nru golang-1.15-1.15.9/src/time/zoneinfo_test.go golang-1.15-1.15.15/src/time/zoneinfo_test.go
--- golang-1.15-1.15.9/src/time/zoneinfo_test.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/time/zoneinfo_test.go 2021-08-05 05:20:40.000000000 +0800
@@ -183,22 +183,62 @@
}
}
-func TestLoadLocationFromTZDataSlim(t *testing.T) {
- // A 2020b slim tzdata for Europe/Berlin
- tzData := "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x04\x00\x00\x00\x12\xff\xff\xff\xffo\xa2a\xf8\xff\xff\xff\xff\x9b\f\x17`\xff\xff\xff\xff\x9b\xd5\xda\xf0\xff\xff\xff\xff\x9cٮ\x90\xff\xff\xff\xff\x9d\xa4\xb5\x90\xff\xff\xff\xff\x9e\xb9\x90\x90\xff\xff\xff\xff\x9f\x84\x97\x90\xff\xff\xff\xff\xc8\tq\x90\xff\xff\xff\xff\xcc\xe7K\x10\xff\xff\xff\xffͩ\x17\x90\xff\xff\xff\xff\u03a2C\x10\xff\xff\xff\xffϒ4\x10\xff\xff\xff\xffЂ%\x10\xff\xff\xff\xff\xd1r\x16\x10\xff\xff\xff\xffѶ\x96\x00\xff\xff\xff\xff\xd2X\xbe\x80\xff\xff\xff\xffҡO\x10\xff\xff\xff\xff\xd3c\x1b\x90\xff\xff\xff\xff\xd4K#\x90\xff\xff\xff\xff\xd59\xd1 \xff\xff\xff\xff\xd5g\xe7\x90\xff\xff\xff\xffըs\x00\xff\xff\xff\xff\xd6)\xb4\x10\xff\xff\xff\xff\xd7,\x1a\x10\xff\xff\xff\xff\xd8\t\x96\x10\xff\xff\xff\xff\xd9\x02\xc1\x90\xff\xff\xff\xff\xd9\xe9x\x10\x00\x00\x00\x00\x13MD\x10\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#<E\x10\x00\x00\x00\x00$,6\x10\x00\x00\x00\x00%\x1c'\x10\x00\x00\x00\x00&\f\x18\x10\x00\x00\x00\x00'\x05C\x90\x00\x00\x00\x00'\xf54\x90\x00\x00\x00\x00(\xe5%\x90\x00\x00\x00\x00)\xd5\x16\x90\x00\x00\x00\x00*\xc5\a\x90\x00\x00\x00\x00+\xb4\xf8\x90\x00\x00\x00\x00,\xa4\xe9\x90\x00\x00\x00\x00-\x94ڐ\x00\x00\x00\x00.\x84ː\x00\x00\x00\x00/t\xbc\x90\x00\x00\x00\x000d\xad\x90\x00\x00\x00\x001]\xd9\x10\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x03\x01\x02\x01\x02\x01\x03\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00\f\x88\x00\x00\x00\x00\x1c \x01\x04\x00\x00\x0e\x10\x00\t\x00\x00*0\x01\rLMT\x00CEST\x00CET\x00CEMT\x00\nCET-1CEST,M3.5.0,M10.5.0/3\n"
+var slimTests = []struct {
+ zoneName string
+ tzData string
+ date func(*time.Location) time.Time
+ wantName string
+ wantOffset int
+}{
+ {
+ // 2020b slim tzdata for Europe/Berlin.
+ zoneName: "Europe/Berlin",
+ tzData: "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<\x00\x00\x00\x04\x00\x00\x00\x12\xff\xff\xff\xffo\xa2a\xf8\xff\xff\xff\xff\x9b\f\x17`\xff\xff\xff\xff\x9b\xd5\xda\xf0\xff\xff\xff\xff\x9cٮ\x90\xff\xff\xff\xff\x9d\xa4\xb5\x90\xff\xff\xff\xff\x9e\xb9\x90\x90\xff\xff\xff\xff\x9f\x84\x97\x90\xff\xff\xff\xff\xc8\tq\x90\xff\xff\xff\xff\xcc\xe7K\x10\xff\xff\xff\xffͩ\x17\x90\xff\xff\xff\xff\u03a2C\x10\xff\xff\xff\xffϒ4\x10\xff\xff\xff\xffЂ%\x10\xff\xff\xff\xff\xd1r\x16\x10\xff\xff\xff\xffѶ\x96\x00\xff\xff\xff\xff\xd2X\xbe\x80\xff\xff\xff\xffҡO\x10\xff\xff\xff\xff\xd3c\x1b\x90\xff\xff\xff\xff\xd4K#\x90\xff\xff\xff\xff\xd59\xd1 \xff\xff\xff\xff\xd5g\xe7\x90\xff\xff\xff\xffըs\x00\xff\xff\xff\xff\xd6)\xb4\x10\xff\xff\xff\xff\xd7,\x1a\x10\xff\xff\xff\xff\xd8\t\x96\x10\xff\xff\xff\xff\xd9\x02\xc1\x90\xff\xff\xff\xff\xd9\xe9x\x10\x00\x00\x00\x00\x13MD\x10\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#<E\x10\x00\x00\x00\x00$,6\x10\x00\x00\x00\x00%\x1c'\x10\x00\x00\x00\x00&\f\x18\x10\x00\x00\x00\x00'\x05C\x90\x00\x00\x00\x00'\xf54\x90\x00\x00\x00\x00(\xe5%\x90\x00\x00\x00\x00)\xd5\x16\x90\x00\x00\x00\x00*\xc5\a\x90\x00\x00\x00\x00+\xb4\xf8\x90\x00\x00\x00\x00,\xa4\xe9\x90\x00\x00\x00\x00-\x94ڐ\x00\x00\x00\x00.\x84ː\x00\x00\x00\x00/t\xbc\x90\x00\x00\x00\x000d\xad\x90\x00\x00\x00\x001]\xd9\x10\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x03\x01\x02\x01\x02\x01\x03\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00\f\x88\x00\x00\x00\x00\x1c \x01\x04\x00\x00\x0e\x10\x00\t\x00\x00*0\x01\rLMT\x00CEST\x00CET\x00CEMT\x00\nCET-1CEST,M3.5.0,M10.5.0/3\n",
+ date: func(loc *time.Location) time.Time { return time.Date(2020, time.October, 29, 15, 30, 0, 0, loc) },
+ wantName: "CET",
+ wantOffset: 3600,
+ },
+ {
+ // 2021a slim tzdata for America/Nuuk.
+ zoneName: "America/Nuuk",
+ tzData: "TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\"\x00\x00\x00\x03\x00\x00\x00\f\xff\xff\xff\xff\x9b\x80h\x00\x00\x00\x00\x00\x13M|P\x00\x00\x00\x00\x143\xfa\x90\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x16\x13ܐ\x00\x00\x00\x00\x17\x03͐\x00\x00\x00\x00\x17\xf3\xbe\x90\x00\x00\x00\x00\x18㯐\x00\x00\x00\x00\x19Ӡ\x90\x00\x00\x00\x00\x1aÑ\x90\x00\x00\x00\x00\x1b\xbc\xbd\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\x9c\x9f\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f|\x81\x10\x00\x00\x00\x00 lr\x10\x00\x00\x00\x00!\\c\x10\x00\x00\x00\x00\"LT\x10\x00\x00\x00\x00#<E\x10\x00\x00\x00\x00$,6\x10\x00\x00\x00\x00%\x1c'\x10\x00\x00\x00\x00&\f\x18\x10\x00\x00\x00\x00'\x05C\x90\x00\x00\x00\x00'\xf54\x90\x00\x00\x00\x00(\xe5%\x90\x00\x00\x00\x00)\xd5\x16\x90\x00\x00\x00\x00*\xc5\a\x90\x00\x00\x00\x00+\xb4\xf8\x90\x00\x00\x00\x00,\xa4\xe9\x90\x00\x00\x00\x00-\x94ڐ\x00\x00\x00\x00.\x84ː\x00\x00\x00\x00/t\xbc\x90\x00\x00\x00\x000d\xad\x90\x00\x00\x00\x001]\xd9\x10\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\xff\xffπ\x00\x00\xff\xff\xd5\xd0\x00\x04\xff\xff\xe3\xe0\x01\bLMT\x00-03\x00-02\x00\n<-03>3<-02>,M3.5.0/-2,M10.5.0/-1\n",
+ date: func(loc *time.Location) time.Time { return time.Date(2020, time.October, 29, 15, 30, 0, 0, loc) },
+ wantName: "-03",
+ wantOffset: -10800,
+ },
+ {
+ // 2021a slim tzdata for Asia/Gaza.
+ zoneName: "Asia/Gaza",
+ tzData: "TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00s\x00\x00\x00\x05\x00\x00\x00\x15\xff\xff\xff\xff}\xbdJ\xb0\xff\xff\xff\xff\xc8Y\xcf\x00\xff\xff\xff\xff\xc8\xfa\xa6\x00\xff\xff\xff\xff\xc98\x9c\x80\xff\xff\xff\xff\xcc\xe5\xeb\x80\xff\xff\xff\xffͬ\xfe\x00\xff\xff\xff\xff\xce\xc7\x1f\x00\xff\xff\xff\xffϏ\x83\x00\xff\xff\xff\xffЩ\xa4\x00\xff\xff\xff\xffф}\x00\xff\xff\xff\xffҊ׀\xff\xff\xff\xff\xd3e\xb0\x80\xff\xff\xff\xff\xd4l\v\x00\xff\xff\xff\xff\xe86c`\xff\xff\xff\xff\xe8\xf4-P\xff\xff\xff\xff\xea\v\xb9`\xff\xff\xff\xff\xea\xd5`\xd0\xff\xff\xff\xff\xeb\xec\xfa\xf0\xff\xff\xff\xff\xec\xb5m\x00\xff\xff\xff\xff\xed\xcf\u007f\xf0\xff\xff\xff\xff\xee\x97\xf2\x00\xff\xff\xff\xffﰳp\xff\xff\xff\xff\xf0y%\x80\xff\xff\xff\xff\xf1\x91\xe6\xf0\xff\xff\xff\xff\xf2ZY\x00\xff\xff\xff\xff\xf3s\x1ap\xff\xff\xff\xff\xf4;\x8c\x80\xff\xff\xff\xff\xf5U\x9fp\xff\xff\xff\xff\xf6\x1e\x11\x80\xff\xff\xff\xff\xf76\xd2\xf0\xff\xff\xff\xff\xf7\xffE\x00\xff\xff\xff\xff\xf9\x18\x06p\xff\xff\xff\xff\xf9\xe1\xca\x00\xff\xff\xff\xff\xfa\xf99\xf0\xff\xff\xff\xff\xfb'BP\x00\x00\x00\x00\b|\x8b\xe0\x00\x00\x00\x00\b\xfd\xb0\xd0\x00\x00\x00\x00\t\xf6\xea`\x00\x00\x00\x00\n\xa63\xd0\x00\x00\x00\x00\x13\xe9\xfc`\x00\x00\x00\x00\x14![`\x00\x00\x00\x00\x1a\xfa\xc6`\x00\x00\x00\x00\x1b\x8en`\x00\x00\x00\x00\x1c\xbe\xf8\xe0\x00\x00\x00\x00\x1dw|\xd0\x00\x00\x00\x00\x1e\xcc\xff`\x00\x00\x00\x00\x1f`\x99P\x00\x00\x00\x00 \x82\xb1`\x00\x00\x00\x00!I\xb5\xd0\x00\x00\x00\x00\"^\x9e\xe0\x00\x00\x00\x00# ]P\x00\x00\x00\x00$Z0`\x00\x00\x00\x00%\x00?P\x00\x00\x00\x00&\v\xed\xe0\x00\x00\x00\x00&\xd6\xe6\xd0\x00\x00\x00\x00'\xeb\xcf\xe0\x00\x00\x00\x00(\xc0\x03P\x00\x00\x00\x00)\xd4\xec`\x00\x00\x00\x00*\xa9\x1f\xd0\x00\x00\x00\x00+\xbbe\xe0\x00\x00\x00\x00,\x89\x01\xd0\x00\x00\x00\x00-\x9bG\xe0\x00\x00\x00\x00._\xa9P\x00\x00\x00\x00/{)\xe0\x00\x00\x00\x000H\xc5\xd0\x00\x00\x00\x000\xe7\a\xe0\x00\x00\x00\x001dF`\x00\x00\x00\x002A\xc2`\x00\x00\x00\x003D(`\x00\x00\x00\x004!\xa4`\x00\x00\x00\x005$\n`\x00\x00\x00\x006\x01\x86`\x00\x00\x00\x007\x16a`\x00\x00\x00\x008\x06DP\x00\x00\x00\x008\xff}\xe0\x00\x00\x00\x009\xef`\xd0\x00\x00\x00\x00:\xdf_\xe0\x00\x00\x00\x00;\xcfB\xd0\x00\x00\x00\x00<\xbfA\xe0\x00\x00\x00\x00=\xaf$\xd0\x00\x00\x00\x00>\x9f#\xe0\x00\x00\x00\x00?\x8f\x06\xd0\x00\x00\x00\x00@\u007f\x05\xe0\x00\x00\x00\x00A\\\x81\xe0\x00\x00\x00\x00B^\xe7\xe0\x00\x00\x00\x00CA\xb7\xf0\x00\x00\x00\x00D-\xa6`\x00\x00\x00\x00E\x12\xfdP\x00\x00\x00\x00F\x0e\xd9\xe0\x00\x00\x00\x00F\xe8op\x00\x00\x00\x00G\xec\x18\xe0\x00\x00\x00\x00H\xb7\x11\xd0\x00\x00\x00\x00I\xcb\xfa\xe0\x00\x00\x00\x00J\xa0<`\x00\x00\x00\x00K\xad.\x9c\x00\x00\x00\x00La\xbd\xd0\x00\x00\x00\x00M\x94\xf9\x9c\x00\x00\x00\x00N5\xc2P\x00\x00\x00\x00Ot\xdb`\x00\x00\x00\x00P[\x91\xe0\x00\x00\x00\x00QT\xbd`\x00\x00\x00\x00RD\xa0P\x00\x00\x00\x00S4\x9f`\x00\x00\x00\x00TIlP\x00\x00\x00\x00U\x15\xd2\xe0\x00\x00\x00\x00V)\\`\x00\x00\x00\x00V\xf5\xc2\xf0\x00\x00\x00\x00X\x13\xca`\x00\x00\x00\x00Xդ\xf0\x00\x00\x00\x00Y\xf3\xac`\x00\x00\x00\x00Z\xb5\x86\xf0\x00\x00\x00\x00[ӎ`\x00\x00\x00\x00\\\x9dC\xe0\x00\x00\x00\x00]\xb3bP\x00\x00\x00\x00^~w`\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x00\x00 P\x00\x00\x00\x00*0\x01\x04\x00\x00\x1c \x00\t\x00\x00*0\x01\r\x00\x00\x1c \x00\x11LMT\x00EEST\x00EET\x00IDT\x00IST\x00\nEET-2EEST,M3.4.4/48,M10.4.4/49\n",
+ date: func(loc *time.Location) time.Time { return time.Date(2020, time.October, 29, 15, 30, 0, 0, loc) },
+ wantName: "EET",
+ wantOffset: 7200,
+ },
+ {
+ // 2021a slim tzdata for Europe/Dublin.
+ zoneName: "Europe/Dublin",
+ tzData: "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x91\x00\x00\x00\x08\x00\x00\x00\x14\xff\xff\xff\xffW\xd1\n\xdc\xff\xff\xff\xff\x9b&\xb3\x91\xff\xff\xff\xff\x9b\xd6\x0b\x11\xff\xff\xff\xff\x9c\xcf0\xa0\xff\xff\xff\xff\x9d\xa4\xc3\xa0\xff\xff\xff\xff\x9e\x9c\x9d\xa0\xff\xff\xff\xff\x9f\x97\x1a\xa0\xff\xff\xff\xff\xa0\x85\xba\x20\xff\xff\xff\xff\xa1v\xfc\xa0\xff\xff\xff\xff\xa2e\x9c\x20\xff\xff\xff\xff\xa3{\xc8\xa0\xff\xff\xff\xff\xa4N\xb8\xa0\xff\xff\xff\xff\xa5?\xfb\x20\xff\xff\xff\xff\xa6%`\x20\xff\xff\xff\xff\xa7'\xc6\x20\xff\xff\xff\xff\xa8*,\x20\xff\xff\xff\xff\xa8\xeb\xf8\xa0\xff\xff\xff\xff\xaa\x00\xd3\xa0\xff\xff\xff\xff\xaa\xd5\x15\x20\xff\xff\xff\xff\xab\xe9\xf0\x20\xff\xff\xff\xff\xac\xc7l\x20\xff\xff\xff\xff\xad\xc9\xd2\x20\xff\xff\xff\xff\xae\xa7N\x20\xff\xff\xff\xff\xaf\xa0y\xa0\xff\xff\xff\xff\xb0\x870\x20\xff\xff\xff\xff\xb1\x92\xd0\xa0\xff\xff\xff\xff\xb2pL\xa0\xff\xff\xff\xff\xb3r\xb2\xa0\xff\xff\xff\xff\xb4P.\xa0\xff\xff\xff\xff\xb5IZ\x20\xff\xff\xff\xff\xb60\x10\xa0\xff\xff\xff\xff\xb72v\xa0\xff\xff\xff\xff\xb8\x0f\xf2\xa0\xff\xff\xff\xff\xb9\x12X\xa0\xff\xff\xff\xff\xb9\xef\xd4\xa0\xff\xff\xff\xff\xba\xe9\x00\x20\xff\xff\xff\xff\xbb\xd8\xf1\x20\xff\xff\xff\xff\xbc\xdbW\x20\xff\xff\xff\xff\xbd\xb8\xd3\x20\xff\xff\xff\xff\xbe\xb1\xfe\xa0\xff\xff\xff\xff\xbf\x98\xb5\x20\xff\xff\xff\xff\xc0\x9b\x1b\x20\xff\xff\xff\xff\xc1x\x97\x20\xff\xff\xff\xff\xc2z\xfd\x20\xff\xff\xff\xff\xc3Xy\x20\xff\xff\xff\xff\xc4Q\xa4\xa0\xff\xff\xff\xff\xc58[\x20\xff\xff\xff\xff\xc6:\xc1\x20\xff\xff\xff\xff\xc7X\xd6\xa0\xff\xff\xff\xff\xc7\xda\x09\xa0\xff\xff\xff\xff\xd4I\xe0\x20\xff\xff\xff\xff\xd5\x1e!\xa0\xff\xff\xff\xff\xd6N\xac\x20\xff\xff\xff\xff\xd7,(\x20\xff\xff\xff\xff\xd8.\x8e\x20\xff\xff\xff\xff\xd8\xf9\x95\x20\xff\xff\xff\xff\xda\x0ep\x20\xff\xff\xff\xff\xda\xeb\xec\x20\xff\xff\xff\xff\xdb\xe5\x17\xa0\xff\xff\xff\xff\xdc\xcb\xce\x20\xff\xff\xff\xff\xdd\xc4\xf9\xa0\xff\xff\xff\xff\xde\xb4\xea\xa0\xff\xff\xff\xff\xdf\xae\x16\x20\xff\xff\xff\xff\xe0\x94\xcc\xa0\xff\xff\xff\xff\xe1rH\xa0\xff\xff\xff\xff\xe2kt\x20\xff\xff\xff\xff\xe3R*\xa0\xff\xff\xff\xff\xe4T\x90\xa0\xff\xff\xff\xff\xe52\x0c\xa0\xff\xff\xff\xff\xe6=\xad\x20\xff\xff\xff\xff\xe7\x1b)\x20\xff\xff\xff\xff\xe8\x14T\xa0\xff\xff\xff\xff\xe8\xfb\x0b\x20\xff\xff\xff\xff\xe9\xfdq\x20\xff\xff\xff\xff\xea\xda\xed\x20\xff\xff\xff\xff\xeb\xddS\x20\xff\xff\xff\xff\xec\xba\xcf\x20\xff\xff\xff\xff\xed\xb3\xfa\xa0\xff\xff\xff\xff\xee\x9a\xb1\x20\xff\xff\xff\xff\xef\x81g\xa0\xff\xff\xff\xff\xf0\x9f}\x20\xff\xff\xff\xff\xf1aI\xa0\xff\xff\xff\xff\xf2\x7f_\x20\xff\xff\xff\xff\xf3Jf\x20\xff\xff\xff\xff\xf4_A\x20\xff\xff\xff\xff\xf5!\x0d\xa0\xff\xff\xff\xff\xf6?#\x20\xff\xff\xff\xff\xf7\x00\xef\xa0\xff\xff\xff\xff\xf8\x1f\x05\x20\xff\xff\xff\xff\xf8\xe0\xd1\xa0\xff\xff\xff\xff\xf9\xfe\xe7\x20\xff\xff\xff\xff\xfa\xc0\xb3\xa0\xff\xff\xff\xff\xfb\xe8\x03\xa0\xff\xff\xff\xff\xfc{\xab\xa0\xff\xff\xff\xff\xfd\xc7\xbbp\x00\x00\x00\x00\x03p\xc6\x20\x00\x00\x00\x00\x04)X\x20\x00\x00\x00\x00\x05P\xa8\x20\x00\x00\x00\x00\x06\x09:\x20\x00\x00\x00\x00\x070\x8a\x20\x00\x00\x00\x00\x07\xe9\x1c\x20\x00\x00\x00\x00\x09\x10l\x20\x00\x00\x00\x00\x09\xc8\xfe\x20\x00\x00\x00\x00\n\xf0N\x20\x00\x00\x00\x00\x0b\xb2\x1a\xa0\x00\x00\x00\x00\x0c\xd00\x20\x00\x00\x00\x00\x0d\x91\xfc\xa0\x00\x00\x00\x00\x0e\xb0\x12\x20\x00\x00\x00\x00\x0fq\xde\xa0\x00\x00\x00\x00\x10\x99.\xa0\x00\x00\x00\x00\x11Q\xc0\xa0\x00\x00\x00\x00\x12y\x10\xa0\x00\x00\x00\x00\x131\xa2\xa0\x00\x00\x00\x00\x14X\xf2\xa0\x00\x00\x00\x00\x15#\xeb\x90\x00\x00\x00\x00\x168\xc6\x90\x00\x00\x00\x00\x17\x03\xcd\x90\x00\x00\x00\x00\x18\x18\xa8\x90\x00\x00\x00\x00\x18\xe3\xaf\x90\x00\x00\x00\x00\x19\xf8\x8a\x90\x00\x00\x00\x00\x1a\xc3\x91\x90\x00\x00\x00\x00\x1b\xe1\xa7\x10\x00\x00\x00\x00\x1c\xac\xae\x10\x00\x00\x00\x00\x1d\xc1\x89\x10\x00\x00\x00\x00\x1e\x8c\x90\x10\x00\x00\x00\x00\x1f\xa1k\x10\x00\x00\x00\x00\x20lr\x10\x00\x00\x00\x00!\x81M\x10\x00\x00\x00\x00\x22LT\x10\x00\x00\x00\x00#a/\x10\x00\x00\x00\x00$,6\x10\x00\x00\x00\x00%JK\x90\x00\x00\x00\x00&\x0c\x18\x10\x00\x00\x00\x00'*-\x90\x00\x00\x00\x00'\xf54\x90\x00\x00\x00\x00)\n\x0f\x90\x00\x00\x00\x00)\xd5\x16\x90\x00\x00\x00\x00*\xe9\xf1\x90\x00\x00\x00\x00+\xb4\xf8\x90\x00\x00\x00\x00,\xc9\xd3\x90\x00\x00\x00\x00-\x94\xda\x90\x00\x00\x00\x00.\xa9\xb5\x90\x00\x00\x00\x00/t\xbc\x90\x00\x00\x00\x000\x89\x97\x90\x00\x00\x00\x001]\xd9\x10\x01\x02\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x04\x05\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\x06\x07\xff\xff\xfa$\x00\x00\xff\xff\xfa\x0f\x00\x04\x00\x00\x08\x1f\x01\x08\x00\x00\x0e\x10\x01\x0c\x00\x00\x00\x00\x00\x10\x00\x00\x0e\x10\x01\x08\x00\x00\x00\x00\x01\x10\x00\x00\x0e\x10\x00\x08LMT\x00DMT\x00IST\x00BST\x00GMT\x00\nIST-1GMT0,M10.5.0,M3.5.0/1\n",
+ date: func(loc *time.Location) time.Time { return time.Date(2021, time.April, 2, 11, 12, 13, 0, loc) },
+ wantName: "IST",
+ wantOffset: 3600,
+ },
+}
- reference, err := time.LoadLocationFromTZData("Europe/Berlin", []byte(tzData))
- if err != nil {
- t.Fatal(err)
- }
+func TestLoadLocationFromTZDataSlim(t *testing.T) {
+ for _, test := range slimTests {
+ reference, err := time.LoadLocationFromTZData(test.zoneName, []byte(test.tzData))
+ if err != nil {
+ t.Fatal(err)
+ }
- d := time.Date(2020, time.October, 29, 15, 30, 0, 0, reference)
- tzName, tzOffset := d.Zone()
- if want := "CET"; tzName != want {
- t.Errorf("Zone name == %s, want %s", tzName, want)
- }
- if want := 3600; tzOffset != want {
- t.Errorf("Zone offset == %d, want %d", tzOffset, want)
+ d := test.date(reference)
+ tzName, tzOffset := d.Zone()
+ if tzName != test.wantName {
+ t.Errorf("Zone name == %s, want %s", tzName, test.wantName)
+ }
+ if tzOffset != test.wantOffset {
+ t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset)
+ }
}
}
@@ -211,20 +251,21 @@
off int
start int64
end int64
+ isDST bool
ok bool
}{
- {"", 0, 0, "", 0, 0, 0, false},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2159200800, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173599, "PST", -8 * 60 * 60, 2145916800, 2152173600, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173600, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173601, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733199, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733200, "PST", -8 * 60 * 60, 2172733200, 2177452800, true},
- {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733201, "PST", -8 * 60 * 60, 2172733200, 2177452800, true},
+ {"", 0, 0, "", 0, 0, 0, false, false},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2159200800, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173599, "PST", -8 * 60 * 60, 2145916800, 2152173600, false, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173600, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2152173601, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733199, "PDT", -7 * 60 * 60, 2152173600, 2172733200, true, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733200, "PST", -8 * 60 * 60, 2172733200, 2177452800, false, true},
+ {"PST8PDT,M3.2.0,M11.1.0", 0, 2172733201, "PST", -8 * 60 * 60, 2172733200, 2177452800, false, true},
} {
- name, off, start, end, ok := time.Tzset(test.inStr, test.inEnd, test.inSec)
- if name != test.name || off != test.off || start != test.start || end != test.end || ok != test.ok {
- t.Errorf("tzset(%q, %d, %d) = %q, %d, %d, %d, %t, want %q, %d, %d, %d, %t", test.inStr, test.inEnd, test.inSec, name, off, start, end, ok, test.name, test.off, test.start, test.end, test.ok)
+ name, off, start, end, isDST, ok := time.Tzset(test.inStr, test.inEnd, test.inSec)
+ if name != test.name || off != test.off || start != test.start || end != test.end || isDST != test.isDST || ok != test.ok {
+ t.Errorf("tzset(%q, %d, %d) = %q, %d, %d, %d, %t, %t, want %q, %d, %d, %d, %t, %t", test.inStr, test.inEnd, test.inSec, name, off, start, end, isDST, ok, test.name, test.off, test.start, test.end, test.isDST, test.ok)
}
}
}
@@ -263,7 +304,8 @@
{"+08", 8 * 60 * 60, "", true},
{"-01:02:03", -1*60*60 - 2*60 - 3, "", true},
{"01", 1 * 60 * 60, "", true},
- {"100", 0, "", false},
+ {"100", 100 * 60 * 60, "", true},
+ {"1000", 0, "", false},
{"8PDT", 8 * 60 * 60, "PDT", true},
} {
off, out, ok := time.TzsetOffset(test.in)
@@ -288,6 +330,7 @@
{"30/03:00:00", time.Rule{Kind: time.RuleDOY, Day: 30, Time: 3 * 60 * 60}, "", true},
{"M4.5.6/03:00:00", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: 3 * 60 * 60}, "", true},
{"M4.5.7/03:00:00", time.Rule{}, "", false},
+ {"M4.5.6/-04", time.Rule{Kind: time.RuleMonthWeekDay, Mon: 4, Week: 5, Day: 6, Time: -4 * 60 * 60}, "", true},
} {
r, out, ok := time.TzsetRule(test.in)
if r != test.r || out != test.out || ok != test.ok {
diff -Nru golang-1.15-1.15.9/src/vendor/golang.org/x/net/http/httpguts/httplex.go golang-1.15-1.15.15/src/vendor/golang.org/x/net/http/httpguts/httplex.go
--- golang-1.15-1.15.9/src/vendor/golang.org/x/net/http/httpguts/httplex.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/vendor/golang.org/x/net/http/httpguts/httplex.go 2021-08-05 05:20:40.000000000 +0800
@@ -137,11 +137,13 @@
// contains token amongst its comma-separated tokens, ASCII
// case-insensitively.
func headerValueContainsToken(v string, token string) bool {
- v = trimOWS(v)
- if comma := strings.IndexByte(v, ','); comma != -1 {
- return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token)
+ for comma := strings.IndexByte(v, ','); comma != -1; comma = strings.IndexByte(v, ',') {
+ if tokenEqual(trimOWS(v[:comma]), token) {
+ return true
+ }
+ v = v[comma+1:]
}
- return tokenEqual(v, token)
+ return tokenEqual(trimOWS(v), token)
}
// lowerASCII returns the ASCII lowercase version of b.
diff -Nru golang-1.15-1.15.9/src/vendor/modules.txt golang-1.15-1.15.15/src/vendor/modules.txt
--- golang-1.15-1.15.9/src/vendor/modules.txt 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/src/vendor/modules.txt 2021-08-05 05:20:40.000000000 +0800
@@ -8,7 +8,7 @@
golang.org/x/crypto/hkdf
golang.org/x/crypto/internal/subtle
golang.org/x/crypto/poly1305
-# golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91
+# golang.org/x/net v0.0.0-20210428183841-261fb518b1ed
## explicit
golang.org/x/net/dns/dnsmessage
golang.org/x/net/http/httpguts
diff -Nru golang-1.15-1.15.9/test/escape5.go golang-1.15-1.15.15/test/escape5.go
--- golang-1.15-1.15.9/test/escape5.go 2021-03-10 22:29:38.000000000 +0800
+++ golang-1.15-1.15.15/test/escape5.go 2021-08-05 05:20:40.000000000 +0800
@@ -262,3 +262,14 @@
return 1 + f28369(n-1)
}
+
+// Issue 44614: parameters that flow to a heap-allocated result
+// parameter must be recorded as a heap-flow rather than a
+// result-flow.
+
+// N.B., must match "leaking param: p",
+// but *not* "leaking param: p to result r level=0".
+func f(p *int) (r *int) { // ERROR "leaking param: p$" "moved to heap: r"
+ sink4 = &r
+ return p
+}
diff -Nru golang-1.15-1.15.9/test/fixedbugs/issue42876.go golang-1.15-1.15.15/test/fixedbugs/issue42876.go
--- golang-1.15-1.15.9/test/fixedbugs/issue42876.go 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/test/fixedbugs/issue42876.go 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,18 @@
+// run
+
+// Copyright 2020 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.
+
+package main
+
+var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4}
+
+func main() {
+ if x[0] > x[1] {
+ panic("fail 1")
+ }
+ if x[2]&x[3] < 0 {
+ panic("fail 2") // Fails here
+ }
+}
diff -Nru golang-1.15-1.15.9/test/fixedbugs/issue45175.go golang-1.15-1.15.15/test/fixedbugs/issue45175.go
--- golang-1.15-1.15.9/test/fixedbugs/issue45175.go 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/test/fixedbugs/issue45175.go 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,29 @@
+// run
+
+// Copyright 2021 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.
+
+package main
+
+//go:noinline
+func f(c bool) int {
+ b := true
+ x := 0
+ y := 1
+ for b {
+ b = false
+ y = x
+ x = 2
+ if c {
+ return 3
+ }
+ }
+ return y
+}
+
+func main() {
+ if got := f(false); got != 0 {
+ panic(got)
+ }
+}
diff -Nru golang-1.15-1.15.9/test/fixedbugs/issue46653.dir/bad/bad.go golang-1.15-1.15.15/test/fixedbugs/issue46653.dir/bad/bad.go
--- golang-1.15-1.15.9/test/fixedbugs/issue46653.dir/bad/bad.go 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/test/fixedbugs/issue46653.dir/bad/bad.go 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,64 @@
+// Copyright 2021 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.
+
+package a
+
+func Bad() {
+ m := make(map[int64]A)
+ a := m[0]
+ if len(a.B.C1.D2.E2.F1) != 0 ||
+ len(a.B.C1.D2.E2.F2) != 0 ||
+ len(a.B.C1.D2.E2.F3) != 0 ||
+ len(a.B.C1.D2.E2.F4) != 0 ||
+ len(a.B.C1.D2.E2.F5) != 0 ||
+ len(a.B.C1.D2.E2.F6) != 0 ||
+ len(a.B.C1.D2.E2.F7) != 0 ||
+ len(a.B.C1.D2.E2.F8) != 0 ||
+ len(a.B.C1.D2.E2.F9) != 0 ||
+ len(a.B.C1.D2.E2.F10) != 0 ||
+ len(a.B.C1.D2.E2.F11) != 0 ||
+ len(a.B.C1.D2.E2.F16) != 0 {
+ panic("bad")
+ }
+}
+
+type A struct {
+ B
+}
+
+type B struct {
+ C1 C
+ C2 C
+}
+
+type C struct {
+ D1 D
+ D2 D
+}
+
+type D struct {
+ E1 E
+ E2 E
+ E3 E
+ E4 E
+}
+
+type E struct {
+ F1 string
+ F2 string
+ F3 string
+ F4 string
+ F5 string
+ F6 string
+ F7 string
+ F8 string
+ F9 string
+ F10 string
+ F11 string
+ F12 string
+ F13 string
+ F14 string
+ F15 string
+ F16 string
+}
diff -Nru golang-1.15-1.15.9/test/fixedbugs/issue46653.dir/main.go golang-1.15-1.15.15/test/fixedbugs/issue46653.dir/main.go
--- golang-1.15-1.15.9/test/fixedbugs/issue46653.dir/main.go 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/test/fixedbugs/issue46653.dir/main.go 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,27 @@
+// Copyright 2021 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.
+
+package main
+
+import (
+ bad "issue46653.dir/bad"
+)
+
+func main() {
+ bad.Bad()
+}
+
+func neverCalled() L {
+ m := make(map[string]L)
+ return m[""]
+}
+
+type L struct {
+ A Data
+ B Data
+}
+
+type Data struct {
+ F1 [22][]string
+}
diff -Nru golang-1.15-1.15.9/test/fixedbugs/issue46653.go golang-1.15-1.15.15/test/fixedbugs/issue46653.go
--- golang-1.15-1.15.9/test/fixedbugs/issue46653.go 1970-01-01 08:00:00.000000000 +0800
+++ golang-1.15-1.15.15/test/fixedbugs/issue46653.go 2021-08-05 05:20:40.000000000 +0800
@@ -0,0 +1,10 @@
+// runindir
+
+// Copyright 2021 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.
+
+// Test to verify compiler and linker handling of multiple
+// competing map.zero symbol definitions.
+
+package ignored
diff -Nru golang-1.15-1.15.9/VERSION golang-1.15-1.15.15/VERSION
--- golang-1.15-1.15.9/VERSION 2021-03-10 22:31:50.000000000 +0800
+++ golang-1.15-1.15.15/VERSION 2021-08-05 05:20:50.000000000 +0800
@@ -1 +1 @@
-go1.15.9
\ No newline at end of file
+go1.15.15
\ No newline at end of file
Reply to: