1
0
mirror of https://github.com/golang/go synced 2024-09-24 17:20:12 -06:00
Commit Graph

50505 Commits

Author SHA1 Message Date
smasher164
ab31dbc05b doc/go1.18: strings,bytes: deprecate Title
Updates #48367.

Change-Id: Ib8fc6d9dd7c3c6a70fefe077615f51a71d9c42ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/361899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-08 14:49:56 +00:00
jiahua wang
9e6ad46bcc net/http: fix spelling in documentation
Change-Id: I8b0924300eafe27de98975512a78a6527a92e446
Reviewed-on: https://go-review.googlesource.com/c/go/+/354729
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Damien Neil <dneil@google.com>
2021-11-07 04:57:22 +00:00
Arran Walker
85493d53e3 archive/zip: don't read data descriptor early
Go 1.17 introduced an unnecessary change to when a zip's data descriptor
is read for file entries, how it is parsed and how the crc32 field is
used.

Before Go 1.17, the data descriptor was read immediately after a file
entry's content. This continuous read is a pattern existing applications
have come to rely upon (for example, where reads at specific offsets
might be translated to HTTP range requests).

In Go 1.17, all data descriptors are immediately read upon opening the
file. This results in scattered and non-continuous reads of the archive,
and depending on the underlying reader, might have severe performance
implications. In addition, an additional object is now initialized for
each entry, but is mostly redundant.

Previously, the crc32 field in the data descriptor would return an error
if it did not match the central directory's entry. This check has
seemingly been unintentionally removed. If the central directory crc32
is invalid and a data descriptor is present, no error is returned.

This change reverts to the previous handling of data descriptors, before
CL 312310.

Fixes #48374
Fixes #49089

Change-Id: I5df2878c4fcc9e500064e7175f3ab9727c82f100
Reviewed-on: https://go-review.googlesource.com/c/go/+/357489
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-07 04:56:11 +00:00
Robert Griesemer
61d789db3a cmd/compile/internal/types2: report error for incomplete struct composite literal type
Mark a struct as "complete" with a non-nil (but possibly zero length)
fields list. Add a test when type-checking struct composite literals,
the same way we do for other composite literal types.

Fixes #49276.

Change-Id: If44a3d790bf7032ddcd155af49bdc47b1cdff4fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/361412
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-06 19:41:15 +00:00
Robert Griesemer
cfb3dc7710 cmd/compile/internal/types2: clearer object string for type parameters
- print "type parameter" rather than just "type"
- print the type bound rather than the underlying type
- added an object string test

Change-Id: Ibb572ff35b74f2c6ccb27641154f096770541130
Reviewed-on: https://go-review.googlesource.com/c/go/+/361401
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-06 19:41:14 +00:00
Robert Griesemer
7ca772a5bc cmd/compile/internal/types2: make object test an external test
Change-Id: I15c969a799404067f34f600da15b1a97d4857315
Reviewed-on: https://go-review.googlesource.com/c/go/+/361409
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-06 19:41:12 +00:00
Robert Griesemer
565f457e81 cmd/compile/internal/types2: always parse tests assuming generic code
We don't need to distinguish anymore as this is the new default.
This removes the need to prefix test package names with "generic_".

Change-Id: If9eaa0a5cffcd19deb529aca6798206f2d396ca1
Reviewed-on: https://go-review.googlesource.com/c/go/+/361408
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-11-06 19:41:10 +00:00
Roland Shoemaker
3544082f75 crypto/x509: verification with system and custom roots
Make system cert pools special, such that when one has extra roots
added to it we run verifications twice, once using the platform
verifier, if available, and once using the Go verifier, merging the
results.

This change re-enables SystemCertPool on Windows, but explicitly does
not return anything from CertPool.Subjects (which matches the behavior
of macOS). CertPool.Subjects is also marked deprecated.

Fixes #46287
Fixes #16736

Change-Id: Idc1843f715ae2b2d0108e55ab942c287181a340a
Reviewed-on: https://go-review.googlesource.com/c/go/+/353589
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
2021-11-06 16:43:43 +00:00
hanpro
4f083c7dcf cmd/compile: avoid adding LECall to the entry block when has opendefers
The openDeferRecord always insert vardef/varlive pairs into the entry block, it may destroy the mem chain when LECall's args are writing into the same block. So create a new block before that happens.

