]> Cypherpunks repositories - gostls13.git/log
gostls13.git
7 years agocmd/asm: fix crash on bad symbol for TEXT
Rob Pike [Mon, 29 Jan 2018 00:28:17 +0000 (11:28 +1100)]
cmd/asm: fix crash on bad symbol for TEXT

Was missing a check in validSymbol.

Fixes #23580.

Can wait for go1.11. Probably safe but the crash is only for
invalid input, so not worth the risk.

Change-Id: I51f88c5be35a8880536147d1fe5c5dd6798c29de
Reviewed-on: https://go-review.googlesource.com/90398
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: fix typo in OverflowInt godoc
Mark Rushakoff [Tue, 13 Feb 2018 01:15:38 +0000 (01:15 +0000)]
doc: fix typo in OverflowInt godoc

Change-Id: I426310e0c05c2b4a0123299ade0fe11721d40b10
GitHub-Last-Rev: 651c0291d6f2561e3e179a0b97e0e73ac6d21e2f
GitHub-Pull-Request: golang/go#23801
Reviewed-on: https://go-review.googlesource.com/93475
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/types: use consistent receiver names
Daniel Martí [Sun, 4 Feb 2018 09:25:55 +0000 (09:25 +0000)]
go/types: use consistent receiver names

Inconsistent names are quite obvious on the godoc HTML rendering:

type Array
    func NewArray(elem Type, len int64) *Array
    func (a *Array) Elem() Type
    func (a *Array) Len() int64
    func (t *Array) String() string
    func (t *Array) Underlying() Type

Fix all the String and Underlying methods to be consistent with their
types. This makes these two lists of methods less consistent, but that's
not visible to the user.

This also makes the inconsistent receiver names rule in golint happy.

Change-Id: I7c84d6bae1235887233a70d5f7f61a224106e952
Reviewed-on: https://go-review.googlesource.com/91736
Reviewed-by: Robert Griesemer <gri@golang.org>
7 years agocmd/compile/internal/syntax: added test cases for recent fixes
Robert Griesemer [Fri, 19 Jan 2018 00:05:39 +0000 (16:05 -0800)]
cmd/compile/internal/syntax: added test cases for recent fixes

R=go1.11.

Now that we have a syntax error test harness, we can add the
proper tests for the recent parser fixes.

For #20800.
For #20789.
For #23385.
For #23434.

A test for #20789 already exists in test/fixedbugs, but this
is the better location for that test. But leaving the existing
one where it is as well.

Change-Id: I5937b9b63bafd1efab467a00344302e717976171
Reviewed-on: https://go-review.googlesource.com/88336
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: implement regression test harness for syntax errors
Robert Griesemer [Thu, 18 Jan 2018 23:03:38 +0000 (15:03 -0800)]
cmd/compile/internal/syntax: implement regression test harness for syntax errors

R=go1.11

Fixes #20800.

Change-Id: Ifea273521d42a543a43da2f655ace7c295650e30
Reviewed-on: https://go-review.googlesource.com/88335
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: implement comment reporting in scanner
Robert Griesemer [Thu, 18 Jan 2018 05:42:51 +0000 (21:42 -0800)]
cmd/compile/internal/syntax: implement comment reporting in scanner

R=go1.11

In order to collect comments in the AST and for error testing purposes,
the scanner needs to not only recognize and skip comments, but also be
able to report them if so desired. This change adds a mode flag to the
scanner's init function which controls the scanner behavior around
comments.

In the common case where comments are not needed, there must be no
significant overhead. Thus, comments are reported via a handler upcall
rather than being returned as a _Comment token (which the parser would
have to filter out with every scanner.next() call).

Because the handlers for error messages, directives, and comments all
look the same (they take a position and text), and because directives
look like comments, and errors never start with a '/', this change
simplifies the scanner's init call to only take one (error) handler
instead of 2 or 3 different handlers with identical signature. It is
trivial in the handler to determine if we have an error, directive,
or general comment.

Finally, because directives are comments, when reporting directives
the full comment text is returned now rather than just the directive
text. This simplifies the implementation and makes the scanner API
more regular. Furthermore, it provides important information about
the comment style used by a directive, which may matter eventually
when we fully implement /*line file:line:col*/ directives.

Change-Id: I2adbfcebecd615e4237ed3a832b6ceb9518bf09c
Reviewed-on: https://go-review.googlesource.com/88215
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: better error recovery after missing type
Robert Griesemer [Wed, 17 Jan 2018 01:00:51 +0000 (17:00 -0800)]
cmd/compile/internal/syntax: better error recovery after missing type

R=go1.11.

This is just a copy of the fix for #23434:
https://go-review.googlesource.com/c/go/+/87898.

Test pending test harness for the syntax package.

Change-Id: I52409aebe13ec784ddd7e41190a81c7e126bdd0c
Reviewed-on: https://go-review.googlesource.com/87901
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: better error msg for some 'if' statements
Robert Griesemer [Thu, 11 Jan 2018 00:05:12 +0000 (16:05 -0800)]
cmd/compile/internal/syntax: better error msg for some 'if' statements

R=go1.11

A common error is to write '=' instead of '==' inside the condition
of a simple 'if' statement:

if x = 0 { ... }

Highlight the fact that we have an assignment in the error message
to prevent further confusion.

Fixes #23385.

Change-Id: I1552050fd6da927bd12a1be0977bd2e98eca5885
Reviewed-on: https://go-review.googlesource.com/87316
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: permit /*line file:line:col*/ directives
Robert Griesemer [Wed, 3 Jan 2018 23:52:22 +0000 (15:52 -0800)]
cmd/compile/internal/syntax: permit /*line file:line:col*/ directives

R=go1.11

This implements parsing of /*line file:line*/ and /*line file:line:col*/
directives and also extends the optional column format to regular //line
directives, per #22662.

For a line directive to be recognized, its comment text must start with
the prefix "line " which is followed by one of the following:

:line
:line:col
filename:line
filename:line:col

with at least one : present. The line and col values must be unsigned
decimal integers; everything before is considered part of the filename.

Valid line directives are:

//line :123
//line :123:8
//line foo.go:123
//line C:foo.go:123 (filename is "C:foo.go")
//line C:foo.go:123:8 (filename is "C:foo.go")
/*line ::123*/ (filename is ":")

No matter the comment format, at the moment all directives act as if
they were in //line comments, and column information is ignored.
To be addressed in subsequent CLs.

For #22662.

Change-Id: I1a2dc54bacc94bc6cdedc5229ee13278971f314e
Reviewed-on: https://go-review.googlesource.com/86037
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agocmd/compile/internal/syntax: remove ParseBytes from API - not needed
Robert Griesemer [Tue, 2 Jan 2018 21:36:38 +0000 (13:36 -0800)]
cmd/compile/internal/syntax: remove ParseBytes from API - not needed

R=go1.11

Also: Minor updates to syntax.Parse doc string.

Change-Id: I649965be9670a2f1c3de2cdb350634ed21e36ad9
Reviewed-on: https://go-review.googlesource.com/85663
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/parser: improved error message for unexpected literals
Robert Griesemer [Wed, 17 Jan 2018 00:17:54 +0000 (16:17 -0800)]
go/parser: improved error message for unexpected literals

R=go1.11

This is a follow up for #11377 which reported that an error like

/tmp/xx.go:9:6: expected '(', found 'IDENT' F1

shouldn't print 'IDENT', as it's just an internal detail.
The relevant change wasn't made in the original fix, so here it is.

For #11377.

Change-Id: Ib76957d86b88e3e63646fbe4abf03a3b9d045139
Reviewed-on: https://go-review.googlesource.com/87900
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/parser: remove newly introduced TODO (cleanup)
Robert Griesemer [Tue, 16 Jan 2018 23:58:46 +0000 (15:58 -0800)]
go/parser: remove newly introduced TODO (cleanup)

R=go1.11

No semantic change.

For #23434.

Change-Id: Iafdb062b0ebe6cd6e51f9a98b62b1d10f1bacc5c
Reviewed-on: https://go-review.googlesource.com/87899
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/parser: improved error recovery after missing type
Robert Griesemer [Tue, 16 Jan 2018 23:28:57 +0000 (15:28 -0800)]
go/parser: improved error recovery after missing type

R=go1.11

This CL also introduces a new TODO in parser.go. To be
addressed in a separate CL to make this easier to review.

Also: Make parser's test harness easier to use by ignoring
auto-inserted (invisible) semicolons when computing error
positions. Adjusted testdata/commas.src accordingly.

Fixes #23434.

