1
0
mirror of https://github.com/golang/go synced 2024-11-14 22:50:27 -07:00
Commit Graph

44246 Commits

Author SHA1 Message Date
Bryan C. Mills
c25dd3f832 [release-branch.go1.15] testing: flush test summaries to stdout atomically when streaming output
While debugging #40771, I realized that the chatty printer should only
ever print to a single io.Writer (normally os.Stdout). The other
Writer implementations in the chain write to local buffers, but if we
wrote a test's output to a local buffer, then we did *not* write it to
stdout and we should not store it as the most recently logged test.

Because the chatty printer should only ever print to one place, it
shouldn't receive an io.Writer as an argument — rather, it shouldn't
be used at all for destinations other than the main output stream.

On the other hand, when we flush the output buffer to stdout in the
top-level flushToParent call, it is important that we not allow some
other test's output to intrude between the test summary header and the
remainder of the test's output. cmd/test2json doesn't know how to
parse such an intrusion, and it's confusing to humans too.

No test because I couldn't reproduce the user-reported error without
modifying the testing package. (This behavior seems to be very
sensitive to output size and/or goroutine scheduling.)

Fixes #40881
Updates #40771
Updates #38458

Change-Id: Ic19bf1d535672b096ba1c8583a3b74aab6d6d766
Reviewed-on: https://go-review.googlesource.com/c/go/+/249026
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 51c0bdc6d1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/252637
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
2020-10-05 22:50:28 +00:00
Keith Randall
fa262e61fd [release-branch.go1.15] cmd/compile: prevent 387+float32+pie from clobbering registers
The 387 port needs to load a floating-point control word from a
global location to implement float32 arithmetic.
When compiling with -pie, loading that control word clobbers an
integer register. If that register had something important in it, boom.

Fix by using LEAL to materialize the address of the global location
first. LEAL with -pie works because the destination register is
used as the scratch register.