Fixes #49282

Change-Id: Ibda6c4a45d960dd412a641f5e02276f663c80785
Reviewed-on: https://go-review.googlesource.com/c/go/+/361410
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
2021-11-06 13:10:06 +00:00
Tobias Klauser
f19e400180 all: remove more leftover // +build lines
CL 344955 and CL 359476 removed almost all // +build lines, but leaving
some assembly files and generating scripts. Also, some files were added
with // +build lines after CL 359476 was merged. Remove these or rename
files where more appropriate.

For #41184

Change-Id: I7eb85a498ed9788b42a636e775f261d755504ffa
Reviewed-on: https://go-review.googlesource.com/c/go/+/361480
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-06 10:24:44 +00:00
Roland Shoemaker
b74f2efc47 crypto/x509: use the platform verifier on iOS
Use the same certificate verification APIs on iOS as on macOS (they
share the same APIs, so we should be able to transparently use them
on both.)

Updates #46287
Fixes #38843

Change-Id: If70f99b0823dd5fa747c42ff4f20c3b625605327
Reviewed-on: https://go-review.googlesource.com/c/go/+/353403
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
2021-11-06 00:29:44 +00:00
Michael Anthony Knyszek
09e8de70c2 runtime: eliminate rendundant loads gcPercent
The previous change was an automated change that made gcPercent a
type-safe atomic variable. However, that introduced a lot of redundant
formal atomic loads of the variable. Remove them by only loading once in
each case, and reusing the value.

Change-Id: I49647135f423574f94506d456d1cc390150fad02
Reviewed-on: https://go-review.googlesource.com/c/go/+/357795
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 22:57:08 +00:00
Michael Anthony Knyszek
2f71c86370 runtime: retype gcControllerState.gcPercent as atomic.Int32
[git-generate]
cd src/runtime
mv export_test.go export.go
GOROOT=$(dirname $(dirname $PWD)) rf '
  add gcControllerState.gcPercent \
// Initialized from GOGC. GOGC=off means no GC. \
gcPercent_ atomic.Int32
  ex {
    import "runtime/internal/atomic"

    var t gcControllerState
    var v, w int32
    var d int32

    t.gcPercent -> t.gcPercent_.Load()
    t.gcPercent = v -> t.gcPercent_.Store(v)
    atomic.Loadint32(&t.gcPercent) -> t.gcPercent_.Load()
    atomic.Storeint32(&t.gcPercent, v) -> t.gcPercent_.Store(v)
    atomic.Xaddint32(&t.gcPercent, d) -> t.gcPercent_.Add(d)
    atomic.Casint32(&t.gcPercent, v, w) -> t.gcPercent_.CompareAndSwap(v, w)
    atomic.Xchgint32(&t.gcPercent, v) -> t.gcPercent_.Swap(v)
  }
  rm gcControllerState.gcPercent
  mv gcControllerState.gcPercent_ gcControllerState.gcPercent
'
mv export.go export_test.go

Change-Id: I1aae34a3f782d096c6b6233bbf7986e67ce9c5f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/357794
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 22:56:55 +00:00
Josh Bleecher Snyder
e83a2047e0 net/netip: document the zero Addr
Fixes #49364

Change-Id: I3372f80723a4deae48ef106f88b0ad880cdd0e45
Reviewed-on: https://go-review.googlesource.com/c/go/+/361914
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 22:55:56 +00:00
Dmitri Shuralyov
ba79c1e241 doc/go1.18: split bytes and strings packages
A small touchup after CL 361894.

For #47694.

Change-Id: Ifc161516f897f727195d21351a3c8eda7b6e327e
Reviewed-on: https://go-review.googlesource.com/c/go/+/361895
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Carlos Amedee <carlos@golang.org>
2021-11-05 22:54:47 +00:00
Josh Bleecher Snyder
3b7e376df8 net/netip: add tests for Addr.AsSlice
Change-Id: Ib88dd101b3bbdf4d2bfd79838994cfadef1b604d
Reviewed-on: https://go-review.googlesource.com/c/go/+/361915
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 22:53:55 +00:00
Jason A. Donenfeld
b07c41d2c1 net/netip: add IPv4Unspecified
There is IPv6Unspecified but there is not IPv4Unspecified, making for
inconsistent code. This commit adds the missing function.