Change-Id: I050592d11d5f984f71185548394c000eea509205
Reviewed-on: https://go-review.googlesource.com/87898
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/scanner: don't eat \r in comments if that shortens the comment
Robert Griesemer [Fri, 12 Jan 2018 05:52:27 +0000 (21:52 -0800)]
go/scanner: don't eat \r in comments if that shortens the comment

For consistent formatting across platforms we strip \r's from
comments. This happens in the go/scanner which already does
this for raw string literals where it is mandated by the spec.
But if a (sequence of) \r appears in a regular (/*-style) comment
between a * and a /, removing that (sequence of) \r shortens that
text segment to */ which terminates the comment prematurely.

Don't do it.

As an aside, a better approach would be to not touch comments,
(and raw string literals for that matter) in the scanner and
leave the extra processing to clients. That is the approach
taken by the cmd/compile/internal/syntax package. However, we
probably can't change the semantics here too much, so just do
the minimal change that doesn't produce invalid comments. It's
an esoteric case after all.

Fixes #11151.

Change-Id: Ib4dcb52094f13c235e840c9672e439ea65fef961
Reviewed-on: https://go-review.googlesource.com/87498
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/parser: more robust error handling for 'if' headers
Robert Griesemer [Thu, 11 Jan 2018 23:09:38 +0000 (15:09 -0800)]
go/parser: more robust error handling for 'if' headers

R=go1.11

To fix this, this CL borrows code from the new syntax
package which has a better tuned parser at this point.

Fixes #11377.

Change-Id: Ib9212c945903d6f62abcc59ef5a5767d4ef36981
Reviewed-on: https://go-review.googlesource.com/87495
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 years agogo/parser: simplify code to read from an io.Reader (cleanup)
Robert Griesemer [Sat, 23 Dec 2017 00:29:36 +0000 (16:29 -0800)]
go/parser: simplify code to read from an io.Reader (cleanup)

ioutil.ReadAll didn't exist when we wrote that parser code
originally (in 2009). Now it does, so use it. This may also
make that code path slightly more efficient.

Also, now that we are guaranteed to have a fast path for reading
from an io.Reader (and thus an io.ReadCloser), simplify setup
code for parser.ParseFile calls in srcimporter.Importer.ParseFiles.

Remove the associated TODO since we cannot reproduce any significant
performance differences when running go test -run ImportStdLib for
the case where we used to read directly from a file (even before the
change to the parser).

Fixes #19281.

Change-Id: I816459d092bb9e27fdc85089b8f21d57ec3fd79a
Reviewed-on: https://go-review.googlesource.com/85395
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/importer: use named receiver types for methods of named interfaces
Robert Griesemer [Fri, 22 Dec 2017 23:04:20 +0000 (15:04 -0800)]
go/importer: use named receiver types for methods of named interfaces

R=go1.11

Once approved, this change must be ported to golang.org/x/tools/go/gcimporter15.

Fixes #13829.

Change-Id: I26a0094d2bfd38b97f2b64bae84b9f428fc9cdf1
Reviewed-on: https://go-review.googlesource.com/85318
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agoruntime: remove legacy comments and code from arm morestack
Austin Clements [Tue, 6 Feb 2018 23:00:13 +0000 (18:00 -0500)]
runtime: remove legacy comments and code from arm morestack

CL 137410043 deleted support for split stacks, which means morestack
no longer needed to save its caller's frame or argument size or its
caller's argument pointer. However, this commit failed to update the
comment or delete the line that computed the caller's argument
pointer. Clean these up now.

Change-Id: I65725d3d42c86e8adb6645d5aa80c305d473363d
Reviewed-on: https://go-review.googlesource.com/92437
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: use NOFRAME on mips and mips64
Austin Clements [Thu, 25 Jan 2018 17:15:23 +0000 (12:15 -0500)]
runtime: use NOFRAME on mips and mips64

This replaces frame size -4/-8 with the NOFRAME flag in mips and
mips64 assembly.

This was automated with:

sed -i -e 's/\(^TEXT.*[A-Z]\),\( *\)\$-[84]/\1|NOFRAME,\2$0/' $(find -name '*_mips*.s')

Plus a manual fix to mkduff.go.

The go binary is identical on both architectures before and after this
change.

Change-Id: I0310384d1a584118c41d1cd3a042bb8ea7227efb
Reviewed-on: https://go-review.googlesource.com/92044
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: use NOFRAME on arm64
Austin Clements [Thu, 25 Jan 2018 17:15:23 +0000 (12:15 -0500)]
runtime: use NOFRAME on arm64

This replaces frame size -8 with the NOFRAME flag in arm64 assembly.

This was automated with:

sed -i -e 's/\(^TEXT.*[A-Z]\),\( *\)\$-8/\1|NOFRAME,\2$0/' $(find -name '*_arm64.s')

Plus a manual fix to mkduff.go.

The go binary is identical before and after this change.

Change-Id: I0310384d1a584118c41d1cd3a042bb8ea7227efa
Reviewed-on: https://go-review.googlesource.com/92043
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime, sync/atomic: use NOFRAME on arm
Austin Clements [Thu, 25 Jan 2018 17:15:23 +0000 (12:15 -0500)]
runtime, sync/atomic: use NOFRAME on arm

This replaces frame size -4 with the NOFRAME flag in arm assembly.

This was automated with:

sed -i -e 's/\(^TEXT.*[A-Z]\),\( *\)\$-4/\1|NOFRAME,\2$0/' $(find -name '*_arm.s')

Plus three manual comment changes found by:

grep '\$-4' $(find -name '*_arm.s')

The go binary is identical before and after this change.

Change-Id: I0310384d1a584118c41d1cd3a042bb8ea7227ef9
Reviewed-on: https://go-review.googlesource.com/92042
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/vet: teach asmdecl check about NOFRAME
Austin Clements [Tue, 6 Feb 2018 22:39:50 +0000 (17:39 -0500)]
cmd/vet: teach asmdecl check about NOFRAME

Change-Id: I3f71228e391f122f9cc5656ca6835fdf51a424b7
Reviewed-on: https://go-review.googlesource.com/92435
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/mips: support NOFRAME
Austin Clements [Wed, 24 Jan 2018 22:17:38 +0000 (17:17 -0500)]
cmd/internal/obj/mips: support NOFRAME

This passes toolstash -cmp with one exception: assembly functions that
were declared with a frame size of -4 (or -8) used to record
locals=0xfffffffffffffffc in the object file and now record
locals=0x0. This doesn't affect anything.

Change-Id: I0d15e81770e54222ae329ce4496da06016736771
Reviewed-on: https://go-review.googlesource.com/92041
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/arm64: support NOFRAME
Austin Clements [Wed, 24 Jan 2018 22:17:38 +0000 (17:17 -0500)]
cmd/internal/obj/arm64: support NOFRAME

In addition, this makes the arm64 prologue code generation much closer
to the pattern used on other platforms.

This passes toolstash -cmp with one exception: assembly functions that
were declared with a frame size of -8 used to record
locals=0xfffffffffffffff8 in the object file and now record
locals=0x0. This doesn't affect anything.

Change-Id: I0d15e81770e54222ae329ce4496da06016736770
Reviewed-on: https://go-review.googlesource.com/92040
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/arm: support NOFRAME
Austin Clements [Wed, 24 Jan 2018 22:17:38 +0000 (17:17 -0500)]
cmd/internal/obj/arm: support NOFRAME

This adds support on arm for the NOFRAME symbol attribute used by
ppc64 and s390x in preference to using a frame size of -4. This is
modeled on ppc64's implementation of NOFRAME.

This passes toolstash -cmp.

Change-Id: I0d15e81770e54222ae329ce4496da0601673677f
Reviewed-on: https://go-review.googlesource.com/92039
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agoruntime: fix silly frame sizes on arm and arm64
Austin Clements [Thu, 25 Jan 2018 18:57:37 +0000 (13:57 -0500)]
runtime: fix silly frame sizes on arm and arm64

"-8" is not a sensible frame size on arm and we're about to start
rejecting it. Replace it with -4.

Likewise, "-4" is not a sensible frame size on arm64 and we're about
to start rejecting it. Replace it with -8.

Finally, clean up some places we're weirdly inconsistent about using 0
versus -8.

Change-Id: If85e229993d5f7f1f0cfa9852b4e294d053bd784
Reviewed-on: https://go-review.googlesource.com/92038
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/arm64: omit stack check for no-frame leafs
Austin Clements [Thu, 25 Jan 2018 18:31:03 +0000 (13:31 -0500)]
cmd/internal/obj/arm64: omit stack check for no-frame leafs

For leaf functions with zero-sized frames, there's no point in doing a
stack check, so omit it.

This aligns arm64 with other architectures.

Change-Id: I1fb483d62f1736af10c5110815d3f5a875a46d7f
Reviewed-on: https://go-review.googlesource.com/92037
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/compile: eliminate NoFramePointer
Austin Clements [Thu, 25 Jan 2018 16:41:41 +0000 (11:41 -0500)]
cmd/compile: eliminate NoFramePointer

The NoFramePointer function flag is no longer used, so this CL
eliminates it. This cleans up some confusion between the compiler's
NoFramePointer flag and obj's NOFRAME flag. NoFramePointer was
intended to eliminate the saved base pointer on x86, but it was
translated into obj's NOFRAME flag. On x86, NOFRAME does mean to omit
the saved base pointer, but on ppc64 and s390x it has a more general
meaning of omitting *everything* from the frame, including the saved
LR and ppc64's "fixed frame". Hence, on ppc64 and s390x there are far
fewer situations where it is safe to set this flag.

Change-Id: If68991310b4d00638128c296bdd57f4ed731b46d
Reviewed-on: https://go-review.googlesource.com/92036
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/internal/obj/x86: adjust SP correctly for tail calls
Austin Clements [Thu, 25 Jan 2018 16:35:27 +0000 (11:35 -0500)]
cmd/internal/obj/x86: adjust SP correctly for tail calls

Currently, tail calls on x86 don't adjust the SP on return, so it's
important that the compiler produce a zero-sized frame and disable the
frame pointer. However, these constraints aren't necessary. For
example, on other architectures it's generally necessary to restore
the saved LR before a tail call, so obj simply makes this work.
Likewise, on x86, there's no reason we can't simply make this work.

Hence, this CL adjusts the compiler to use the same tail call
convention for x86 that we use on LR machines by producing a RET with
a target, rather than a JMP with a target. In fact, obj already
understands this convention for x86 except that it's buggy with
non-zero frame sizes. So we also fix this bug obj. As a result of
these fixes, the compiler no longer needs to mark wrappers as
NoFramePointer since it's now perfectly fine to save the frame
pointer.

In fact, this eliminates the only use of NoFramePointer in the
compiler, which will enable further cleanups.

This also fixes what is very nearly, but not quite, a code generation
bug. NoFramePointer becomes obj.NOFRAME in the object file, which on
ppc64 and s390x means to omit the saved LR. Hence, on these
architectures, NoFramePointer (and NOFRAME) is only safe to set on
leaf functions. However, on *most* architectures, wrappers aren't
necessarily leaf functions because they may call DUFFZERO. We're saved
on ppc64 and s390x only because the compiler doesn't have the rules to
produce DUFFZERO calls on these architectures. Hence, this only works
because the set of LR architectures that implement NOFRAME is disjoint
from the set where the compiler produces DUFFZERO operations. (I
discovered this whole mess when I attempted to add NOFRAME support to
arm.)

Change-Id: Icc589aeb86beacb850d0a6a80bd3024974a33947
Reviewed-on: https://go-review.googlesource.com/92035
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agogo/types: use check.lookup consistently where possible (cleanup)
Robert Griesemer [Thu, 21 Dec 2017 22:35:21 +0000 (14:35 -0800)]
go/types: use check.lookup consistently where possible (cleanup)

This CL converts the last call to scope.LookupParent with no position
information to a check.lookup call that respects position information
provided by Eval (there's one more LookupParent call that cannot be
converted, see the respective comment in the code).

In this case, the lookup is needed to determine the variable on the
LHS of an assignment, for adjustment of its `used` information.

Outside a types.Eval call, i.e., during normal type-checking, there
is no difference between this new code and the old code.

While in a types.Eval call, it's important to use the correct position
to look up the relevant variable. If token.NoPos were used, one might
find another variable with the same name, declared later in the scope.

Caveat: Types.Eval only accepts expressions, and it's currently not
possible to evaluate assignments (except via function literals, but
then the scope is different). That is, this change is a fix for a
potential future bug, and for now a no-op.

Change-Id: I28db1fe1202c07e3f7b3fadfd185728afb9b2ae7
Reviewed-on: https://go-review.googlesource.com/85199
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: correctly determine if panic call refers to built-in
Robert Griesemer [Thu, 21 Dec 2017 22:15:20 +0000 (14:15 -0800)]
go/types: correctly determine if panic call refers to built-in

R=go1.11

The terminating statement check for functions that declare result
parameters was using the wrong scope to look up calls to `panic`
which in esoteric cases lead to a false positive.

Instead of looking up a panic call again at a time when correct
scope information would have to be recomputed, collect calls to
predeclared panic in a set when type-checking that call.

Fixes #23218.

Change-Id: I35eaf010e5cb8e43696efba7d77cefffb6f3deb2
Reviewed-on: https://go-review.googlesource.com/85198
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: perform delayed tests even for types.Eval
Robert Griesemer [Tue, 19 Dec 2017 23:45:50 +0000 (15:45 -0800)]
go/types: perform delayed tests even for types.Eval

R=go1.11

types.Eval historically never evaluated any delayed tests, which
included verification of validity of map keys, but also function
literal bodies.

Now, embedded interfaces are also type-checked in a delayed fashion,
so it becomes imperative to do all delayed checks for eval (otherwise
obviously incorrect type expressions are silently accepted).

Enabling the delayed tests also removes the restriction that function
literals were not type-checked.

Also fixed a bug where eval wouldn't return a type-checking error
because check.handleBailout was using the wrong err variable.

Added tests that verify that method set computation is using the
right types when evaluating interfaces with embedded types.

For #18395.
For #22992.

Change-Id: I574fa84568b5158bca4b4ccd4ef5abb616fbf896
Reviewed-on: https://go-review.googlesource.com/84898
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: don't associate methods with alias type names
Robert Griesemer [Thu, 14 Dec 2017 05:37:13 +0000 (21:37 -0800)]
go/types: don't associate methods with alias type names

R=go1.11

The existing code associated methods with receiver base type
names before knowing if a type name denoted a locally defined
type. Sometimes, methods would be incorrectly associated with
alias type names and consequently were lost down the road.

This change first collects all methods with non-blank names
and in a follow-up pass resolves receiver base type names to
valid non-alias type names with which the methods are then
associated.

Fixes #23042.

Change-Id: I7699e577b70aadef6a2997e882beb0644da89fa3
Reviewed-on: https://go-review.googlesource.com/83996
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: accept iotas inside closures of const init expressions
Robert Griesemer [Wed, 13 Dec 2017 01:46:57 +0000 (17:46 -0800)]
go/types: accept iotas inside closures of const init expressions

R=go1.11

Fixes #22345.

Change-Id: I7cf22d17bdd0143efb6ee48981e649ffe797aed9
Reviewed-on: https://go-review.googlesource.com/83579
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: delay type-checking of function literals
Robert Griesemer [Mon, 11 Dec 2017 23:30:39 +0000 (15:30 -0800)]
go/types: delay type-checking of function literals

R=go1.11

Functions (at the package level) were collected and their bodies
type-checked after all other package-level objects were checked.
But function literals where type-checked right away when they were
encountered so that they could see the correct, partially populated
surrounding scope, and also to mark variables of the surrounding
function as used.

This approach, while simple, breaks down in esoteric cases where
a function literal appears inside the declaration of an object
that its body depends on: If the body is type-checked before the
object is completely set up, the literal may use incomplete data
structures, possibly leading to spurious errors.

This change postpones type-checking of function literals to later;
after the current expression or statement, but before any changes
to the enclosing scope (so that the delayed type-checking sees the
correct scope contents).

The new mechanism is general and now is also used for other
(non-function) delayed checks.

Fixes #22992.

Change-Id: Ic95f709560858b4bdf8c645be70abe4449f6184d
Reviewed-on: https://go-review.googlesource.com/83397
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: add lookup method to context and factor out LookupParent calls
Robert Griesemer [Fri, 8 Dec 2017 23:55:27 +0000 (15:55 -0800)]
go/types: add lookup method to context and factor out LookupParent calls

R=go1.11

Also: Moved Checker.pos field into context where it belongs.

This is a cleanup/code factoring.

For #22992.

Change-Id: If9d4f0af537cb181f73735e709ebc8258b2a1378
Reviewed-on: https://go-review.googlesource.com/83017
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agogo/types: correctly compute method set of some recursive interfaces
Robert Griesemer [Tue, 21 Nov 2017 23:53:39 +0000 (15:53 -0800)]
go/types: correctly compute method set of some recursive interfaces

R=go1.11.

The existing algorithm for type-checking interfaces breaks down in
complex cases of recursive types, e.g.:

package issue21804

type (
_ interface{ m(B) }
A interface{ a(D) }
B interface{ A }
C interface{ B }
D interface{ C }
)

var _ A = C(nil)

The underlying problem is that the method set of C is computed by
following a chain of embedded interfaces at a point when the method
set for one of those interfaces is not yet complete. A more general
problem is largely avoided by topological sorting of interfaces
depending on their dependencies on embedded interfaces (but not
method parameters).

This change fixes this problem by fundamentally changing how
interface method sets are computed: Instead of determining them
based on recursively type-checking embedded interfaces, the new
approach computes the method sets of interfaces separately,
based on syntactic structure and name resolution; and using type-
checked types only when readily available (e.g., for local types
which can at best refer to themselves, and imported interfaces).

This approach avoids cyclic dependencies arising in the method
sets by separating the collection of embedded methods (which
fundamentally cannot have cycles in correct programs) and type-
checking of the method's signatures (which may have arbitrary
cycles).