387 support is about to go away (#40255), so this will need to be
backported to have any effect.

No test. I have one, but it requires building with -pie, which
requires cgo. Our testing infrastructure doesn't make that easy.
Not worth it for a port which is about to vanish.

Fixes #41620

Change-Id: I140f9fc8fdce4e74a52c2c046e2bd30ae476d295
Reviewed-on: https://go-review.googlesource.com/c/go/+/257277
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Keith Randall <khr@golang.org>
(cherry picked from commit ea106cc07a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/257207
2020-10-01 18:28:30 +00:00
Ian Lance Taylor
fa01c8a14e [release-branch.go1.15] internal/poll: adjust ignoringEINTR to avoid slice escape
The 1.15 compiler is not quite smart enough to see that the byte slice
passed to ignoringEINTR does not escape. This ripples back up to user
code which would see a byte slice passed to os.(*File).Write escape,
which did not happen in 1.14.

Rather than backport some moderately complex compiler fixes, rewrite
the code slightly so that the 1.15 compiler is able to see that the
slice does not escape.

This is not a backport from tip, where the code is already different.
The test for this will be on tip, where we will most likely change the
compiler to understand this kind of code.

Fixes #41543
For #41474

Change-Id: I6c78164229fea7794e7edba512bfd7034a0b91c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/256418
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-09-24 19:57:55 +00:00
Michael Anthony Knyszek
b1be1428dc [release-branch.go1.15] runtime: fix ReadMemStatsSlow's and CheckScavengedBits' chunk iteration
Both ReadMemStatsSlow and CheckScavengedBits iterate over the page
allocator's chunks but don't actually check if they exist. During the
development process the chunks index became sparse, so now this was a
possibility. If the runtime tests' heap is sparse we might end up
segfaulting in either one of these functions, though this will generally
be very rare.

The pattern here to return nil for a nonexistent chunk is also useful
elsewhere, so this change introduces tryChunkOf which won't throw, but
might return nil. It also updates the documentation of chunkOf.

For #41296.
Fixes #41317.

Change-Id: Id5ae0ca3234480de1724fdf2e3677eeedcf76fa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/253777
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 34835df048)
Reviewed-on: https://go-review.googlesource.com/c/go/+/253917
2020-09-10 18:38:18 +00:00
Michael Munday
bbee5236cd [release-branch.go1.15] cmd/internal/obj: fix inline marker issue on s390x
The optimization that replaces inline markers with pre-existing
instructions assumes that 'Prog' values produced by the compiler are
still reachable after the assembler has run. This was not true on
s390x where the assembler was removing NOP instructions from the
linked list of 'Prog' values. This led to broken inlining data
which in turn caused an infinite loop in the runtime traceback code.

Fix this by stopping the s390x assembler backend removing NOP
values. It does not make any difference to the output of the
assembler because NOP instructions are 0 bytes long anyway.

Note: compiler check omitted from backport to reduce risk of change.

Fixes #40693.

Change-Id: I4eb570de13165cde342d5fb2ee3218945ddf4b52
Reviewed-on: https://go-review.googlesource.com/c/go/+/248478
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-10 18:29:56 +00:00
Dmitri Shuralyov
9706f510a5 [release-branch.go1.15] go1.15.2
Change-Id: I876e199ac276e42cd98bf36d22eaacf26506a975
Reviewed-on: https://go-review.googlesource.com/c/go/+/253717
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-09 16:38:12 +00:00
Cherry Zhang
f50cde9a70 [release-branch.go1.15] cmd/compile, runtime: mark R12 clobbered for write barrier call on PPC64
When external linking, for large binaries, the external linker
may insert a trampoline for the write barrier call, which looks

0000000005a98cc8 <__long_branch_runtime.gcWriteBarrier>:
 5a98cc8:       86 01 82 3d     addis   r12,r2,390
 5a98ccc:       d8 bd 8c e9     ld      r12,-16936(r12)
 5a98cd0:       a6 03 89 7d     mtctr   r12
 5a98cd4:       20 04 80 4e     bctr

It clobbers R12 (and CTR, which is never live across a call).

As at compile time we don't know whether the binary is big and
what link mode will be used, I think we need to mark R12 as
clobbered for write barrier call. For extra safety (future-proof)
we mark caller-saved register that cannot be used for function
arguments, which includes R11, as potentially clobbered as well.

Updates #40851.
Fixes #40868.

Change-Id: Iedd901c5072f1127cc59b0a48cfeb4aaec81b519
Reviewed-on: https://go-review.googlesource.com/c/go/+/248917
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
(cherry picked from commit b58d297416)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249019
2020-09-03 14:49:02 +00:00
Keith Randall
b616f745ef [release-branch.go1.15] cmd/internal/obj: stop removing NOPs from instruction stream
This has already been done for s390x, ppc64. This CL is for
all the other architectures.

Fixes #40798

Change-Id: Idd1816e057df63022d47e99fa06617811d8c8489
Reviewed-on: https://go-review.googlesource.com/c/go/+/248684
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
(cherry picked from commit 46ca7b5ee2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249444
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-03 02:29:39 +00:00
Lynn Boger
a5fb3b1f3d [release-branch.go1.15] cmd/internal/obj/ppc64: don't remove NOP in assembler
Previously, the assembler removed NOPs from the Prog list in
obj9.go. NOPs shouldn't be removed if they were added as
an inline mark, as described in the issue below.

Fixes #40767

Once the NOPs were left in the Prog list, some instructions
were flagged as invalid because they had an operand which was
not represented in optab. In order to preserve the previous
assembler behavior, entries were added to optab for those
operand cases. They were not flagged as errors before because
the NOP instructions were removed before the code to check the
valid opcode/operand combinations.

Change-Id: Iae5145f94459027cf458e914d7c5d6089807ccf8
Reviewed-on: https://go-review.googlesource.com/c/go/+/247842
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 7d7bd5abc7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248381
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-03 02:16:47 +00:00
Filippo Valsorda
33e86004f1 [release-branch.go1.15] net/http/fgci: skip flaky test
A test introduced in the security release is flaky due to a pre-existing
issue that does not qualify for backport itself.

Updates #41167
Fixes #41193

Change-Id: Ie6014e0796c1baee7b077881b5a799f9947fc9c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/252717
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-02 17:40:55 +00:00
Bryan C. Mills
09b28977f5 [release-branch.go1.15] cmd/test2json: do not emit a final Action if the result is not known
If we are parsing a test output, and the test does not end in the
usual PASS or FAIL line (say, because it panicked), then we need the
exit status of the test binary in order to determine whether the test
passed or failed. If we don't have that status available, we shouldn't
guess arbitrarily — instead, we should omit the final "pass" or "fail"
action entirely.

(In practice, we nearly always DO have the final status, such as when
running 'go test' or 'go tool test2json some.exe'.)

Updates #40132
Fixes #40805

Change-Id: Iae482577361a6033395fe4a05d746b980e18c3de
Reviewed-on: https://go-review.googlesource.com/c/go/+/248624
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 1b86bdbdc3)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248725
2020-09-02 15:02:34 +00:00
Bryan C. Mills
76a89d6ca0 [release-branch.go1.15] cmd/go/internal/test: keep looking for go command flags after ambiguous test flag
Updates #40763
Fixes #40802

Change-Id: I275970d1f8561414571a5b93e368d68fa052c60f
Reviewed-on: https://go-review.googlesource.com/c/go/+/248618
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
(cherry picked from commit 797124f5ff)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248726
2020-09-02 14:57:44 +00:00
ShihCheng Tu
60fdbce6fd [release-branch.go1.15] doc/go1.14: document json.Umarshal map key support of TextUnmarshaler
Document that json.Unmarshal supports map keys whose underlying
types implement encoding.TextUnmarshaler.

Updates #38801.
Fixes #41178.

Change-Id: Icb9414e9067517531ba0da910bd4a2bb3daace65
Reviewed-on: https://go-review.googlesource.com/c/go/+/237857
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 47b4509977)
Reviewed-on: https://go-review.googlesource.com/c/go/+/252618
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2020-09-02 13:39:54 +00:00
chainhelen
a269e5f939 [release-branch.go1.15] runtime: fix panic if newstack at runtime.acquireLockRank
Process may crash becaues acquireLockRank and releaseLockRank may
be called in nosplit context. With optimizations and inlining
disabled, these functions won't get inlined or have their morestack
calls eliminated.
Nosplit is not strictly required for lockWithRank, unlockWithRank
and lockWithRankMayAcquire, just keep consistency with lockrank_on.go
here.