Updates #49298.

Change-Id: Id2519b646323642f59fb1cc6ea8e335fdde16290
Reviewed-on: https://go-review.googlesource.com/c/go/+/361056
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 22:30:17 +00:00
Jason A. Donenfeld
87a3fc518a net/netip: reduce allocations in MarshalBinary
Addr's MarshalBinary required two allocations in the case of a zone
existing, and AddrPort and Prefix both required three. This refactors
things slightly so that each marshal function only needs a single
allocation.

Change-Id: I9bde9969fedc1cad64bebb607188c4287f6a0d01
Reviewed-on: https://go-review.googlesource.com/c/go/+/361054
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 22:28:56 +00:00
Roland Shoemaker
feb024f415 crypto/x509: use platform verifier on darwin
When VerifyOptions.Roots is nil, default to using the platform X.509
certificate verification APIs on darwin, rather than using the Go
verifier. Since our oldest supported version of macOS is 10.12, we are
able to use the modern verification APIs, and don't need to resort to
the complex chain building trickery employed by chromium et al.

Unfortunately there is not a clean way to programmatically add test
roots to the system trust store that the builders would tolerate. The
most obvious solution, using 'security add-trusted-cert' requires human
interaction for authorization. We could also manually add anchors to
the constructed SecTrustRef, but that would require adding a whole
bunch of plumbing for test functionality, and would mean we weren't
really testing the actual non-test path. The path I've chosen here is
to just utilize existing valid, and purposefully invalid, trusted
chains, from google.com and the badssl.com test suite. This requires
external network access, but most accurately reflects real world
contexts.

This change removes the x509.SystemCertPool() functionality, which will
be ammended in a follow-up change which supports the suggested hybrid
pool approach described in #46287.

Updates #46287
Fixes #42414
Fixes #38888
Fixes #35631
Fixes #19561

Change-Id: I17f0d6c5cb3ef8a1f2731ce3296478b28d30df46
Reviewed-on: https://go-review.googlesource.com/c/go/+/353132
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 22:28:32 +00:00
Jason A. Donenfeld
8f923a4e3c net/netip: add missing encoding.BinaryUnmarshaler to AddrPort and Prefix
The Addr type got an encoding.BinaryUnmarshaler implementation, but not
AddrPort and Prefix. This commit adds the missing implementation of that
interface to these types. It also adds two round trip tests that follow
the template of the existing one for Addr.

Updates #49298.

Change-Id: Iac633aed8aac579960815bb64d06ff3181214841
Reviewed-on: https://go-review.googlesource.com/c/go/+/360875
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 22:27:21 +00:00
Jason A. Donenfeld
d3a80c795e net/netip: add Addr.AsSlice() method
We have AddrFrom4, AddrFrom6, AddrFromSlice and As4, As6, but we are
missing AsSlice, so this commit adds the missing function. It also gets
rid of the less ergonomic and inconsistently named IPAddrParts.

Updates #49298.

Change-Id: I1c6a2c32fc6c69b244ab49765412ffe3bbe7e5c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/360874
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 22:26:07 +00:00
Filippo Valsorda
35a588109b net: accept "." as a valid domain name
Fixes #45715

Change-Id: Ibdaa91c97d34473061b377325ebe9a3bf5696c8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/360314
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-05 22:23:52 +00:00
Filippo Valsorda
035963c7f5 crypto/tls: set default minimum client version to TLS 1.2
Updates #45428

Change-Id: I5d70066d4091196ec6f8bfc2edf3d78fdc0520c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/359779
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-11-05 22:03:24 +00:00
Dmitri Shuralyov
f00b43f28c doc/go1.18: fill in Go 1.18 release note TODOs using relnote
For #47694.

Change-Id: Ia80a1859bd0fc6f08d27293f519c22fd9a804fd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/361894
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2021-11-05 22:00:37 +00:00
Michael Matloob
755ede0c5b cmd/go: fix bugs in replacement path handling
These are tested in golang.org/cl/357169 and golang.org/cl/358540.