As a consequence, type-checking interfaces can rely on the
pre-computed method sets which makes the code simpler: Type-
checking of embedded interface types doesn't have to happen
anymore during interface construction since we already have
all methods and now is delayed to the end of type-checking.
Also, the topological sort of global interfaces is not needed
anymore.

Fixes #18395.

Change-Id: I0f849ac9568e87a32c9c27bbf8fab0e2bac9ebb1
Reviewed-on: https://go-review.googlesource.com/79575
Reviewed-by: Alan Donovan <adonovan@google.com>
7 years agoall: restore changes from faulty merge/revert
Andrew Bonventre [Mon, 12 Feb 2018 20:13:33 +0000 (20:13 +0000)]
all: restore changes from faulty merge/revert

This reverts commit 3b6abd8a4501d816e80b4d46e6fda4df486ccb66.

Change-Id: I8ca100501c1844af78a547989786d14dac6b494a
Reviewed-on: https://go-review.googlesource.com/93456
Reviewed-by: Andrew Bonventre <andybons@golang.org>
7 years agoRevert "[release-branch.go1.10] all: merge master into release-branch.go1.10"
Andrew Bonventre [Mon, 12 Feb 2018 20:09:58 +0000 (20:09 +0000)]
Revert "[release-branch.go1.10] all: merge master into release-branch.go1.10"