Updates #40843.
Fixes #40845.

Change-Id: I5824119f98a1da66d767cdb9a60dffe768f13c81
GitHub-Last-Rev: 38fd3ccf6e
GitHub-Pull-Request: golang/go#40844
Reviewed-on: https://go-review.googlesource.com/c/go/+/248878
Reviewed-by: Dan Scales <danscales@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit b246c0e12f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/252339
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2020-09-02 12:57:08 +00:00
Bryan C. Mills
0ffc5672df [release-branch.go1.15] testing: treat PAUSE lines as changing the active test name
We could instead fix cmd/test2json to treat PAUSE lines as *not*
changing the active test name, but that seems like it would be more
confusing to humans, and also wouldn't fix tools that parse output
using existing builds of cmd/test2json.

Fixes #40849
Updates #40657

Change-Id: I937611778f5b1e7dd1d6e9f44424d7e725a589ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/248727
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jean de Klerk <deklerk@google.com>
(cherry picked from commit cdc77d34d7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249097
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-09-01 19:41:10 +00:00
Filippo Valsorda
b990aa0ed7 [release-branch.go1.15] all: merge release-branch.go1.15-security into release-branch.go1.15
Change-Id: Iac13fc6d5c363ecd2896dd1aac1923af699815de
2020-09-01 19:06:55 +02:00
Dmitri Shuralyov
01af46f7cc [release-branch.go1.15-security] go1.15.1
Change-Id: I4103c524ce46d50215af5097460e514609b513c6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/835373
Reviewed-by: Filippo Valsorda <valsorda@google.com>
2020-09-01 14:08:32 +00:00
Roberto Clapis
eb07103a08 [release-branch.go1.15-security] net/http/cgi,net/http/fcgi: add Content-Type detection
This CL ensures that responses served via CGI and FastCGI
have a Content-Type header based on the content of the
response if not explicitly set by handlers.

If the implementers of the handler did not explicitly
specify a Content-Type both CGI implementations would default
to "text/html", potentially causing cross-site scripting.

Thanks to RedTeam Pentesting GmbH for reporting this.

Fixes CVE-2020-24553

Change-Id: I82cfc396309b5ab2e8d6e9a87eda8ea7e3799473
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/823217
Reviewed-by: Russ Cox <rsc@google.com>
(cherry picked from commit 23d675d07fdc56aafd67c0a0b63d5b7e14708ff0)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/835311
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2020-09-01 12:31:45 +00:00
Ian Lance Taylor
1fa328f8fb [release-branch.go1.15] net/mail: return error on empty address list
This restores the handling accidentally changed in CL 217377.

Fixes #40804
For #40803
For #36959

Change-Id: If77fbc0c2a1dde4799f760affdfb8dde9bcaf458
Reviewed-on: https://go-review.googlesource.com/c/go/+/248598
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Jeremy Fishman <jfishman@cloudflare.com>
(cherry picked from commit 3e636ab9ad)
Reviewed-on: https://go-review.googlesource.com/c/go/+/251167
2020-08-28 20:05:42 +00:00
Changkun Ou
19c8546cd9 [release-branch.go1.15] sync: delete dirty keys inside Map.LoadAndDelete
Updates #40999
Fixes #41011

Change-Id: Ie32427e5cb5ed512b976b554850f50be156ce9f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/250197
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 94953d3e59)
Reviewed-on: https://go-review.googlesource.com/c/go/+/250297
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-08-27 20:27:35 +00:00
Michał Łowicki
45265c210c [release-branch.go1.15] testing: fix Cleanup race with Logf and Errorf
Updates #40908
Fixes #41034