Change-Id: I5add3f202db71731487f2688234c547abe1fd287
Reviewed-on: https://go-review.googlesource.com/c/go/+/361416
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-05 22:00:16 +00:00
Filippo Valsorda
6b223e872a crypto/x509: disable SHA-1 signature verification
Updates #41682

Change-Id: Ib766d2587d54dd3aeff8ecab389741df5e8af7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/359777
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-11-05 21:48:25 +00:00
Nevkontakte
bb53fd740c net/http: adjust a substring which matches "uninteresting" goroutine
This change allows the check to pass unmodified under GopherJS, which
stack traces are formatted differently (due to being generated by
NodeJS). There are no other functions named `interestingGoroutines` in
the standard library, so it's very unlikely to create false negatives,
and will allow reduce the number of overlays GopherJS needs to maintain.

Change-Id: I925594c6c313ca35805811f240c8528241950547
GitHub-Last-Rev: 26b32efb22
GitHub-Pull-Request: golang/go#49128
Reviewed-on: https://go-review.googlesource.com/c/go/+/358154
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Damien Neil <dneil@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 21:34:10 +00:00
jiahua wang
75952abc6a unicode/utf8: add AppendRune Example
Also, correct TestAppendRune error message.

Change-Id: I3ca3ac7051af1ae6d449381b78efa86c2f6be8ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/354529
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Trust: Robert Findley <rfindley@google.com>
Trust: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 21:29:18 +00:00
jiahua wang
fb8b1764d8 errors: add errors.Unwrap example
Change-Id: Id2336a6059f7a8d627e6c0661a4d4c05485b65f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/355589
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Trust: Robert Findley <rfindley@google.com>
2021-11-05 21:28:50 +00:00
zhouguangyuan
90462dfc3a time: fix looking for zone offset when date is close to a zone transition
The old implement passed start - 1 or end in func lookup to adjust the offset.But if the time is close to the last zoneTrans, like the issue, testcase and comment, the "start" from lookup will be omega. It can't be adjusted correctly.

Fixes #49284

Change-Id: Ibaf82dc4db6d5dd3279796f003d2b19c38a26341
Reviewed-on: https://go-review.googlesource.com/c/go/+/360616
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-11-05 21:28:34 +00:00
jiahua wang
ad6ce55a55 time: add some examples
Change-Id: I2668cdea64f75bee87d424730d404834d69362a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/357270
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-11-05 21:28:07 +00:00
smasher164
7aed6dd7e1 strings, bytes: deprecate Title
Title doesn't handle Unicode punctuation and language-specific
capitalization rules. Replace the BUG comment with a Deprecated
one, suggesting a more robust alternative, and allowing Title
to be exposed to tooling.

Fixes #48367.

Change-Id: I952f1f37cd35b587a95893fb022827bdd9ec7de9
Reviewed-on: https://go-review.googlesource.com/c/go/+/359485
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-11-05 21:27:34 +00:00
Dan Kortschak
58ec925270 debug/plan9obj: export ErrNoSymbols
This allows callers of *File.Symbols to distinguish absence of symbols
from other errors as can already by done in debug/elf.

Fixes #48052

Change-Id: I5ba15d8473911e516c016a69c1f1c710f7fc4cd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/350229
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-05 21:27:19 +00:00
jiahua wang
3e9e02412e bytes: add example with (*Buffer).Cap, (*Buffer).Read, (*Buffer).ReadByte
Change-Id: Ieb107fdfccde9f054491f667a384b16f7af71dea
Reviewed-on: https://go-review.googlesource.com/c/go/+/355289
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-11-05 21:26:54 +00:00
Charlie Getzen
4c7cafdd03 net/http: distinguish between timeouts and client hangups in TimeoutHandler
Fixes #48948

Change-Id: I411e3be99c7979ae289fd937388aae63d81adb59
GitHub-Last-Rev: 14abd7e4d7
GitHub-Pull-Request: golang/go#48993
Reviewed-on: https://go-review.googlesource.com/c/go/+/356009
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 21:18:28 +00:00
zhouguangyuan
091948a55f time: make Ticker.Reset(0) panic
Fixes #49315