This reverts commit b83d7f72537bdc0cec2e949d73ae40fbd42b7c63.

Reason for revert: wrong branch

Change-Id: I28ebb121f7b3e331729e8a6a00961b876f3dd0f2
Reviewed-on: https://go-review.googlesource.com/93455
Reviewed-by: Andrew Bonventre <andybons@golang.org>
7 years ago[release-branch.go1.10] all: merge master into release-branch.go1.10
Andrew Bonventre [Mon, 12 Feb 2018 20:05:15 +0000 (15:05 -0500)]
[release-branch.go1.10] all: merge master into release-branch.go1.10

74b56022a1 doc: note that x509 cert parsing rejects some more certs now
c52e27e68d CONTRIBUTING: remove Pull Request bit
829b64c1ea cmd/fix: fix cast check
ee59f6dff2 doc: minor wording improvement to the diagnostics guide
c6e7330ebd all: remove PULL_REQUEST_TEMPLATE from .github
d814c2be9b doc: remove Pull Request note in README.md
104445e314 doc: document Go 1.9.4 and Go 1.8.7

Change-Id: I58bfc6800964504258690d774a9b0aeaba509086

7 years agodoc: note that x509 cert parsing rejects some more certs now
Brad Fitzpatrick [Wed, 7 Feb 2018 16:07:34 +0000 (16:07 +0000)]
doc: note that x509 cert parsing rejects some more certs now

Fixes #23711

7 years agoCONTRIBUTING: remove Pull Request bit
Brad Fitzpatrick [Sun, 11 Feb 2018 16:20:38 +0000 (16:20 +0000)]
CONTRIBUTING: remove Pull Request bit

Also remove the "Also, please do not post patches on the issue
tracker" part, since that didn't seem to reduce the number of patches
inlined into bug reports. And now that we accept PRs, people will
probably try that first. We'll see.

Fixes #23779
Updates #18517

Change-Id: I449e0afd7292718e57d9d428494799c78296a0d2
Reviewed-on: https://go-review.googlesource.com/93335
Reviewed-by: Andrew Bonventre <andybons@golang.org>
7 years agocmd/fix: fix cast check
Keith Randall [Fri, 9 Feb 2018 19:21:37 +0000 (11:21 -0800)]
cmd/fix: fix cast check

Need 2-result cast so we can check the result correctly.

Fixes #23762

Change-Id: Icac3a5415156fe918988f369d6022a9a29c14089
Reviewed-on: https://go-review.googlesource.com/93078
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodoc: minor wording improvement to the diagnostics guide
JBD [Fri, 9 Feb 2018 01:14:31 +0000 (01:14 +0000)]
doc: minor wording improvement to the diagnostics guide

Change-Id: I8469fbbb934f096f04ad68c592aacdb805b6d2d4
GitHub-Last-Rev: 6d2cfcc23d0d8e6a1b6ca383dae51f0cada2e1b3
GitHub-Pull-Request: golang/go#23754
Reviewed-on: https://go-review.googlesource.com/92996
Reviewed-by: Andrew Bonventre <andybons@golang.org>
7 years agoall: remove PULL_REQUEST_TEMPLATE from .github
Andrew Bonventre [Fri, 9 Feb 2018 00:29:19 +0000 (19:29 -0500)]
all: remove PULL_REQUEST_TEMPLATE from .github

Update golang/go#18517

Change-Id: I76d928d5fcc5ed22beaffb86f0fa8fbf6d4ac3d7
Reviewed-on: https://go-review.googlesource.com/93035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: remove Pull Request note in README.md
Andrew Bonventre [Thu, 8 Feb 2018 23:50:16 +0000 (23:50 +0000)]
doc: remove Pull Request note in README.md

Since we now accept Pull Requests via GerritBot, this comment is obsolete.

Change-Id: I0de8ecff7d1f146320a52f143e65068f8adbeaa6
GitHub-Last-Rev: 01818bdf7a8361efde427a872b813f2e8510cef7
GitHub-Pull-Request: golang/go#23752
Reviewed-on: https://go-review.googlesource.com/92995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: document Go 1.9.4 and Go 1.8.7
Russ Cox [Wed, 7 Feb 2018 19:10:48 +0000 (14:10 -0500)]
doc: document Go 1.9.4 and Go 1.8.7

Change-Id: I50928e7747f43858fc863b53cfb5b63e208d6932
Reviewed-on: https://team-review.git.corp.google.com/213447
Reviewed-by: Andrew Bonventre <andybons@google.com>
7 years ago[release-branch.go1.10] go1.10rc2 go1.10rc2
Russ Cox [Wed, 7 Feb 2018 16:05:41 +0000 (11:05 -0500)]
[release-branch.go1.10] go1.10rc2

Change-Id: I393ff9e8599d20f71545ab9f4191993f5d6fa5a4
Reviewed-on: https://team-review.git.corp.google.com/213247
Reviewed-by: Andrew Bonventre <andybons@google.com>
7 years ago[release-branch.go1.10] all: merge master into release-branch.go1.10, for go1.10rc2
Russ Cox [Wed, 7 Feb 2018 15:37:00 +0000 (10:37 -0500)]
[release-branch.go1.10] all: merge master into release-branch.go1.10, for go1.10rc2

This adds the go get security fix.

1dcb5836 cmd/go: accept only limited compiler and linker flags in #cgo directives

Change-Id: Ib2caf2039d2cefabe3afa0bb4dcc4c0dc8d664ff

7 years agocmd/go: accept only limited compiler and linker flags in #cgo directives
Russ Cox [Thu, 1 Feb 2018 19:07:21 +0000 (14:07 -0500)]
cmd/go: accept only limited compiler and linker flags in #cgo directives

Both gcc and clang accept an option -fplugin=code.so to load
a plugin from the ELF shared object file code.so.
Obviously that plugin can then do anything it wants
during the build. This is contrary to the goal of "go get"
never running untrusted code during the build.
(What happens if you choose to run the result of
the build is your responsibility.)