Change-Id: I25561a3f18e730a50e6fbf85aa7bd85bf1b73b6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/250078
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
(cherry picked from commit 00a053bd4b)
Reviewed-on: https://go-review.googlesource.com/c/go/+/250617
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Michał Łowicki <mlowicki@gmail.com>
2020-08-27 20:26:34 +00:00
Jason A. Donenfeld
b1253d24e1 [release-branch.go1.15] runtime: detect services in signal handler
The service handler needs to handle CTRL+C-like events -- including
those sent by the service manager itself -- using the default Windows
implementation if no signal handler from Go is already listening to
those events. Ordinarily, the signal handler would call exit(2), but we
actually need to allow this to be passed onward to the service handler.
So, we detect if we're in a service and skip calling exit(2) in that
case, just like we do for shared libraries.

Updates #40167.
Updates #40074.
Fixes #40412.

Change-Id: Ia77871737a80e1e94f85b02d26af1fd2f646af96
Reviewed-on: https://go-review.googlesource.com/c/go/+/244959
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-08-22 03:57:10 +00:00
Tobias Klauser
8bf83b323c [release-branch.go1.15] internal/poll: treat copy_file_range EPERM as not-handled
Updates #40893.
Fixes #40900.

Change-Id: I938ea4796c1e1d1e136117fe78b06ad6da8e40de
Reviewed-on: https://go-review.googlesource.com/c/go/+/249257
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Antonio Troina <thoeni@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit b0cc02e8c2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249897
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2020-08-22 01:21:29 +00:00
Matthew Dempsky
f454f70344 [release-branch.go1.15] cmd/compile: fix checkptr handling of &^
checkptr has code to recognize &^ expressions, but it didn't take into
account that "p &^ x" gets rewritten to "p & ^x" during walk, which
resulted in false positive diagnostics.

This CL changes walkexpr to mark OANDNOT expressions with Implicit
when they're rewritten to OAND, so that walkCheckPtrArithmetic can
still recognize them later.