Change-Id: I0887bad1059b25ae0749bfa1ed6ddccbecca7951
Reviewed-on: https://go-review.googlesource.com/c/go/+/361074
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-11-05 21:13:38 +00:00
Keiichi Hirobe
dbd3cf8849 net/http: fix comment of writeRequest
Change-Id: I5ebfc6a89323cc086ea0e0b619370dc45da1f3a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/345437
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 20:59:43 +00:00
Austin Clements
71559a6ffd runtime: fix racy stackForceMove check
Currently, newstack loads gp.stackguard0 twice to check for different
poison values. The race window between these two checks can lead to
unintentional stack doubling, and ultimately to stack overflows.

Specifically, newstack checks if stackguard0 is stackPreempt first,
then it checks if it's stackForceMove. If stackguard0 is set to
stackForceMove on entry, but changes to stackPreempt between the two
checks, newstack will incorrectly double the stack allocation.

Fix this by loading stackguard0 exactly once and then checking it
against different poison values.

The effect of this is relatively minor because stackForceMove is only
used by a small number of runtime tests. I found this because
mayMorestackMove uses stackForceMove aggressively, which makes this
failure mode much more likely.

Change-Id: I1f8b6a6744e45533580a3f45d7030ec2ec65a5fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/361775
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 20:59:32 +00:00
Bryan C. Mills
7be227ccd0 cmd/go: don't assume case-insensitivity in TestScript/gcflags_patterns
For #30432

Change-Id: I84f208705483018559b425b3669e724e7d5627ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/361814
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-05 20:06:27 +00:00
Lynn Boger
c353f1b41d crypt/aes: update formatting of ppc64le asm comments
This does not change any code, just reformats the comments in
the asm code.

Change-Id: I70fbfa77db164898d25b59b589d3e85b8399b0fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/361694
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-11-05 19:48:29 +00:00
Paul E. Murphy
fa16efb835 cmd/link: enable internal linking of PIE binaries on ppc64le
The amd64/arm64 relocation processing is used as a template
and updated for ppc64le.

This requires updating the TOC relocation handling code to
support linux type TOC relocations too (note, AIX uses
TOC-indirect accesses).

Noteably, the shared flag of go functions is used as a proxy
for the local entry point offset encoded in elf objects. Functions
in go ppc64le shared objects always[1] insert 2 instructions to
regenerate the TOC pointer.

[1] excepting a couple special runtime functions, see preprocess
    in obj9.go for specific details of this behavior.

Change-Id: I3646e6dc8a0a0ffe712771a976983315eae5c418
Reviewed-on: https://go-review.googlesource.com/c/go/+/352829
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-11-05 19:14:22 +00:00
Filippo Valsorda
93bab8a2f9 crypto/elliptic: port P-224 and P-384 to fiat-crypto
Also, adopt addchain code generation for field inversion, and switch
P-521 to Montgomery multiplication, which is significantly slower but
allows us to reuse the P-224/P-256/P-384 wrapper code. No one uses P-521
anyway, and it's still faster than it was in Go 1.16.

Removed a portion of tests that ran the P-224 vectors against P-256,
for some reason.

Sadly, fiat-crypto is not fast enough to replace the generic 32-bit
P-256 implementation (just yet?).

A change in visible behavior is that we literally can't internally
operate on invalid curve points anymore (yay!) but the crypto/elliptic
API locked us into accepting any pair of integers for
Add/Double/ScalarMult and return no error (sigh), although of course
that's undefined behavior. Panics are always regretted. Returning nil
leads to panics. A fixed point might be exploited. The most reasonable
solution felt to return a made up random point, which is not that
different from an off-curve point but leaks less.

name                                  old time/op    new time/op    delta
pkg:crypto/elliptic goos:darwin goarch:arm64
ScalarBaseMult/P224-8                    573µs ± 0%     146µs ± 0%   -74.56%  (p=0.000 n=7+9)
ScalarMult/P224-8                        574µs ± 0%     152µs ± 5%   -73.58%  (p=0.000 n=7+10)
MarshalUnmarshal/P224/Uncompressed-8     664ns ± 0%     481ns ± 1%   -27.64%  (p=0.000 n=8+10)
MarshalUnmarshal/P224/Compressed-8       666ns ± 1%     480ns ± 0%   -27.92%  (p=0.000 n=10+10)
pkg:crypto/ecdsa goos:darwin goarch:arm64
Sign/P224-8                              597µs ± 0%     169µs ± 2%   -71.71%  (p=0.000 n=10+9)
Verify/P224-8                           1.18ms ± 1%    0.32ms ± 5%   -72.81%  (p=0.000 n=10+10)
GenerateKey/P224-8                       577µs ± 0%     147µs ± 0%   -74.51%  (p=0.000 n=8+8)