Disallow this behavior by only allowing a small set of
known command-line flags in #cgo CFLAGS directives
(and #cgo LDFLAGS, etc).

The new restrictions can be adjusted by the environment
variables CGO_CFLAGS_ALLOW, CGO_CFLAGS_DISALLOW,
and so on. See the documentation.

In addition to excluding cgo-defined flags, we also have to
make sure that when we pass file names on the command
line, they don't look like flags. So we now refuse to build
packages containing suspicious file names like -x.go.

A wrinkle in all this is that GNU binutils uniformly accept
@foo on the command line to mean "if the file foo exists,
then substitute its contents for @foo in the command line".
So we must also reject @x.go, flags and flag arguments
beginning with @, and so on.

Fixes #23672, CVE-2018-6574.

Change-Id: I59e7c1355155c335a5c5ae0d2cf8fa7aa313940a
Reviewed-on: https://team-review.git.corp.google.com/209949
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 years agoall: merge master into release-branch.go1.10, for go1.10rc2
Russ Cox [Wed, 7 Feb 2018 14:33:20 +0000 (09:33 -0500)]
all: merge master into release-branch.go1.10, for go1.10rc2

b2d3d6e6 cmd/link/internal/loadelf: fix logic for computing ELF flags on ARM
c07095cd cmd/cgo: revert CL 49490 "fix for function taking pointer typedef"
23e8e197 cmd/compile: use unsigned loads for multi-element comparisons
85bdd05c cmd/go: rebuild as needed for tests of packages that add methods
fd7331a8 text/template: revert CL 66410 "add break, continue actions in ranges"
f54f780d cmd/vet: unexported interface{} fields on %s are ok
a0222ec5 cmd/internal/obj/arm64: fix assemble add/adds/sub/subs/cmp/cmn(extended register) bug
59523176 cmd/go: only run -race test if -race works
4558321e doc/editors: remove feature matrix for various editors/IDEs
e6756ec1 cmd/go: ignore coverpkg match on sync/atomic in atomic coverage mode
10d096fe cmd/go: fix import config debugging flag
f598ad58 go/internal/gccgoimporter: remove old and exp gccgo packages in test
2a8229d9 misc/cgo/test: get uintptr, not pointer, from dlopen
851e98f0 spec: remove need for separate Function production (cleanup)
cbe1a61e net: fix the kernel state name for TCP listen queue on FreeBSD
6f37fee3 cmd/go: fix TestNoCache on Plan 9
e5186895 runtime: restore RSB for sigpanic call on mips64x
3ff41cdf runtime: suppress "unexpected return pc" any time we're in cgo
d929e40e syscall: use SYS_GETDENTS64 on linux/mips64{,le}
43288467 test: add test for gccgo bug 23545
19150303 cmd/go: if unable to initialize cache, just disable it
ebe38b86 runtime: fail silently if we unwind over sigpanic into C code
5c2be42a runtime: don't unwind past asmcgocall
03e10bd9 os/signal: skip TestTerminalSignal if posix_openpt fails with EACCES
d30591c1 cmd/vendor/github.com/google/pprof: cherry-pick fix to cope with $HOME not being writable
bcc86d5f doc: add GOMIPS to source installation docs
926f2787 cmd/fix: cleanup directories created during typecheck
32a08d09 bootstrap.bash: only fetch git revision if we need it
14f8027a cmd/vet: extra args if any formats are indexed are ok
4072608b cmd/vet: %s is valid for an array of stringer
1f85917f cmd/vet: **T is not Stringer if *T has a String method
8c1f21d9 cmd/vet: disable complaint about 0 flag in print
d529aa93 doc: fix the closing tag in contribute.html
f8610bbd doc: fix two small mistakes in 1.10 release notes
5af1e7d7 cmd/go: skip external tests on plan9/arm
00587e89 doc: fix spelling mistake
3ee8c3cc os: document inheritance of thread state over exec
b5b35be2 cmd/compile: don't inline functions that call recover
651ddbdb database/sql: buffers provided to Rows.Next should not be modified by drivers
7350297e doc: remove Sarah Adams from conduct working group contacts

Change-Id: I3c04d83706cd4322252ddf732688afe5d938c1f5

7 years agocmd/link/internal/loadelf: fix logic for computing ELF flags on ARM
Michael Hudson-Doyle [Wed, 7 Feb 2018 02:46:26 +0000 (15:46 +1300)]
cmd/link/internal/loadelf: fix logic for computing ELF flags on ARM

The linker contains complicated logic for figuring out which float ABI to
indicate it is using on (32 bit) ARM systems: it parses a special section in
host object files to look for a flag indicating use of the hard float ABI. When
loadelf got split into its own package a bug was introduced: if the last host
object file does not contain a float ABI related tag, the ELF header's flag was
set to 0, rather than using the value from the last object file which contained
an ABI tag. Fix the code to only change the value used for the ELF header if a
tag was found.

This fixes an extremely confusing build failure on Ubuntu's armhf builders.

Change-Id: I0845d68d082d1383e4cae84ea85164cdc6bcdddb
Reviewed-on: https://go-review.googlesource.com/92515
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/cgo: revert CL 49490 "fix for function taking pointer typedef"
Ian Lance Taylor [Tue, 6 Feb 2018 23:11:59 +0000 (15:11 -0800)]
cmd/cgo: revert CL 49490 "fix for function taking pointer typedef"

CL 49490 fixed a warning when compiling the C code generated by cgo,
but it introduced typedef conflicts in Go code that cgo is supposed to
avoid.

Original CL description:

    cmd/cgo: fix for function taking pointer typedef

    Fixes #19832

Updates #19832
Fixes #23720

Change-Id: I22a732db31be0b4f7248c105277ab8ee44ef6cfb
Reviewed-on: https://go-review.googlesource.com/92455
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
7 years agocmd/compile: use unsigned loads for multi-element comparisons
Keith Randall [Tue, 6 Feb 2018 17:44:34 +0000 (09:44 -0800)]
cmd/compile: use unsigned loads for multi-element comparisons

When loading multiple elements of an array into a single register,
make sure we treat them as unsigned.  When treated as signed, the
upper bits might all be set, causing the shift-or combo to clobber
the values higher in the register.

Fixes #23719.

Change-Id: Ic87da03e9bd0fe2c60bb214b99f846e4e9446052
Reviewed-on: https://go-review.googlesource.com/92335
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
7 years agocmd/go: rebuild as needed for tests of packages that add methods
Russ Cox [Tue, 6 Feb 2018 04:57:41 +0000 (23:57 -0500)]
cmd/go: rebuild as needed for tests of packages that add methods

If A's external test package imports B, which imports A,
and A's (internal) test code also adds something to A that
invalidates anything in the export data from a build of A
without its test code, then strictly speaking we need to
rebuild B against the test-augmented version of A before
using it to build A's external test package.

We've been skating by without doing this for a very long time,
but I knew we'd need to handle it better eventually,
I planned for it in the new build cache simplifications,
and the code was ready. Now that we have a real-world
test case that needs it, turn on the "proper rebuilding" code.

It doesn't really matter how much things slow down, since
a real-world test cases that caused an internal compiler error
before is now handled correctly, but it appears to be small:
I wasn't able to measure an effect on "go test -a -c fmt".
And of course most builds won't use -a and will be cached well.

Fixes #6204.
Fixes #23701.

Change-Id: I2cd60cf400d1928428979ab05831f48ff7cee6ca
Reviewed-on: https://go-review.googlesource.com/92215
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agotext/template: revert CL 66410 "add break, continue actions in ranges"
Ian Lance Taylor [Mon, 5 Feb 2018 23:50:29 +0000 (15:50 -0800)]
text/template: revert CL 66410 "add break, continue actions in ranges"

The new break and continue actions do not work in html/template, and
fixing them requires thinking about security issues that seem too
tricky at this stage of the release. We will try again for 1.11.

Original CL description:

    text/template: add break, continue actions in ranges

    Adds the two range control actions "break" and "continue". They act the
    same as the Go keywords break and continue, but are simplified in that
    only the innermost range statement can be broken out of or continued.

    Fixes #20531

Updates #20531
Updates #23683

Change-Id: Ia7fd3c409163e3bcb5dc42947ae90b15bdf89853
Reviewed-on: https://go-review.googlesource.com/92155
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agocmd/vet: unexported interface{} fields on %s are ok
Daniel Martí [Mon, 29 Jan 2018 11:14:31 +0000 (11:14 +0000)]
cmd/vet: unexported interface{} fields on %s are ok

For example, the following program is valid:

type T struct {
f interface{}
}

func main() {
fmt.Printf("%s", T{"foo"}) // prints {foo}
}

Since the field is of type interface{}, we might have any value in it.
For example, if we had T{3}, fmt would complain. However, not knowing
what the type under the interface is, we must be conservative.

However, as shown in #17798, we should issue an error if the field's
type is statically known to implement the error or fmt.Stringer
interfaces. In those cases, the user likely wanted the %s format to call
those methods. Keep the vet error in those cases.

While at it, add more field type test cases, such as custom error types,
and interfaces that extend the error interface.

Fixes #23563.

Change-Id: I063885955555917c59da000391b603f0d6dce432
Reviewed-on: https://go-review.googlesource.com/90516
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/internal/obj/arm64: fix assemble add/adds/sub/subs/cmp/cmn(extended register...
fanzha02 [Wed, 17 Jan 2018 10:25:26 +0000 (10:25 +0000)]
cmd/internal/obj/arm64: fix assemble add/adds/sub/subs/cmp/cmn(extended register) bug

The current code encodes the wrong option value in the binary.

The fix reconstructs the function opxrrr() that does not encode the option
value into the binary value when arguments is sign or zero-extended register.

Add the relevant test cases and negative tests.

Fixes #23501
Change-Id: Ie5850ead2ad08d9a235a5664869aac5051762f1f
Reviewed-on: https://go-review.googlesource.com/88876
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/go: only run -race test if -race works
Ian Lance Taylor [Mon, 5 Feb 2018 20:19:08 +0000 (12:19 -0800)]
cmd/go: only run -race test if -race works

Updates #23694

Change-Id: I5fdad8cceacb8bbc85ca2661eb6482aa80343656
Reviewed-on: https://go-review.googlesource.com/92075
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc/editors: remove feature matrix for various editors/IDEs
Andrew Bonventre [Mon, 5 Feb 2018 17:10:22 +0000 (12:10 -0500)]
doc/editors: remove feature matrix for various editors/IDEs

The speed of feature development for these products outpaces the
standard Go 6-month release cycle tied to this page. The cost of
maintaining this list is becoming a burden as we make every
attempt at being impartial. As of this writing, we believe feature
lists belong on the pages of the editors/IDEs themselves.

Change-Id: Ie2dfe0e0d47d203c913373e58cbb65cb0fb14d0c
Reviewed-on: https://go-review.googlesource.com/91976
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/go: ignore coverpkg match on sync/atomic in atomic coverage mode
Ian Lance Taylor [Mon, 5 Feb 2018 02:45:39 +0000 (18:45 -0800)]
cmd/go: ignore coverpkg match on sync/atomic in atomic coverage mode

Otherwise we get into a dependency loop as we try to apply coverage
analysis to sync/atomic when the coverage analysis itself requires
sync/atomic.

Fixes #23694

Change-Id: I3a74ef3881ec5c6197ed348acc7f9e175417f6c7
Reviewed-on: https://go-review.googlesource.com/91875
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agocmd/go: fix import config debugging flag
Russ Cox [Wed, 31 Jan 2018 02:16:09 +0000 (21:16 -0500)]
cmd/go: fix import config debugging flag

Was improperly bypassed in a couple places.

Change-Id: I13426b3efe68b9e67324c283540d0ef7b81b3d41
Reviewed-on: https://go-review.googlesource.com/91636
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/internal/gccgoimporter: remove old and exp gccgo packages in test
Ian Lance Taylor [Fri, 2 Feb 2018 19:11:32 +0000 (11:11 -0800)]
go/internal/gccgoimporter: remove old and exp gccgo packages in test

The old and exp packages listed in gccgoinstallation_test.go have been
removed from gccgo. Remove them from the test.

Fixes #20932

Change-Id: I04a5148e18dccef332904b836c42098b55f2516c
Reviewed-on: https://go-review.googlesource.com/91656
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agomisc/cgo/test: get uintptr, not pointer, from dlopen
Ian Lance Taylor [Fri, 2 Feb 2018 13:38:08 +0000 (05:38 -0800)]
misc/cgo/test: get uintptr, not pointer, from dlopen

The dlopen function returns an opaque handle, and it is possible for
it to look like a Go pointer, causing garbage collector and cgo
confusion.

Fixes #23663

Change-Id: Id080e2bbcee8cfa7ac4a457a927f96949eb913f8
Reviewed-on: https://go-review.googlesource.com/91596
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agospec: remove need for separate Function production (cleanup)
Robert Griesemer [Thu, 1 Feb 2018 22:08:45 +0000 (14:08 -0800)]
spec: remove need for separate Function production (cleanup)

The EBNF production

Function = Signature FunctionBody .

was used in FunctionDecl, MethodDecl, and FunctionLit, but only
for the latter it shortened the syntax slightly.

This change "inlines" Function which simplifies FunctionDecl and
MethodDecl and gets rid of the Function production.

This has no impact on the specified language. Also, the Function
production is never referred to by the prose, so it's safe to
remove it from the spec.

Finally, neither go/ast nor go/parser have a representation of
this production via a corresponding node or parse function, so
no possibly valuable documentation is lost, either.

Change-Id: Ia2875d31c6ec2d2079081ef481e50bad4f43c694
Reviewed-on: https://go-review.googlesource.com/91515
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agonet: fix the kernel state name for TCP listen queue on FreeBSD
Mikio Hara [Thu, 1 Feb 2018 19:25:44 +0000 (04:25 +0900)]
net: fix the kernel state name for TCP listen queue on FreeBSD

Fixes #23653.

Change-Id: Ic1e3c8f156ae576cfb5da1b4d082d4b12fae114f
Reviewed-on: https://go-review.googlesource.com/91317
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/go: fix TestNoCache on Plan 9
David du Colombier [Wed, 31 Jan 2018 21:56:39 +0000 (22:56 +0100)]
cmd/go: fix TestNoCache on Plan 9

CL 91097 added TestNoCache. However, this
test is failing on Plan 9 because the HOME
environment variable doesn't contain the
home directory where the Go cache is located.

This change fixes the TestNoCache test
by using the home environment variable
instead of HOME on Plan 9.

Fixes #23644.

Change-Id: Icfb7a7a4c2852f159c93032b4081411628a2787f
Reviewed-on: https://go-review.googlesource.com/91216
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: restore RSB for sigpanic call on mips64x
Austin Clements [Wed, 31 Jan 2018 19:34:36 +0000 (14:34 -0500)]
runtime: restore RSB for sigpanic call on mips64x

preparePanic must set all registers expected by Go runtime conventions
in case the sigpanic is being injected into C code. However, on
mips64x it fails to restore RSB (R28). As a result, if C code modifies
RSB and then raises a signal that turns into a sigpanic call, sigpanic
may crash when it attempts to lock runtime.debuglock (the first global
it references).

Fix this by restoring RSB in the signal context using the same
convention as main and sigtramp.

Fixes #23641.

Change-Id: Ib47e83df89e2a3eece10f480e4e91ce9e4424388
Reviewed-on: https://go-review.googlesource.com/91156
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agoruntime: suppress "unexpected return pc" any time we're in cgo
Austin Clements [Wed, 31 Jan 2018 16:55:22 +0000 (11:55 -0500)]
runtime: suppress "unexpected return pc" any time we're in cgo

Currently, gentraceback suppresses the "unexpected return pc" error
for sigpanic's caller if the M was running C code.

However, there are various situations where a sigpanic is injected
into C code that can cause traceback to unwind *past* the sigpanic
before realizing that it's in trouble (the traceback beyond the
sigpanic will be wrong).

Rather than try to fix these issues for Go 1.10, this CL simply
disables complaining about unexpected return PCs if we're in cgo
regardless of whether or not they're from the sigpanic frame. Go 1.9
never complained about unexpected return PCs when printing, so this is
simply a step closer to the old behavior.

This should fix the openbsd-386 failures on the dashboard, though this
issue could affect any architecture.

Fixes #23640.

Change-Id: I8c32c1ee86a70d2f280661ed1f8caf82549e324b
Reviewed-on: https://go-review.googlesource.com/91136
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agosyscall: use SYS_GETDENTS64 on linux/mips64{,le}
Tobias Klauser [Wed, 31 Jan 2018 12:59:00 +0000 (13:59 +0100)]
syscall: use SYS_GETDENTS64 on linux/mips64{,le}

The getdents64 syscall is only available for mips64/mips64le starting
with Linux kernel 3.10. Since mips64le requires at least 4.8 according
to [1] (regarding #16848) using it should be fine.

[1] https://golang.org/wiki/MinimumRequirements

This CL changes the binary layout of type Dirent for mips64/mips64le,
but not the public API. But since the currently used layout doesn't
match the struct linux_dirent returned by the getdents syscall this
should be fine as well.

Fixes #23624

Change-Id: Iaa7306fa6e4442ad2fed41c60b37627a7314f117
Reviewed-on: https://go-review.googlesource.com/91055
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agotest: add test for gccgo bug 23545
Cherry Zhang [Thu, 25 Jan 2018 04:44:17 +0000 (23:44 -0500)]
test: add test for gccgo bug 23545

The fix is CL 91035.

Build only with gccgo at the moment, as it hits issue #23546.

Updates #23545.

Change-Id: I3a1367bb31b04773d31f71016f8fd7bd1855d7b5
Reviewed-on: https://go-review.googlesource.com/89735
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/go: if unable to initialize cache, just disable it
Ian Lance Taylor [Wed, 31 Jan 2018 18:02:01 +0000 (10:02 -0800)]
cmd/go: if unable to initialize cache, just disable it

Fixes #23638

Change-Id: I51967290448217f371fc7aba9259918ee9857143
Reviewed-on: https://go-review.googlesource.com/91097
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoruntime: fail silently if we unwind over sigpanic into C code
Austin Clements [Tue, 30 Jan 2018 21:03:51 +0000 (16:03 -0500)]
runtime: fail silently if we unwind over sigpanic into C code

If we're running C code and the code panics, the runtime will inject a
call to sigpanic into the C code just like it would into Go code.
However, the return PC from this sigpanic will be in C code. We used
to silently abort the traceback if we didn't recognize a return PC, so
this went by quietly. Now we're much louder because in general this is
a bad thing. However, in this one particular case, it's fine, so if
we're in cgo and are looking at the return PC of sigpanic, silence the
debug output.

Fixes #23576.

Change-Id: I03d0c14d4e4d25b29b1f5804f5e9ccc4f742f876
Reviewed-on: https://go-review.googlesource.com/90896
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime: don't unwind past asmcgocall
Austin Clements [Tue, 30 Jan 2018 21:01:33 +0000 (16:01 -0500)]
runtime: don't unwind past asmcgocall

asmcgocall switches to the system stack and aligns the SP, so
gentraceback both can't unwind over it when it appears on the system
stack (it'll read some uninitialized stack slot as the return PC).
There's also no point in unwinding over it, so don't.

Updates #23576.

Change-Id: Idfcc9599c7636b80dec5451cb65ae892b4611981
Reviewed-on: https://go-review.googlesource.com/90895
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoos/signal: skip TestTerminalSignal if posix_openpt fails with EACCES
Michael Hudson-Doyle [Tue, 30 Jan 2018 21:27:49 +0000 (10:27 +1300)]
os/signal: skip TestTerminalSignal if posix_openpt fails with EACCES

This happens in a chroot and so causes failures when packaging Go 1.10 for
Debian/Ubuntu.

Change-Id: I817038c237e584ce185b2168f8c7a10b9ef27b43
Reviewed-on: https://go-review.googlesource.com/90875
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/vendor/github.com/google/pprof: cherry-pick fix to cope with $HOME not being...
Michael Hudson-Doyle [Tue, 30 Jan 2018 22:11:39 +0000 (11:11 +1300)]
cmd/vendor/github.com/google/pprof: cherry-pick fix to cope with $HOME not being writable

Upstream PRs: https://github.com/google/pprof/pull/305,
https://github.com/google/pprof/pull/306.

Change-Id: I28969118f52ee08fcaf3572ad5da015ae756fd7a
Reviewed-on: https://go-review.googlesource.com/90935
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agodoc: add GOMIPS to source installation docs
Brad Fitzpatrick [Tue, 30 Jan 2018 16:55:27 +0000 (16:55 +0000)]
doc: add GOMIPS to source installation docs

Also close </li> tags.

Fixes #23614

Change-Id: Icabcd577ef7df43e54d2b0068ee54614ba65bea1
Reviewed-on: https://go-review.googlesource.com/90815
Reviewed-by: Cherry Zhang <cherryyz@google.com>
7 years agocmd/fix: cleanup directories created during typecheck
Mohit Agarwal [Tue, 30 Jan 2018 12:58:50 +0000 (18:28 +0530)]
cmd/fix: cleanup directories created during typecheck

Executing

$ go tool dist test -run=^go_test:cmd/fix$

leaves a number of directories (fix_cgo_typecheck*) in TMPDIR.

Change-Id: Ia5bdc2f7d884333771d50365063faf514ebf6eae
Reviewed-on: https://go-review.googlesource.com/90795
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agobootstrap.bash: only fetch git revision if we need it
Ian Lance Taylor [Tue, 30 Jan 2018 04:35:43 +0000 (20:35 -0800)]
bootstrap.bash: only fetch git revision if we need it

Updates #22912
Fixes #23610

Change-Id: Id1c91fc3f040412d5931dba40e430685793f8eea
Reviewed-on: https://go-review.googlesource.com/90715
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/vet: extra args if any formats are indexed are ok
Daniel Martí [Mon, 29 Jan 2018 10:35:39 +0000 (10:35 +0000)]
cmd/vet: extra args if any formats are indexed are ok

For example, the following program is valid:

func main() {
fmt.Printf("%[1]d", 1, 2, 3)
}

If any of the formats are indexed, fmt will not complain about unused
extra arguments. See #22867 for more detail.

Make vet follow the same logic, to avoid erroring on programs that would
run without fmt complaining.

Fixes #23564.

Change-Id: Ic9dede5d4c37d1cd4fa24714216944897b5bb7cc
Reviewed-on: https://go-review.googlesource.com/90495
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/vet: %s is valid for an array of stringer
Daniel Martí [Mon, 29 Jan 2018 09:24:51 +0000 (09:24 +0000)]
cmd/vet: %s is valid for an array of stringer

vet was quiet for []stringer, but not for [N]stringer. The source of the
problem was how the recursive call used .Elem().Underlying() for arrays,
but .Elem() for slices. In the first case, the named type is dropped,
thus losing all information of attached methods.

Be consistent across slices and arrays, by dropping the Underlying call
that is causing trouble. Add regression tests too, including cases where
the element type does not implement fmt.Stringer.

Fixes #23552.

Change-Id: I0fde07d101f112d5768be0a79207ef0b3dc45f2e
Reviewed-on: https://go-review.googlesource.com/90455
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/vet: **T is not Stringer if *T has a String method
Daniel Martí [Mon, 29 Jan 2018 09:50:50 +0000 (09:50 +0000)]
cmd/vet: **T is not Stringer if *T has a String method

vet recorded what types had String methods defined on them, but it did
not record whether the receivers were pointer types. That information is
important, as the following program is valid:

type T string

func (t *T) String() string {
return fmt.Sprint(&t) // prints address
}

Teach vet that, if *T is Stringer, **T is not.

Fixes #23550.

Change-Id: I1062e60e6d82e789af9cca396546db6bfc3541e8
Reviewed-on: https://go-review.googlesource.com/90417
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agocmd/vet: disable complaint about 0 flag in print
Rob Pike [Tue, 30 Jan 2018 02:49:48 +0000 (13:49 +1100)]
cmd/vet: disable complaint about 0 flag in print

The problem is that vet complains about 0 as a Printf flag in some
situations where fmt allows it but probably shouldn't. The two
need to be brought in line, but it's too late in the release cycle.

The situation is messy and should be resolved properly in 1.11. This
CL is a simple fix to disable a spurious complaint for 1.10 that will be
resolved in a more thorough way in 1.11.

The workaround is just to be silent about flag 0, as suggested in
issue 23605.

Fixes #23605
Update #23498

Change-Id: Ice1a4f4d86845d70c1340a0a6430d74e5de9afd4
Reviewed-on: https://go-review.googlesource.com/90695
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agodoc: fix the closing tag in contribute.html
Mohit Agarwal [Mon, 29 Jan 2018 18:44:54 +0000 (00:14 +0530)]
doc: fix the closing tag in contribute.html

Change-Id: I802bc11d90d414e7313dd11842a04fd6b591ea06
Reviewed-on: https://go-review.googlesource.com/90595
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: fix two small mistakes in 1.10 release notes
Alberto Donizetti [Mon, 29 Jan 2018 10:59:53 +0000 (11:59 +0100)]
doc: fix two small mistakes in 1.10 release notes

Change-Id: If928b14f6cd89b1d78745e8bc7a081ccbd7fd38f
Reviewed-on: https://go-review.googlesource.com/90515
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agocmd/go: skip external tests on plan9/arm
David du Colombier [Sun, 28 Jan 2018 18:58:25 +0000 (19:58 +0100)]
cmd/go: skip external tests on plan9/arm

CL 13166, CL 13342 and CL 33425 skipped external tests
on freebsd/arm, linux/arm and linux/mips.

This CL does the same for plan9/arm to reduce test time
on plan9/arm and prevent the Go builder to time out.

Change-Id: I16fcc5d8010a354f480673b8c4a8a11dbc833557
Reviewed-on: https://go-review.googlesource.com/90416
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agodoc: fix spelling mistake
Kevin Burke [Thu, 25 Jan 2018 19:26:54 +0000 (11:26 -0800)]
doc: fix spelling mistake

Change-Id: I7bf1a93d3377acccdd3a34c5dcef7863310496e0
Reviewed-on: https://go-review.googlesource.com/89955
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoos: document inheritance of thread state over exec
Austin Clements [Fri, 26 Jan 2018 18:44:28 +0000 (13:44 -0500)]
os: document inheritance of thread state over exec

Fixes #23570.

Change-Id: I462ada2960d710c2c94dc22a59d292703d83f612
Reviewed-on: https://go-review.googlesource.com/90255
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agocmd/compile: don't inline functions that call recover
Austin Clements [Thu, 25 Jan 2018 22:22:41 +0000 (17:22 -0500)]
cmd/compile: don't inline functions that call recover

recover determines whether it's being called by a deferred frame by
matching its caller's argument frame pointer with the one recorded in
the panic object. That means its caller needs a valid and unique
argument frame pointer, so it must not be inlined.

With this fix, test/recover.go passes with -l=4.

Fixes #23557.

Change-Id: I1f32a624c49e387cfc67893a0829bb248d69c3d4
Reviewed-on: https://go-review.googlesource.com/90035
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agodatabase/sql: buffers provided to Rows.Next should not be modified by drivers
Daniel Theophanes [Thu, 25 Jan 2018 18:50:02 +0000 (10:50 -0800)]
database/sql: buffers provided to Rows.Next should not be modified by drivers

Previously we allowed drivers to modify the row buffer used to scan
values when closing Rows. This is no longer acceptable and can lead
to data races.

Fixes #23519

Change-Id: I91820a6266ffe52f95f40bb47307d375727715af
Reviewed-on: https://go-review.googlesource.com/89936
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agodoc: remove Sarah Adams from conduct working group contacts
Sarah Adams [Wed, 24 Jan 2018 23:07:15 +0000 (15:07 -0800)]
doc: remove Sarah Adams from conduct working group contacts

Change-Id: Id2332332ba5ff5a3ae6e58882743aa25359c02f6
Reviewed-on: https://go-review.googlesource.com/89675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years ago[release-branch.go1.10] go1.10rc1 go1.10rc1
Andrew Bonventre [Thu, 25 Jan 2018 16:22:38 +0000 (11:22 -0500)]
[release-branch.go1.10] go1.10rc1

Change-Id: I49ec1e476e02d403a4b46f55ea48a9c3cee54efa
Reviewed-on: https://go-review.googlesource.com/89855
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Broadfoot <cbro@golang.org>
7 years agodatabase/sql: fix TestConversions when count > 1
Daniel Theophanes [Wed, 24 Jan 2018 20:27:59 +0000 (12:27 -0800)]
database/sql: fix TestConversions when count > 1

Provide a fresh conversion table for TestConversions as it gets
modified on each test.

Change-Id: I6e2240d0c3455451271a6879e994b82222c3d44c
Reviewed-on: https://go-review.googlesource.com/89595
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
7 years agoos: use the syscall version of Getwd for Plan 9
Richard Miller [Wed, 24 Jan 2018 16:17:05 +0000 (16:17 +0000)]
os: use the syscall version of Getwd for Plan 9

In Plan 9, each OS thread has its own independent working directory,
so the Go runtime for Plan 9 needs to coordinate Chdir and Getwd
operations to keep the working directory consistent for all goroutines.

The function os.Getwd in Plan 9 should always call syscall.Getwd
to retrieve the common working directory.  Failure to do this was
the cause of (at least some of) the intermittent failures in the
Plan 9 builders with a seemingly spurious "file does not exist"
message, when a thread's working directory had been removed in
another thread.

Change-Id: Ifb834ad025ee39578234ad3b04d08bc98e939291
Reviewed-on: https://go-review.googlesource.com/89575
Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

7 years agocmd/go: fix -coverpkg=all with dot imports
Russ Cox [Tue, 23 Jan 2018 01:07:58 +0000 (20:07 -0500)]
cmd/go: fix -coverpkg=all with dot imports

If you use -coverpkg=all you get coverage for all packages in the build.
Go 1.9 used a global counter for all the GoCover variables, so that they
were distinct for the entire build. The global counter caused problems
with caching, so we switched to a per-package counter. But now the
GoCover_0 in one package may be dot-imported into another and
conflict with the GoCover_0 in that other package.

Reestablish (overwhelmingly likely) global uniqueness of GoCover
variables by appending an _xxxxxxxxxxxx suffix, where the x's are
the prefix of the SHA256 hash of the import path. The point is only
to avoid accidents, not to defeat people determined to break the tools.

Fixes #23432.

Change-Id: I3088eceebbe35174f2eefe8d558b7c8b59d3eeac
Reviewed-on: https://go-review.googlesource.com/89135
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agogo/types: fix spelling mistake in comment
Kevin Burke [Wed, 24 Jan 2018 06:19:34 +0000 (22:19 -0800)]
go/types: fix spelling mistake in comment

Change-Id: If8609dd7c4bdc261056804759ec254f8af0156df
Reviewed-on: https://go-review.googlesource.com/89417
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 years agoruntime/pprof: scale mutex profile with sampling rate
Hana Kim [Tue, 23 Jan 2018 20:02:45 +0000 (15:02 -0500)]
runtime/pprof: scale mutex profile with sampling rate

pprof expects the samples are scaled and reflects unsampled numbers.
The legacy profile parser uses the sampling period in the output
and multiplies all values with the period.

https://github.com/google/pprof/blob/0138a3cd6dad6f94495ba0b5c3a5c124f04ae011/profile/legacy_profile.go#L815

Apply the same scaling when we output the mutex profile
in the pprof proto format.

Block profile shares the same code, but how to infer unsampled
values is unclear. Legacy profile parser doesn't do anything special
so we do nothing for block profile here.

Tested by checking the profiles reported with debug=0 (proto format)
are similar to the profiles computed from legacy format profile
when the profile rate is a non-trivial number (e.g. 2) manually.

Change-Id: Iaa33f92051deed67d8be43ddffc7c1016db566ca
Reviewed-on: https://go-review.googlesource.com/89295
Reviewed-by: Peter Weinberger <pjw@google.com>
7 years agoos: homogenize error checks on Plan 9
David du Colombier [Tue, 23 Jan 2018 20:58:33 +0000 (21:58 +0100)]
os: homogenize error checks on Plan 9

Remove leading space at the beginning of error strings,
so the strings are consistent between isExist, isNotExist
and isPermission functions.

Here is a list of error strings returned on the most common
file servers on Plan 9:

     match                     cwfs                      fossil                   ramfs

"exists"            "create/wstat -- file exists"  "file already exists"    "file exists"
"is a directory"                                   "is a directory"         "file is a directory"

"does not exist"                                   "file does not exist"    "file does not exist"
"not found"         "directory entry not found"
"has been removed"                                 "file has been removed"

"permission denied" "access permission denied"     "permission denied"      "permission denied"

"no parent" is an error returned by lib9p when removing a file without parent.

Change-Id: I2362ed4b6730b8bec7a707a1052bd1ad8921cd97
Reviewed-on: https://go-review.googlesource.com/89315
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
7 years agolib/time: follow redirects in curl
Kyle Shannon [Wed, 24 Jan 2018 00:54:57 +0000 (17:54 -0700)]
lib/time: follow redirects in curl

Starting on or about the 2018c archives, www.iana.org is redirected to
data.iana.org.  Tell curl to follow the redirect.

Updates: #22487

Change-Id: I00acada1a3ba01ef701d6d4ffae6cc2cbb6a068f
Reviewed-on: https://go-review.googlesource.com/89375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
7 years agocmd/compile: don't let spills clobber arguments
Keith Randall [Tue, 23 Jan 2018 21:06:21 +0000 (13:06 -0800)]
cmd/compile: don't let spills clobber arguments

The compiler allows code to have multiple differently-typed views of a
single argument. For instance, if we have

func f(x float64) {
   y := *(*int64)(unsafe.Pointer(&x))
   ...
}

Then in SSA we get two OpArg ops, one with float64 type and one with
int64 type.

The compiler will try to reuse argument slots for spill slots. It
checks that the argument slot is dead by consulting an interference
graph.

When building the interference graph, we normally ignore cross-type
edges because the values on either end of that edge can't be allocated
to the same slot. (This is just a space-saving optimization.) This
rule breaks down when one of the values is an argument, because of the
multiple views described above. If we're spilling a float64, it is not
enough that the float64 version of x is dead; the int64 version of x
has to be dead also.

Remove the optimization of not recording interference edges if types
don't match. That optimization is incorrect if one of the values
connected by the edge is an argument.

Fixes #23522

Change-Id: I361f85d80fe3bc7249014ca2c3ec887c3dc30271
Reviewed-on: https://go-review.googlesource.com/89335
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>