It would be slightly more idiomatic to instead mark the OBITNOT
expression as Implicit (as it's a compiler-generated Node), but the
OBITNOT expression might get constant folded. It's not worth the extra
complexity/subtlety of relying on n.Right.Orig, so we set Implicit on
the OAND node instead.

To atone for this transgression, I add documentation for nodeImplicit.

Updates #40917.
Fixes #40934.

Change-Id: I386304171ad299c530e151e5924f179e9a5fd5b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/249477
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
(cherry picked from commit e94544cf01)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249879
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-08-21 23:45:40 +00:00
Ian Lance Taylor
f2b7109989 [release-branch.go1.15] internal/poll: treat copy_file_range EOPNOTSUPP as not-handled
For #40731
Fixes #40739

Change-Id: I3e29878d597318acf5edcc38497aa2624f72be35
Reviewed-on: https://go-review.googlesource.com/c/go/+/248258
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
(cherry picked from commit d3a411b6de)
Reviewed-on: https://go-review.googlesource.com/c/go/+/249197
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2020-08-21 23:20:23 +00:00
Josh Bleecher Snyder
9c17883f28 cmd/compile: correct type of CvtBoolToUint8 values
Fixes #40772

Change-Id: I539f07d1f958dacee87d846171a8889d03182d25
Reviewed-on: https://go-review.googlesource.com/c/go/+/248397
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/248401
2020-08-21 20:58:15 +00:00
Cherry Zhang
46a34f93a2 [release-branch.go1.15] doc/go1.15: clarify external linking can still be used for building PIE
In Go 1.15 we switched the default linking mode for PIE on
Linux/AMD64 and Linux/ARM64 to internal linking. Clarify that
the previous behavior (external linking) can still be used with
a flag.

Updates #40719.

Change-Id: Ib7042622bc91e1b1aa31f520990d03b5eb6c56bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/248199
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 50f63a7ae4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248330
2020-08-13 00:42:22 +00:00
Andrew
91de29ec8f [release-branch.go1.15] doc/go1.15: include behavior updates to the context package
Fixes #40737

Change-Id: I8e2c1e1653d427af1ded6d61df1aa450e3c4d35c
Reviewed-on: https://go-review.googlesource.com/c/go/+/248329
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit b2353174db)
Reviewed-on: https://go-review.googlesource.com/c/go/+/248331
Reviewed-by: Andrew Gerrand <adg@golang.org>
2020-08-13 00:37:54 +00:00
Andrew Bonventre
0fdc3801bf [release-branch.go1.15] go1.15
Change-Id: Id2262ff66e750e798ebe7ecfcc13d2653cb85b71
Reviewed-on: https://go-review.googlesource.com/c/go/+/247905
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-11 19:01:57 +00:00
Andrew
cbc69e89b1 [release-branch.go1.15] all: merge master into release-branch.go1.15
5c7748dc9d doc/go1.15: encoding/json's CL 191783 was reverted
5ff5b3c557 doc/go1.15: remove draft notice
5ae1d62ee3 CONTRIBUTORS: update for the Go 1.15 release
7ad776dda5 doc/go1.15: document crypto/tls permanent error
a93a4c1780 runtime: make nanotime1 reentrant

Updates #40697

Change-Id: Ie39896ee6304544cc9e9c1938bdf176f1dcf8766
Reviewed-on: https://go-review.googlesource.com/c/go/+/247900
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-11 17:05:57 +00:00
Alexander Rakoczy
c4f8cb43ca [release-branch.go1.15] go1.15rc2
Change-Id: I2fe55c3f0328291b7d602cfae83d3f0b72cee14c
Reviewed-on: https://go-review.googlesource.com/c/go/+/247238
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-07 14:56:02 +00:00
Alexander Rakoczy
fd4126ae7f [release-branch.go1.15] all: merge master into release-branch.go1.15
ba9e108899 cmd: update golang.org/x/xerrors
027d7241ce encoding/binary: read at most MaxVarintLen64 bytes in ReadUvarint
6f08e89ec3 cmd/go: fix error stacks when there are scanner errors
f235275097 net/http: fix cancelation of requests with a readTrackingBody wrapper
f92337422e runtime/race: fix ppc64le build
e49b2308a5 runtime/race: rebuild some .syso files to remove getauxval dependency
10523c0efb doc/go1.15: fix a few trivial inconsistencies
7388956b76 cmd/cgo: fix mangling of enum and union types
b56791cdea runtime: validate candidate searchAddr in pageAlloc.find
10374e2435 testing: fix quotation marks
7f86080476 cmd/compile: don't addLocalInductiveFacts if there is no direct edge from if block to phi block
54e75e8f9d crypto/ed25519: remove s390x KDSA implementation
6b4dcf19fa runtime: hold sched.lock over globrunqputbatch in runqputbatch
85afa2eb19 runtime: ensure startm new M is consistently visible to checkdead
c4fed25553 cmd/compile: add floating point load+op operations to addressing modes pass
19a932ceb8 cmd/link: don't mark shared library symbols reachable unconditionally
8696ae82c9 syscall: use correct file descriptor in dup2 fallback path
9591515f51 runtime, sync: add copyright headers to new files
074f2d800f doc/go1.15: surface the crypto/x509 CommonName deprecation note

