1
0
mirror of https://github.com/golang/go synced 2024-11-15 02:20:32 -07:00
Commit Graph

45065 Commits

Author SHA1 Message Date
Roland Shoemaker
ed2996bac7 crypto/x509: document support for leading periods in DNS constraints
This change adds a comment to the Verify documentation that indicates
that you can use URI and email style name constraints with a leading
period for DNS names (and explains what they do). This behavior is
not standards compliant, but matches the community application of
RFC 5280, so it makes sense to document it.

Fixes #37535

Change-Id: Ibd6f039e4fa46d40ad7ae1ab48eab86f13cf8eff
Reviewed-on: https://go-review.googlesource.com/c/go/+/233525
Reviewed-by: Ryan Sleevi <sleevi@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-06-02 19:58:42 +00:00
Dan Scales
e05695ed4d runtime: add three new partial orders for lock ranking
Two are associated with the new sysmon rank:  lockRankSysmon -> lockRankFin
(https://build.golang.org/log/07b0b8ee6ec9421d83699a1d850d9938390fb996)
and one I encountered during testing, lockRankSysmon -> lockRankWbufSpans

And another just seems not to have occurred before:  lockRankScavenge -> lockRankFin
(https://build.golang.org/log/07ba499b861fc93f527ef8514f5ba4c77086f4c4)

Change-Id: I070b5ed8e742857e815c6a56f8439d17a0ba36f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/236137
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2020-06-02 18:36:30 +00:00
Richard Miller
d17aebf46d internal/poll: add mutex to prevent SetDeadline race in Plan 9
There are data races on fd.[rw]aio and fd.[rw]timedout when Read/Write
is called on a polled fd concurrently with SetDeadline (see #38769).
Adding a mutex around accesses to each pair (read and write) prevents
the race, which was causing deadlocks in net/http tests on the builders.

Updates #38769.

Change-Id: I31719b3c9a664e81a775cda583cff31c0da946c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/235820
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
2020-06-02 12:10:28 +00:00
Cherry Zhang
0eb9767caa misc/cgo/testplugin: fix typo in comment
Change-Id: I7d1a5f6936505dff8f765541b5102dcbcd6ae835
Reviewed-on: https://go-review.googlesource.com/c/go/+/235924
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-01 23:25:14 +00:00
Elias Naur
612da6bf19 doc: document the new Cgo EGLConfig special case
Change-Id: I7ae5eaa974b85eac421a0b1f79cb734a0fe44e72
Reviewed-on: https://go-review.googlesource.com/c/go/+/235818
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-01 21:59:51 +00:00
Elias Naur
ff795a8af0 doc: document new Android default linker
Change-Id: I3557f6726afe325db79b2c972d107b3bcc103b8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/235819
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-01 21:58:00 +00:00
Cherry Zhang
13bc6d4223 cmd/link: flush file mapping before unmapping
Call FlushViewOfFile before unmapping the output file, for extra
safety. The documentation says the function does not wait for
the data to be written to disk, so it should be cheap.

Fixes #38440.

Change-Id: I05352f15d9305e6e7086a002f61802f74036b710
Reviewed-on: https://go-review.googlesource.com/c/go/+/235639
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2020-06-01 20:38:23 +00:00
Jay Conrod
8be0de1e7e cmd/go/internal/modload: document mvsReqs.Max
The version "" denotes the main module, which has no version. The
mvs.Reqs interface documentation hints this is allowed, but it's not
obvious from the implementation in modload.mvsReqs.Max.

Also, replace a related TODO with a comment in mvs.Downgrade.

Fixes #39042

Change-Id: I11e10908c9b3d8c2283eaa5c04bd8e1b936851fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/234003
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-06-01 18:13:51 +00:00
Daniel Nephin
f8662a5a96 cmd/test2json: attribute output to the correct test
When printing regular test output check the indentation of the output, and use
the report stack to find the appropriate test name for that output.

This change includes a whitespace change to some golden test files. The
indentation of tests was changed in CL 113177
from tabs to spaces. The golden files have been updated to match the new
output format. The tabs in the golden files cause problems because the indentation check
looks for 4 spaces.

Fixes #29755
Updates #25369

Change-Id: Iebab51816a9755168083a7a665b41497e9dfd85f
GitHub-Last-Rev: 898827f1a6
GitHub-Pull-Request: golang/go#34419
Reviewed-on: https://go-review.googlesource.com/c/go/+/196617
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-06-01 16:13:47 +00:00
Alexander Rakoczy
eecc6282cc doc/go1.15: update Go 1.15 release notes using relnote
The additions were generated using golang.org/x/build/cmd/relnote.

Updates #37419

Change-Id: Iad7b564dd7e6cbcbd0d216c2530802e086ec49cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/235757
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-06-01 15:54:29 +00:00
Richard Musiol
0452f9460f runtime: fix race condition between timer and event handler
This change fixes a race condition between beforeIdle waking up the
innermost event handler and a timer causing a different goroutine to
wake up at the exact same moment. This messes up the wasm event handling
and leads to memory corruption. The solution is to make beforeIdle
return the goroutine that must run next and have findrunnable pick
this goroutine without considering timers again.

Fixes #38093
Fixes #38574

Change-Id: Iffbe99411d25c2730953d1c8b0741fd892f8e540
Reviewed-on: https://go-review.googlesource.com/c/go/+/230178
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-31 18:35:04 +00:00
Elias Naur
7dbbb5bacf cmd/cgo,cmd/fix,misc/cgo: map the EGLConfig C type to uintptr in Go
Similarly to EGLDisplay, EGLConfig is declared as a pointer but may
contain non-pointer values.

I believe this is the root cause of https://todo.sr.ht/~eliasnaur/gio/121.

Change-Id: I412c4fbc2eef4aa028534d68bda95db98e3a365d
Reviewed-on: https://go-review.googlesource.com/c/go/+/235817
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-31 09:48:08 +00:00
Yasser Abdolmaleki
f1f8f9af9a container/list: fix typo in function comments
The correct word to use here is 'another' not 'an other'

Change-Id: Ie4f748ae94a5945dceb52779222ffd8cf36b8845
Reviewed-on: https://go-review.googlesource.com/c/go/+/235838
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-05-31 02:07:28 +00:00
Paschalis Tsilias
8da78625b1 net/http: reject HTTP/1.1 Content-Length with sign in response
Enforces section 14.13 of RFC 2616 so that Content-Length header
values with a sign such as "+5" will be rejected.

Updates #39017

Change-Id: Icce9f00d03c8475fe704b33f9bed9089ff8802f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/234817
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-31 00:55:05 +00:00
Austin Clements
fc40beb987 Revert "cmd/go: group 'go get' update messages together near the end of output"
This reverts https://golang.org/cl/232578.

Reason for revert: This commit broke TestScript/mod_load_badchain,
which is causing all longtest builders to fail.

Change-Id: I4a17392ce74ac3a7ad340980556025f669d94b65
Reviewed-on: https://go-review.googlesource.com/c/go/+/235857
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-05-31 00:38:00 +00:00
Brad Erickson
1ed57c1b72 database/sql/driver: use correct method name "Connect" in DriverContext docs
Change-Id: I755fedebb1f8f4d3f27b2b3f8626bca03bd36c88
GitHub-Last-Rev: 4a123572d5
GitHub-Pull-Request: golang/go#39305
Reviewed-on: https://go-review.googlesource.com/c/go/+/235518
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2020-05-30 03:20:54 +00:00
Michael Pratt
0aed2a4133 runtime: no SIGWINCH to pgrp while GDB is running
When run with stdin == /dev/null and stdout/stderr == pipe (i.e., as
os/exec.Command.CombinedOutput), GDB suffers from a bug
(https://sourceware.org/bugzilla/show_bug.cgi?id=26056) that causes
SIGSEGV when sent a SIGWINCH signal.

Package runtime tests TestEINTR and TestSignalDuringExec both send
SIGWINCH signals to the entire process group, thus including GDB if one
of the GDB tests is running in parallel.

TestEINTR only intends its signals for the current process, so it is
changed to do so. TestSignalDuringExec, really does want its signals to
go to children. However, it does not call t.Parallel(), so it won't run
at the same time as GDB tests.

This is a simple fix, but GDB is vulnerable, so we must be careful not
to add new parallel tests that send SIGWINCH to the entire process
group.

Fixes #39021

Change-Id: I803606fb000f08c65c1b10ec554d4ef6819e5dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/235557
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-05-29 21:18:16 +00:00
Jay Conrod
6ad5f4e334 go/build: move build constraint docs to 'go help buildconstraint'
CL 228017 added a new help page 'go help buildconstraint' which
summarized the information on build constraints in the go/build
documentation. The summary was almost as long as the go/build
documentation, since there's very little that can be left out.

This CL moves the original go/build documentation to
'go help buildconstraint' to eliminate redundnancy. The text
describing enabled tags is slightly different (targeting command-line
users more than go/build users), but the rest of the documentation is
unchanged.

Fixes #37018

Change-Id: Ic0ed4c6fdae2395dd58852e1600c701247c9c4cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/232981
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-05-29 20:56:20 +00:00
Jay Conrod
c2d1df6391 cmd/go: group 'go get' update messages together near the end of output
In module mode, 'go get' prints a message for each version query it
resolves. This change groups those messages together near the end of
the output so they aren't mixed with other module "finding" and
"downloading" messages. They'll still be printed before build-related
messages.

Fixes #37982

Change-Id: I107a9f2b2f839e896399df906e20d6fc77f280c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/232578
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-05-29 20:55:14 +00:00
Than McIntosh
6851a55f28 cmd/compile: add test case for issue 38068
New test case for issue 38068, which deals with build reproducibility:
do a pair of compilations, the first with the concurrent back end
turned on, and the second with -c=1, then check to make sure we get
the same output (using a test case that triggers late inlining into
wrapper methods).

Updates #38068.

Change-Id: I4afaf78898706a66985f09d18f6f6f29876c9017
Reviewed-on: https://go-review.googlesource.com/c/go/+/234417
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-29 20:31:43 +00:00
Cherry Zhang
cdaeaaca92 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: If2280b25fedfea9aca8560301cfa54ba4990e47b
2020-05-29 14:50:43 -04:00
Xiangdong Ji
e8f5a33191 cmd/compile: fix incorrect rewriting to if condition
Some ARM64 rewriting rules convert 'comparing to zero' conditions of if
statements to a simplified version utilizing CMN and CMP instructions to
branch over condition flags, in order to save one Add or Sub caculation.

Such optimizations lead to wrong branching in case an overflow/underflow
occurs when executing CMN or CMP.

Fix the issue by introducing new block opcodes that don't honor the
overflow/underflow flag, in the following categories:

  Block-Op        Meaning                   ARM condition codes
  1. LTnoov        less than                 MI
  2. GEnoov        greater than or equal     PL
  3. LEnoov        less than or equal        MI || EQ
  4. GTnoov        greater than              NEQ & PL

The backend generates two consecutive branch instructions for 'LEnoov'
and 'GTnoov' to model their expected behavior. A slight change to 'gc'
and amd64/386 backends is made to unify the code generation.

Add a test 'TestCondRewrite' as justification, it covers 32 incorrect rules
identified on arm64, more might be needed on other arches, like 32-bit arm.

Add two benchmarks profiling the aforementioned category 1&2 and category
3&4 separetely, we expect the first two categories will show performance
improvement and the second will not result in visible regression compared with
the non-optimized version.

This change also updates TestFormats to support using %#x.

Examples exhibiting where does the issue come from:
  1: 'if x + 3 < 0' might be converted to:
  before:
    CMN $3, R0
    BGE <else branch> // wrong branch is taken if 'x+3' overflows
  after:
    CMN $3, R0
    BPL <else branch>

  2: 'if y - 3 > 0' might be converted to:
  before:
    CMP $3, R0
    BLE <else branch> // wrong branch is taken if 'y-3' underflows
  after:
    CMP $3, R0
    BMI <else branch>
    BEQ <else branch>

Benchmark data from different kinds of arm64 servers, 'old' is the non-optimized
version (not the parent commit), generally the optimization version outperforms.

S1:
name                    old time/op  new time/op  delta
CondRewrite/SoloJump  13.6ns ± 0%  12.9ns ± 0%  -5.15%  (p=0.000 n=10+10)
CondRewrite/CombJump  13.8ns ± 1%  12.9ns ± 0%  -6.32%  (p=0.000 n=10+10)

S2:
name                     old time/op  new time/op  delta
CondRewrite/SoloJump  11.6ns ± 0%  10.9ns ± 0%  -6.03%  (p=0.000 n=10+10)
CondRewrite/CombJump  11.4ns ± 0%  10.8ns ± 1%  -5.53%  (p=0.000 n=10+10)

S3:
name                     old time/op  new time/op  delta
CondRewrite/SoloJump  7.36ns ± 0%  7.50ns ± 0%  +1.79%  (p=0.000 n=9+10)
CondRewrite/CombJump  7.35ns ± 0%  7.75ns ± 0%  +5.51%  (p=0.000 n=8+9)

S4:
name                      old time/op  new time/op  delta
CondRewrite/SoloJump-224  11.5ns ± 1%  10.9ns ± 0%  -4.97%  (p=0.000 n=10+10)
CondRewrite/CombJump-224  11.9ns ± 0%  11.5ns ± 0%  -2.95%  (p=0.000 n=10+10)

S5:
name                     old time/op  new time/op  delta
CondRewrite/SoloJump  10.0ns ± 0%  10.0ns ± 0%  -0.45%  (p=0.000 n=9+10)
CondRewrite/CombJump  9.93ns ± 0%  9.77ns ± 0%  -1.53%  (p=0.000 n=10+9)

Go1 perf. data:

name                     old time/op    new time/op    delta
BinaryTree17              6.29s ± 1%     6.30s ± 1%    ~     (p=1.000 n=5+5)
Fannkuch11                5.40s ± 0%     5.40s ± 0%    ~     (p=0.841 n=5+5)
FmtFprintfEmpty          97.9ns ± 0%    98.9ns ± 3%    ~     (p=0.937 n=4+5)
FmtFprintfString          171ns ± 3%     171ns ± 2%    ~     (p=0.754 n=5+5)
FmtFprintfInt             212ns ± 0%     217ns ± 6%  +2.55%  (p=0.008 n=5+5)
FmtFprintfIntInt          296ns ± 1%     297ns ± 2%    ~     (p=0.516 n=5+5)
FmtFprintfPrefixedInt     371ns ± 2%     374ns ± 7%    ~     (p=1.000 n=5+5)
FmtFprintfFloat           435ns ± 1%     439ns ± 2%    ~     (p=0.056 n=5+5)
FmtManyArgs              1.37µs ± 1%    1.36µs ± 1%    ~     (p=0.730 n=5+5)
GobDecode                14.6ms ± 4%    14.4ms ± 4%    ~     (p=0.690 n=5+5)
GobEncode                11.8ms ±20%    11.6ms ±15%    ~     (p=1.000 n=5+5)
Gzip                      507ms ± 0%     491ms ± 0%  -3.22%  (p=0.008 n=5+5)
Gunzip                   73.8ms ± 0%    73.9ms ± 0%    ~     (p=0.690 n=5+5)
HTTPClientServer          116µs ± 0%     116µs ± 0%    ~     (p=0.686 n=4+4)
JSONEncode               21.8ms ± 1%    21.6ms ± 2%    ~     (p=0.151 n=5+5)
JSONDecode                104ms ± 1%     103ms ± 1%  -1.08%  (p=0.016 n=5+5)
Mandelbrot200            9.53ms ± 0%    9.53ms ± 0%    ~     (p=0.421 n=5+5)
GoParse                  7.55ms ± 1%    7.51ms ± 1%    ~     (p=0.151 n=5+5)
RegexpMatchEasy0_32       158ns ± 0%     158ns ± 0%    ~     (all equal)
RegexpMatchEasy0_1K       606ns ± 1%     608ns ± 3%    ~     (p=0.937 n=5+5)
RegexpMatchEasy1_32       143ns ± 0%     144ns ± 1%    ~     (p=0.095 n=5+4)
RegexpMatchEasy1_1K       927ns ± 2%     944ns ± 2%    ~     (p=0.056 n=5+5)
RegexpMatchMedium_32     16.0ns ± 0%    16.0ns ± 0%    ~     (all equal)
RegexpMatchMedium_1K     69.3µs ± 2%    69.7µs ± 0%    ~     (p=0.690 n=5+5)
RegexpMatchHard_32       3.73µs ± 0%    3.73µs ± 1%    ~     (p=0.984 n=5+5)
RegexpMatchHard_1K        111µs ± 1%     110µs ± 0%    ~     (p=0.151 n=5+5)
Revcomp                   1.91s ±47%     1.77s ±68%    ~     (p=1.000 n=5+5)
Template                  138ms ± 1%     138ms ± 1%    ~     (p=1.000 n=5+5)
TimeParse                 787ns ± 2%     785ns ± 1%    ~     (p=0.540 n=5+5)
TimeFormat                729ns ± 1%     726ns ± 1%    ~     (p=0.151 n=5+5)

Updates #38740
Change-Id: I06c604874acdc1e63e66452dadee5df053045222
Reviewed-on: https://go-review.googlesource.com/c/go/+/233097
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2020-05-29 15:39:54 +00:00
Alberto Donizetti
65f514edfb math: fix dead link to springerlink (now link.springer)
Change-Id: Ie5fd026af45d2e7bc371a38d15dbb52a1b4958cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/235717
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-05-29 14:33:50 +00:00
Jeremy Faller
c5a9b3d63a [dev.link] cmd/link: simplify asmb2
Move lots of the binary-file format specific pieces into their
appropriate places. Similarly rescope some variables to just ld.

Change-Id: I74bc6d8aba58f5ac86e6579be1fcb356c4636825
Reviewed-on: https://go-review.googlesource.com/c/go/+/235278
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-05-29 14:09:21 +00:00
Volker Dobler
1519bc4457 net/http: clarify that AddCookie only sanitizes the Cookie being added
AddCookie properly encodes a cookie and appends it to the Cookie header
field but does not modify or sanitize what the Cookie header field
contains already. If a user manualy sets the Cookie header field to
something not conforming to RFC 6265 then a cookie added via AddCookie
might not be retrievable.

Fixes #38437

Change-Id: I232b64ac489b39bb962fe4f7dbdc2ae44fcc0514
Reviewed-on: https://go-review.googlesource.com/c/go/+/235141
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-29 09:21:54 +00:00
Daniel Martí
8f4151ea67 encoding/xml: only initialize nil struct fields when decoding
fieldInfo.value used to initialize nil anonymous struct fields if they
were encountered. This behavior is wanted when decoding, but not when
encoding. When encoding, the value should never be modified, and these
nil fields should be skipped entirely.

To fix the bug, add a bool argument to the function which tells the
code whether we are encoding or decoding.

Finally, add a couple of tests to cover the edge cases pointed out in
the original issue.

Fixes #27240.

Change-Id: Ic97ae4bfe5f2062c8518e03d1dec07c3875e18f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/196809
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-28 22:48:53 +00:00
Daniel Martí
107ebb1781 Revert "encoding/json: reuse values when decoding map elements"
This reverts golang.org/cl/179337.

Reason for revert: broke a few too many reasonably valid Go programs.
The previous behavior was perhaps less consistent, but the docs were
never very clear about when the decoder merges with existing values,
versus replacing existing values altogether.

Fixes #39149.

Change-Id: I1c1d857709b8398969fe421aa962f6b62f91763a
Reviewed-on: https://go-review.googlesource.com/c/go/+/234559
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-05-28 22:17:10 +00:00
Bryan C. Mills
86ed0955bf os: in Symlink, stat the correct target path for drive-relative targets on Windows
Previously, when the target (“old”) path passed to os.Symlink was a
“root-relative” Windows path,¹ we would erroneously prepend
destination (“new”) path when determining which path to Stat,
resulting in an invalid path which was then masked by the lack of
error propagation for the Stat call (#39183).

If the link target is a directory (rather than a file), that would
result in the symlink being created without the
SYMBOLIC_LINK_FLAG_DIRECTORY flag, which then fails in os.Open.

¹https://docs.microsoft.com/en-us/windows/win32/fileio/creating-symbolic-links

Updates #39183

Change-Id: I04f179cd2b0c44f984f34ec330acad2408aa3a20
Reviewed-on: https://go-review.googlesource.com/c/go/+/235317
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-28 21:41:10 +00:00
Dmitri Shuralyov
5a00adf1ea doc/go1.15: document no language changes
There are no language changes in Go 1.15, so document that.

For #37419.

Change-Id: I1e96e58b701f1758d64c79881dfa0b1109836b83
Reviewed-on: https://go-review.googlesource.com/c/go/+/235580
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-05-28 21:13:51 +00:00
Elias Naur
2711127974 syscall: avoid dup2 in forkAndExecInChild1 on Android
Android O and newer blocks the dup2 syscall.

Change-Id: Ibca01fc72ef114deeef6c0450a8b81a556ed0530
Reviewed-on: https://go-review.googlesource.com/c/go/+/235537
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-28 19:51:59 +00:00
Cherry Zhang
6bf2eea62a cmd/compile: always use StackMapDontCare as register map index when reg map is not used
When go115ReduceLiveness is true (so we don't emit actual
register maps), use StackMapDontCare consistently for the
register map index, so RegMapValid is always false.

This fixes a compiler crash when doing -live=2 debug print.

Fixes #39251.

Change-Id: Ice087af491fa69c413f8ee59f923b72d592c0643
Reviewed-on: https://go-review.googlesource.com/c/go/+/235418
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-05-28 14:43:19 +00:00
Bryan C. Mills
0d20a49282 run.bat: use ..\bin\go instead of "go" to install std and cmd
The paths for the other "go" commands in this file were fixed in CL 223741,
but this one was missed (and run.bat is not caught by the builders).

Change-Id: Iba1efddc7d2fbe6af39c39d643508decc954bbc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/234758
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-05-27 19:54:12 +00:00
Russ Cox
e3491c4603 net/http: handle body rewind in HTTP/2 connection loss better
In certain cases the HTTP/2 stack needs to resend a request.
It obtains a fresh body to send by calling req.GetBody.
This call was missing from the path where the HTTP/2
round tripper returns ErrSkipAltProtocol, meaning fall back
to HTTP/1.1. The result was that the HTTP/1.1 fallback
request was sent with no body at all.

This CL changes that code path to rewind the body before
falling back to HTTP/1.1. But rewinding the body is easier
said than done. Some requests have no GetBody function,
meaning the body can't be rewound. If we need to rewind and
can't, that's an error. But if we didn't read anything, we don't
need to rewind. So we have to track whether we read anything,
with a new ReadCloser wrapper. That in turn requires adding
to the couple places that unwrap Body values to look at the
underlying implementation.

This CL adds the new rewinding code in the main retry loop
as well.

The new rewindBody function also takes care of closing the
old body before abandoning it. That was missing in the old
rewind code.

Thanks to Aleksandr Razumov for CL 210123
and to Jun Chen for CL 234358, both of which informed
this CL.

Fixes #32441.

Change-Id: Id183758526c087c6b179ab73cf3b61ed23a2a46a
Reviewed-on: https://go-review.googlesource.com/c/go/+/234894
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-05-27 16:56:56 +00:00
Michael Pratt
748533e3a1 runtime: check gdb exit status and log output
All GDB tests currently ignore non-zero exit statuses. When tests
flakes, we don't even know if GDB exited successfully or not.

Add checks for non-zero exits, which are not expected.

Furthermore, always log the output from GDB. The tests are currently
inconsistent about whether they always log, or only on error.

Updates #39021

Change-Id: I7af1d795fc2fdf58093cb2731d616d4aa44e9996
Reviewed-on: https://go-review.googlesource.com/c/go/+/235282
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-27 15:53:56 +00:00
Cherry Zhang
902d8de79e cmd/link: actually close the output file
When the output file is mmap'd, OutBuf.Close currently munmap the
file but doesn't actually close the file descriptor. This CL
makes it actually close the FD.

Change-Id: I053c5592ae95497228c50ce6a267b3b48f0af6d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/235417
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-05-27 15:26:40 +00:00
Paschalis Tsilias
c0e8e405c0 cmd/go: clean -cache -n should not delete cache
Uses the `cfg.BuildN` flag to avoid deleting inside the `if cleanCache`
block. Introduces a test in src/cmd/go/testdata/script.

Fixes #39250

Change-Id: I857c441b1d7aa7c68cfd646d6833e6eaca5b18d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/235140
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-05-27 13:37:56 +00:00
Jay Conrod
b2ce3931d8 cmd/go: report error for empty GOPROXY list
If GOPROXY is "", we set it to the default value,
"https://proxy.golang.org,direct". However, if GOPROXY is a non-empty
string that doesn't contain any URLs or keywords, we treat it as
either "off" or "noproxy", which can lead to some strange errors.

This change reports an error for this kind of GOPROXY value.

For #39180

Change-Id: If2e6e39d6f74c708e5ec8f90e9d4880e0e91894f
Reviewed-on: https://go-review.googlesource.com/c/go/+/234857
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-05-26 22:28:45 +00:00
Tobias Klauser
4abec2a480 runtime, time: gofmt
Change-Id: Ib36a5f239db5af497aae122eba049c15d0d4c4a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/235139
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-05-26 22:06:26 +00:00
Katie Hockman
b5bf2f0682 crypto/x509: allow setting MaxPathLen to -1 without IsCA
This fixes a bug in CL 228777 which disallowed
a MaxPathLen of -1 without IsCA, even though the
x509.Certificate documentation indicates that
MaxPathLen of -1 is considered "unset".

Updates #38216

Change-Id: Ib7240e00408d060f27567be8b820d0eee239256f
Reviewed-on: https://go-review.googlesource.com/c/go/+/235280
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-05-26 21:29:55 +00:00
Paul D. Weber
e5a6a94aeb cmd/link/internal/ld/lib.go: use lld on Android
Set linker explicitly to lld because the default does not work on NDK
versions r19c, r20, r20b and r21. NDK 18b (or earlier) based builds
will need to specify -fuse-ld=gold.

Fixes #38838

Change-Id: Ib75f71fb9896b843910f41bd12aa1e36868fa9b3
GitHub-Last-Rev: eeaa171604
GitHub-Pull-Request: golang/go#39217
Reviewed-on: https://go-review.googlesource.com/c/go/+/235017
Reviewed-by: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-05-26 19:10:28 +00:00
Jeremy Faller
e1c0b751b5 [dev.link] cmd/link: change asmb2 api and rescope some functions
Change-Id: I49916b4740316a7042566e389759b70d7b1fa037
Reviewed-on: https://go-review.googlesource.com/c/go/+/234895
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:58:19 +00:00
Jeremy Faller
c7ade964ba [dev.link] cmd/link: move asmb2 aix from ppc64 to generic code
Removes last vestiges all but wasm's asmb2.

Change-Id: Ia06efc3ded7bfc657b5dd20a9549fd48d1355e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/234892
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:56:04 +00:00
Jeremy Faller
ebdb15f7f8 [dev.link] cmd/link: move asmb2 plan 9 architecture code out of architectures
Change-Id: I7a8f8edc4511e3ae0c44ec5017167f14d4c60755
Reviewed-on: https://go-review.googlesource.com/c/go/+/234891
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:55:53 +00:00
Jeremy Faller
13c1401b8e [dev.link] cmd/link: port asmb2 pe generation over to generic functions
Change-Id: I09ab68e1fa99bf0260b7e820b8747d5d418fd581
Reviewed-on: https://go-review.googlesource.com/c/go/+/234890
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:54:56 +00:00
Jeremy Faller
7260ad6f52 [dev.link] cmd/link: move asmb2 elf to generic handling
Change-Id: Ic3e90793f0ce49909c4f76df1272b25a1d61ebdf
Reviewed-on: https://go-review.googlesource.com/c/go/+/234887
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:54:41 +00:00
Jeremy Faller
0ca6098f70 [dev.link] cmd/link: remove Flag8 from amd64
It's only ever checked for plan 9 and it was irrelevantly set.

Change-Id: I225d4be645f573ceccde47ec2236bf3dbeb0ea70
Reviewed-on: https://go-review.googlesource.com/c/go/+/234886
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:51:40 +00:00
Jeremy Faller
c551318046 [dev.link] cmd/link: move macho asmb2 support to generic functions
Change-Id: Ic360af7c0e8de3446aa8d26d70f95f87690087ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/234883
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:48:40 +00:00
Jeremy Faller
25b283bf8c [dev.link] cmd/link: move plan9 header out of architectures
Change-Id: I7ccd14e8faa84085e976d23f83b822c05ee6a0ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/234877
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:45:23 +00:00
Than McIntosh
6265ed7452 [dev.link] cmd/compile: emit fewer R_USETYPE relocations
Background: when compiling a function, it's possible that a local
variable will be optimized away, which could potentially degrade the
debugging experience if the compiler fails to emit DWARF information
for the variable's type. To mitigate this situation, the compiler
emits R_USETYPE relocations for the function's auto/param variables as
a signal to the linker to generate DWARF for the types in question,
even if the type is not specifically attached to a DWARF param or var.

This patch change the logic in the compiler to avoid emitting a
R_USETYPE relocation if the type in question is already referenced by
a concrete DWARF param or auto record. This cuts down on the amount of
work the linker has to do, also makes object files a bit smaller on
average (about 1% for the runtime package).

Change-Id: I4d24da458d0658edf90c5dca0bf21d5ddc3961d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/234837
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:34:04 +00:00
Than McIntosh
8ca2eae206 [dev.link] cmd/link: refactor DWARF fn die processing to remove name lookups
Rework the code in the linker that visits DWARF subprorgam DIEs to
reduce number of symbol name instantiations and name lookups, by
making better use of relocation target symbol types.

Change-Id: Ifb2a4e24874b8c891d7fdf17dd749c3f9139157a
Reviewed-on: https://go-review.googlesource.com/c/go/+/234685
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-26 17:33:19 +00:00