name                                  old time/op    new time/op    delta
pkg:crypto/elliptic goos:darwin goarch:arm64
ScalarBaseMult/P384-8                   2.01ms ± 2%    0.50ms ± 0%  -75.00%  (p=0.000 n=10+8)
ScalarMult/P384-8                       2.02ms ± 3%    0.51ms ± 3%  -74.64%  (p=0.000 n=10+10)
MarshalUnmarshal/P384/Uncompressed-8    1.09µs ± 1%    0.76µs ± 0%  -30.27%  (p=0.000 n=10+9)
MarshalUnmarshal/P384/Compressed-8      1.08µs ± 0%    0.76µs ± 1%  -29.86%  (p=0.000 n=8+10)
pkg:crypto/ecdsa goos:darwin goarch:arm64
Sign/P384-8                             2.06ms ± 1%    0.56ms ± 2%  -72.76%  (p=0.000 n=10+10)
Verify/P384-8                           4.06ms ± 2%    1.08ms ± 0%  -73.49%  (p=0.000 n=10+8)
GenerateKey/P384-8                      2.01ms ± 1%    0.51ms ± 3%  -74.65%  (p=0.000 n=10+10)

name                                  old time/op    new time/op    delta
pkg:crypto/elliptic goos:darwin goarch:arm64
ScalarBaseMult/P521-8                    715µs ± 6%    1525µs ± 4%  +113.39%  (p=0.000 n=10+10)
ScalarMult/P521-8                        698µs ± 1%    1543µs ± 1%  +120.99%  (p=0.000 n=9+9)
MarshalUnmarshal/P521/Uncompressed-8     797ns ± 0%    1296ns ± 0%   +62.65%  (p=0.000 n=10+9)
MarshalUnmarshal/P521/Compressed-8       798ns ± 0%    1299ns ± 1%   +62.82%  (p=0.000 n=8+10)
pkg:crypto/ecdsa goos:darwin goarch:arm64
Sign/P521-8                              810µs ± 3%    1645µs ± 0%  +103.03%  (p=0.000 n=10+10)
Verify/P521-8                           1.42ms ± 1%    3.19ms ± 1%  +125.28%  (p=0.000 n=10+8)
GenerateKey/P521-8                       698µs ± 1%    1549µs ± 0%  +121.87%  (p=0.000 n=10+7)

Updates #40171

Change-Id: I34edf5002b5e9fad0ebb6c1e2119fb123ea6d18f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360014
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05 19:01:13 +00:00
Bryan C. Mills
53bab198d9 runtime: skip TestNoShrinkStackWhileParking on netbsd/arm64
This test appears to deadlock frequently on the only netbsd-arm64
builder we have (netbsd-arm64-bsiegert). Skip the test to provide
more useful test coverage for other failures.

For #49382

Change-Id: I3be32f58ce1e396f7c69163e70cf58f779f57ac6
Reviewed-on: https://go-review.googlesource.com/c/go/+/361615
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2021-11-05 18:20:07 +00:00
Michael Anthony Knyszek
df1837799d runtime: make consistentHeapStats acquire/release nosplit
consistentHeapStats is updated during a stack allocation, so a stack
growth during an acquire or release could cause another acquire to
happen before the operation completes fully. This may lead to an invalid
sequence number.

Fixes #49395.

Change-Id: I41ce3393dff80201793e053d4d6394d7b211a5b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/361158
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2021-11-05 17:52:30 +00:00
Michael Anthony Knyszek
6f32d2050d runtime: pace the scavenger according to 1% of overall CPU time
Currently the scavenger is paced to 1% of 1 CPU because it had
scalability problems. As of the last few CLs, that should be largely
resolved. This change resolves the TODO and paces the scavenger
according to 1% of overall CPU time.