Change-Id: I0bfcff1fc2de723960909d9dda718fee6abc2912
2020-08-06 15:39:24 -04:00
Alexander Rakoczy
ba9e108899 cmd: update golang.org/x/xerrors
This pulls in CL 247217.

Fixes #40573

Change-Id: I89eeebb5da9a4668adc6b5c5155651e5da421d59
Reviewed-on: https://go-review.googlesource.com/c/go/+/247186
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-06 19:17:13 +00:00
Katie Hockman
027d7241ce encoding/binary: read at most MaxVarintLen64 bytes in ReadUvarint
This CL ensures that ReadUvarint consumes only a limited
amount of input (instead of an unbounded amount).

On some inputs, ReadUvarint could read an arbitrary number
of bytes before deciding to return an overflow error.
After this CL, ReadUvarint returns that same overflow
error sooner, after reading at most MaxVarintLen64 bytes.

Fix authored by Robert Griesemer and Filippo Valsorda.

Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani,
and Preston Van Loon for reporting this.

Fixes #40618
Fixes CVE-2020-16845

Change-Id: Ie0cb15972f14c38b7cf7af84c45c4ce54909bb8f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/812099
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/247120
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
2020-08-06 17:24:10 +00:00
Michael Matloob
6f08e89ec3 cmd/go: fix error stacks when there are scanner errors
After golang.org/cl/228784 setLoadPackageDataError tries to decide whether an
error is caused by an imported package or an importing package by examining the
error itself to decide. Ideally, the errors themselves would belong to a
specific interface or some other property to make it unambiguous that they
were import errors. Since they don't, setLoadPackageDataError just checked
for nogoerrors and classified all other errors as import errors. But
it missed scanner errors which are also "caused" by the imported
package.

Fixes #40544

Change-Id: I39159bfdc286bee73697decd07b8aa9451f2db06
Reviewed-on: https://go-review.googlesource.com/c/go/+/246717
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-05 18:24:52 +00:00
Damien Neil
f235275097 net/http: fix cancelation of requests with a readTrackingBody wrapper
Use the original *Request in the reqCanceler map, not the transient
wrapper created to handle body rewinding.

Change the key of reqCanceler to a struct{*Request}, to make it more
difficult to accidentally use the wrong request as the key.

Fixes #40453.

Change-Id: I4e61ee9ff2c794fb4c920a3a66c9a0458693d757
Reviewed-on: https://go-review.googlesource.com/c/go/+/245357
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2020-08-04 19:27:13 +00:00
Keith Randall
f92337422e runtime/race: fix ppc64le build
The .syso test also fails for ppc64le. Not sure why. For now, just
disable the test for that architecture. The test really only needs to
run on a single builder of any arch.

Change-Id: I346cdc01ada09d43c4c504fbc30be806f59d5422
Reviewed-on: https://go-review.googlesource.com/c/go/+/246358
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-02 00:04:25 +00:00
Keith Randall
e49b2308a5 runtime/race: rebuild some .syso files to remove getauxval dependency
We can't depend on getauxval because it only exists in glibc >= 2.16.
Tsan has been updated to avoid that dependency
(https://reviews.llvm.org/D84859). This CL rebuilds the affected
.syso files, and adds a test to make sure we don't regress.

Fixes #37485

Change-Id: I891f54d28ec0d7da50a8df1adadc76dd6e7ab3e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/246258
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2020-08-01 06:32:57 +00:00
Toshihiro Shiino
10523c0efb doc/go1.15: fix a few trivial inconsistencies
For #37419

Change-Id: I8ede539df5d5344aeb44ba1a7e2383363d92157f
Reviewed-on: https://go-review.googlesource.com/c/go/+/245977
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-01 01:11:19 +00:00
Matthew Dempsky
7388956b76 cmd/cgo: fix mangling of enum and union types
Consider this test package:

    package p

    // enum E { E0 };
    // union U { long x; };
    // void f(enum E e, union U* up) {}
    import "C"

    func f() {
    	C.f(C.enum_E(C.E0), (*C.union_U)(nil))
    }

In Go 1.14, cgo translated this to (omitting irrelevant details):

    type _Ctype_union_U [8]byte

    func f() {
    	_Cfunc_f(uint32(_Ciconst_E0), (*[8]byte)(nil))
    }

    func _Cfunc_f(p0 uint32, p1 *[8]byte) (r1 _Ctype_void) { ... }

Notably, _Ctype_union_U was declared as a defined type, but uses were
being rewritten into uses of the underlying type, which matched how
_Cfunc_f was declared.

After CL 230037, cgo started consistently rewriting "C.foo" type
expressions as "_Ctype_foo", which caused it to start emitting:

    type _Ctype_enum_E uint32
    type _Ctype_union_U [8]byte

    func f() {
    	_Cfunc_f(_Ctype_enum_E(_Ciconst_E0), (*_Ctype_union_U)(nil))
    }

    // _Cfunc_f unchanged

Of course, this fails to type-check because _Ctype_enum_E and
_Ctype_union_U are defined types.

This CL changes cgo to emit:

    type _Ctype_enum_E = uint32
    type _Ctype_union_U = [8]byte

    // f unchanged since CL 230037
    // _Cfunc_f still unchanged

It would probably be better to fix this in (*typeConv).loadType so
that cgo generated code uses the _Ctype_foo aliases too. But as it
wouldn't have any effect on actual compilation, it's not worth the
risk of touching it at this point in the release cycle.

Updates #39537.
Fixes #40494.

Change-Id: I88269660b40aeda80a9a9433777601a781b48ac0
Reviewed-on: https://go-review.googlesource.com/c/go/+/246057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-31 16:35:33 +00:00
Michael Anthony Knyszek
b56791cdea runtime: validate candidate searchAddr in pageAlloc.find
Currently pageAlloc.find attempts to find a better estimate for the
first free page in the heap, even if the space its looking for isn't
necessarily going to be the first free page in the heap (e.g. if npages
>= 2). However, in doing so it has the potential to return a searchAddr
candidate that doesn't actually correspond to mapped memory, but this
candidate might still be adopted. As a result, pageAlloc.alloc's fast
path may look at unmapped summary memory and segfault. This case is rare
on most operating systems since the heap is kept fairly contiguous, so
the chance that the candidate searchAddr discovered is unmapped is
fairly low. Even so, this is totally possible and outside the user's
control when it happens (in fact, it's likely to happen consistently for
a given user on a given system).

Fix this problem by ensuring that our candidate always points to mapped
memory. We do this by looking at mheap's arenas structure first. If it
turns out our candidate doesn't correspond to mapped memory, then we
look at inUse to round up the searchAddr to the next mapped address.

While we're here, clean up some documentation related to searchAddr.

Fixes #40191.

Change-Id: I759efec78987e4a8fde466ae45aabbaa3d9d4214
Reviewed-on: https://go-review.googlesource.com/c/go/+/242680
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-31 14:35:39 +00:00
Katie Hockman
10374e2435 testing: fix quotation marks
Change-Id: I4b816e26718ef5521afba2b200a6333373b09c58
Reviewed-on: https://go-review.googlesource.com/c/go/+/245136
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-30 19:08:42 +00:00
Cholerae Hu
7f86080476 cmd/compile: don't addLocalInductiveFacts if there is no direct edge from if block to phi block
Currently in addLocalInductiveFacts, we only check whether
direct edge from if block to phi block exists. If not, the
following logic will treat the phi block as the first successor,
which is wrong.

This patch makes prove pass more conservative, so we disable
some cases in test/prove.go. We will do some optimization in
the following CL and enable these cases then.

Fixes #40367.

Change-Id: I27cf0248f3a82312a6f7dabe11c79a1a34cf5412
Reviewed-on: https://go-review.googlesource.com/c/go/+/244579
Reviewed-by: Zach Jones <zachj1@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-30 17:23:11 +00:00
Michael Munday
54e75e8f9d crypto/ed25519: remove s390x KDSA implementation
This reverts CL 202578 and CL 230677 which added an optimization
to use KDSA when available on s390x.

Inconsistencies have been found between the two implementations
in their handling of certain edge cases. Since the Go 1.15 release
is extremely soon it seems prudent to remove this optimization
for now and revisit it in a future release.

Fixes #40475.

Change-Id: Ifb2ed9b9e573784df57383671f1c29d8abae90d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/245497
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ruixin(Peter) Bao <ruixin.bao@ibm.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-07-30 16:00:05 +00:00
Michael Anthony Knyszek
6b4dcf19fa runtime: hold sched.lock over globrunqputbatch in runqputbatch
globrunqputbatch should never be called without sched.lock held.
runqputbatch's documentation even says it may acquire sched.lock in
order to call it.

Fixes #40457.

Change-Id: I5421b64f1da3a6087dfebbef7203db0c95d213a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/245377
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-30 15:46:39 +00:00
Michael Pratt
85afa2eb19 runtime: ensure startm new M is consistently visible to checkdead
If no M is available, startm first grabs an idle P, then drops
sched.lock and calls newm to start a new M to run than P.

Unfortunately, that leaves a window in which a G (e.g., returning from a
syscall) may find no idle P, add to the global runq, and then in stopm
discover that there are no running M's, a condition that should be
impossible with runnable G's.

To avoid this condition, we pre-allocate the new M ID in startm before
dropping sched.lock. This ensures that checkdead will see the M as
running, and since that new M must eventually run the scheduler, it will
handle any pending work as necessary.

Outside of startm, most other calls to newm/allocm don't have a P at
all. The only exception is startTheWorldWithSema, which always has an M
if there is 1 P (i.e., the currently running M), and if there is >1 P
the findrunnable spinning dance ensures the problem never occurs.

This has been tested with strategically placed sleeps in the runtime to
help induce the correct race ordering, but the timing on this is too
narrow for a test that can be checked in.

Fixes #40368

Change-Id: If5e0293a430cc85154b7ed55bc6dadf9b340abe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/245018
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-07-28 16:59:04 +00:00
Keith Randall
c4fed25553 cmd/compile: add floating point load+op operations to addressing modes pass
They were missed as part of the refactoring to use a separate
addressing modes pass.

Fixes #40426

Change-Id: Ie0418b2fac4ba1ffe720644ac918f6d728d5e420
Reviewed-on: https://go-review.googlesource.com/c/go/+/244859
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-07-27 18:24:32 +00:00
Cherry Zhang
19a932ceb8 cmd/link: don't mark shared library symbols reachable unconditionally
During the transitioning period, we mark symbols from Go shared
libraries reachable unconditionally. That might be useful when
there was still a large portion of the linker using sym.Symbols,
and only reachable symbols were converted to sym.Symbols. Marking
them reachable brings them to the dynamic symbol table, even if
they are not needed, increased the binary size unexpectedly.

That time has passed. Now we largely operate on loader symbols,
and it is not needed to mark them reachable anymore.

Fixes #40416.

Change-Id: I1e2bdb93a960ba7dc96575fabe15af93d8e95329
Reviewed-on: https://go-review.googlesource.com/c/go/+/244839
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-27 16:04:55 +00:00
Ian Lance Taylor
8696ae82c9 syscall: use correct file descriptor in dup2 fallback path
This fixes a mistake in CL 220422. This changes code that is only
executed on Linux kernel versions earlier than 2.6.27.

Change-Id: I01280184f4d7b75e06387c38f1891e8f0a81f793
Reviewed-on: https://go-review.googlesource.com/c/go/+/244630
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-07-25 20:13:27 +00:00
Ian Lance Taylor
9591515f51 runtime, sync: add copyright headers to new files
For #38029

Change-Id: I71de2b66c1de617d32c46d4f2c1866f9ff1756ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/244631
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-07-25 03:26:17 +00:00