This change is made separately to allow it to be more easily rolled
back.

Change-Id: I1ab4de24ba41c564960701634a128a813c55ece9
Reviewed-on: https://go-review.googlesource.com/c/go/+/358675
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 17:47:28 +00:00
Michael Anthony Knyszek
e48e4b4cbb runtime: use a controller to control the scavenge rate
Currently the scavenge rate is determined by a bunch of ad-hoc
mechanisms. Just use a controller instead, now that we have one.

To facilitate this, the scavenger now attempts to scavenge for at least
1 ms at a time, because any less and the timer system is too imprecise to
give useful feedback to the controller. Also increase the amount that we
scavenge at once, to try to reduce the overheads involved (at the
expense of a little bit of latency).

This change also modifies the controller to accept an update period,
because it's useful to allow that to be variable.

Change-Id: I8a15b2355d0a7c6cbac68c957082d5819618f7d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/353975
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 17:46:59 +00:00
Michael Anthony Knyszek
f063e0da28 runtime: add harddecommit GODEBUG flag
This change adds a new debug flag that makes the runtime map pages
PROT_NONE in sysUnused on Linux, in addition to the usual madvise calls.
This behavior mimics the behavior of decommit on Windows, and is helpful
in debugging the scavenger. sysUsed is also updated to re-map the pages
as PROT_READ|PROT_WRITE, mimicing Windows' explicit commit behavior.

Change-Id: Iaac5fcd0e6920bd1d0e753dd4e7f0c0b128fe842
Reviewed-on: https://go-review.googlesource.com/c/go/+/356612
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 17:46:41 +00:00
Michael Anthony Knyszek
4f543b59c5 runtime: don't hold the heap lock while scavenging
This change modifies the scavenger to no longer hold the heap lock while
actively scavenging pages. To achieve this, the change also:
* Reverses the locking behavior of the (*pageAlloc).scavenge API, to
  only acquire the heap lock when necessary.
* Introduces a new lock on the scavenger-related fields in a pageAlloc
  so that access to those fields doesn't require the heap lock. There
  are a few places in the scavenge path, notably reservation, that
  requires synchronization. The heap lock is far too heavy handed for
  this case.
* Changes the scavenger to marks pages that are actively being scavenged
  as allocated, and "frees" them back to the page allocator the usual
  way.
* Lifts the heap-growth scavenging code out of mheap.grow, where the
  heap lock is held, and into allocSpan, just after the lock is
  released. Releasing the lock during mheap.grow is not feasible if we
  want to ensure that allocation always makes progress (post-growth,
  another allocator could come in and take all that space, forcing the
  goroutine that just grew the heap to do so again).

This change means that the scavenger now must do more work for each
scavenge, but it is also now much more scalable. Although in theory it's
not great by always taking the locked paths in the page allocator, it
takes advantage of some properties of the allocator:
* Most of the time, the scavenger will be working with one page at a
  time. The page allocator's locked path is optimized for this case.
* On the allocation path, it doesn't need to do the find operation at
  all; it can go straight to setting bits for the range and updating the
  summary structure.

Change-Id: Ie941d5e7c05dcc96476795c63fef74bcafc2a0f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/353974
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2021-11-05 17:46:27 +00:00
Tobias Klauser
0bc98b3e9b syscall: fix mkall.sh for openbsd/386
CL 287654 converted the syscall package on openbsd/386 to use libc.
However, the mksyscall.pl invocation wasn't adjusted. Do so now to use
syscall_openbsd_libc.go like the other libc-based openbsd ports.

Change-Id: I48a7bd6ce4c25eca5222f560ed584e412b466111
Reviewed-on: https://go-review.googlesource.com/c/go/+/361481
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-11-05 17:39:43 +00:00
Josh Bleecher Snyder
37951d8881 net/netip: optimize As4 and As16
name    old time/op  new time/op  delta
As16-8  2.88ns ± 3%  2.16ns ± 3%  -25.19%  (p=0.000 n=15+15)

Fixes #49379
Updates #20859

Change-Id: If4cf58d19ed0e2ac0f179da5c132ed37061e4cb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/361674
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 17:23:06 +00:00