]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 years agohtml/template: add DefinedTemplates to html/template
Rob Pike [Mon, 23 Nov 2015 20:43:17 +0000 (12:43 -0800)]
html/template: add DefinedTemplates to html/template

It is not important to add, since it's only used for creating an error message,
but for consistency in the API between text/template and html/template
it should be provided here.

The implementation just calls the one in text/template.

Fixes #13349.

Change-Id: I0882849e06a58f1e38b00eb89d79ac39777309b2
Reviewed-on: https://go-review.googlesource.com/17172
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/compile: simplify parsing of possibly absent type
Robert Griesemer [Sat, 21 Nov 2015 01:31:33 +0000 (17:31 -0800)]
cmd/compile: simplify parsing of possibly absent type

Introduce a try_ntype function which doesn't return an error upon
not finding a type. Use it instead of having separate repeated
token checks. Simpler, less code, and more efficient.

Change-Id: I81e482158b71901eb179470269349688636aa0ba
Reviewed-on: https://go-review.googlesource.com/17157
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agodoc: update 1.6.txt for fmt.Scanf change
Rob Pike [Mon, 23 Nov 2015 21:12:36 +0000 (13:12 -0800)]
doc: update 1.6.txt for fmt.Scanf change

Change-Id: Icdce5cdb8676c3bcb73bd943b406000252509521
Reviewed-on: https://go-review.googlesource.com/17174
Reviewed-by: Rob Pike <r@golang.org>
9 years agofmt: check newline in the end of input
Nodir Turakulov [Wed, 21 Oct 2015 18:09:00 +0000 (11:09 -0700)]
fmt: check newline in the end of input

Sscanf doc says:
Newlines in the input must match newlines in the format.

However Sscanf didn't check newline in the end of input (EOF).
A test for the case is broken.

* check newline in EOF
* fix the test
* slightly simplify ss.doScanf

Fixes #12788

Change-Id: Iaf6b7d81324a72e557543ac22ecea5cecb72e0d6
Reviewed-on: https://go-review.googlesource.com/16165
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime: clean up gcMarkDone
Austin Clements [Mon, 23 Nov 2015 16:37:12 +0000 (11:37 -0500)]
runtime: clean up gcMarkDone

This improves the documentation comment on gcMarkDone, replaces a
recursive call with a simple goto, and disables preemption before
stopping the world in accordance with the documentation comment on
stopTheWorldWithSema.

Updates #13363, but, sadly, doesn't fix it.

Change-Id: I6cb2a5836b35685bf82f7b1ce7e48a7625906656
Reviewed-on: https://go-review.googlesource.com/17149
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoruntime: improve stack barrier debugging
Austin Clements [Mon, 23 Nov 2015 16:29:56 +0000 (11:29 -0500)]
runtime: improve stack barrier debugging

This improves stack barrier debugging messages in various ways:

1) Rather than printing only the remaining stack barriers (of which
   there may be none, which isn't very useful), print all of the G's
   stack barriers with a marker at the position the stack itself has
   unwound to and a marker at the problematic stack barrier (where
   applicable).

2) Rather than crashing if we encounter a stack barrier when there are
   no more stkbar entries, print the same debug message we would if we
   had encountered a stack barrier at an unexpected location.

Hopefully this will help with debugging #12528.

Change-Id: I2e6fe6a778e0d36dd8ef30afd4c33d5d94731262
Reviewed-on: https://go-review.googlesource.com/17147
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: make stack barrier locking more robust
Austin Clements [Thu, 19 Nov 2015 18:26:43 +0000 (13:26 -0500)]
runtime: make stack barrier locking more robust

The stack barrier locking functions use a simple cas lock because they
need to support trylock, but currently don't increment g.m.locks. This
is okay right now because they always run on the system stack or the
signal stack and are hence non-preemtible, but this could lead to
difficult-to-reproduce deadlocks if these conditions change in the
future.

Make these functions more robust by incrementing g.m.locks and making
them nosplit to enforce non-preemtibility.

Change-Id: I73d60a35bd2ad2d81c73aeb20dbd37665730eb1b
Reviewed-on: https://go-review.googlesource.com/17058
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/cgo: ignore vars with no name or type if they have a AttrSpecification
Ian Lance Taylor [Fri, 20 Nov 2015 21:53:18 +0000 (13:53 -0800)]
cmd/cgo: ignore vars with no name or type if they have a AttrSpecification

Fixes #13344.

Change-Id: I33c6721fd33d144c85c87840ddf27ce15aa72328
Reviewed-on: https://go-review.googlesource.com/17151
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/go: disable TestNoteReading on dragonfly
Russ Cox [Mon, 23 Nov 2015 02:14:52 +0000 (21:14 -0500)]
cmd/go: disable TestNoteReading on dragonfly

It started failing on the dragonfly builder at an unrelated commit
(one that changed the wording in a few comments in the compiler).

Created #13364 to track this.

Change-Id: I462880bed8ff565a9950e7e185de97d43999c5e2
Reviewed-on: https://go-review.googlesource.com/17143
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agohtml/template: Add missing error check to package example.
Dmitri Shuralyov [Sun, 22 Nov 2015 01:09:08 +0000 (17:09 -0800)]
html/template: Add missing error check to package example.

This appears to be an unintended omission. The check func is declared
just above, and the err value from template.Parse is captured rather
than discarded via blank identifier. All following calls that similarly
return err are checked, so it can't be that this example elides error
checking for brevity. Finally, if you look at Example_autoescaping,
it does check err from template.Parse and its code is very similar.

Change-Id: I076e1846302d5f2cdb1d027ed85ca0db85e33ace
Reviewed-on: https://go-review.googlesource.com/17170
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agomisc/cgo/testshared: add format specifier in Errorf calls
Mohit Agarwal [Sat, 21 Nov 2015 09:54:34 +0000 (15:24 +0530)]
misc/cgo/testshared: add format specifier in Errorf calls

Found by cmd/vet

Change-Id: I29dd207ecd40fe703054e8ad4e81b3267ca89da2
Reviewed-on: https://go-review.googlesource.com/17160
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/compile: address several more 1.6 TODOs in parser
Robert Griesemer [Sat, 21 Nov 2015 00:49:30 +0000 (16:49 -0800)]
cmd/compile: address several more 1.6 TODOs in parser

- fix/check location of popdcl calls where questioned
- remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached)
- inlined and fnret_type and simplified fnres as a consequence
- leave handling of ... (LDDD) in arg_list alone (remove TODO)
- verify that parser requires a ';' after last statement in a case/default
  (added test case)

Fixes #13243.

Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d
Reviewed-on: https://go-review.googlesource.com/17155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile: simplify tracing code (cleanup)
Robert Griesemer [Fri, 20 Nov 2015 18:16:34 +0000 (10:16 -0800)]
cmd/compile: simplify tracing code (cleanup)

Change-Id: I7c084542996226f3ed464314a5622fcfaac02d61
Reviewed-on: https://go-review.googlesource.com/17103
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agonet: move TestLookupPort into lookup_test.go
Mikio Hara [Sun, 1 Nov 2015 05:29:45 +0000 (14:29 +0900)]
net: move TestLookupPort into lookup_test.go

No code changes.

Change-Id: Ibbba7c86007d74b853fb59aa742f87783bd69503
Reviewed-on: https://go-review.googlesource.com/16541
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agonet: don't run multicast listen test on nil interface in short mode
Ian Lance Taylor [Sat, 21 Nov 2015 00:01:45 +0000 (16:01 -0800)]
net: don't run multicast listen test on nil interface in short mode

The gccgo bug report https://gcc.gnu.org/PR65785 points out that the
multicast listen tests will use the network even with -test.short.
Fix test by checking testing.Short with a nil interface.

Change-Id: I7eab8df34fe3b78fc376912312fac9d0f94977f1
Reviewed-on: https://go-review.googlesource.com/17154
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
9 years agofmt: give correct error for % at end of string when scanning
Rob Pike [Fri, 20 Nov 2015 21:17:32 +0000 (13:17 -0800)]
fmt: give correct error for % at end of string when scanning

Previously it said, "bad verb %% for ...", which is not only wrong,
it's ironic as the fix is to use %% rather than % at the end of the
string. Diagnose the case where a simple % is at EOF.

If there's anything after the percent, the error is already good
but this CL also puts quotes around the verb designation ('%d' etc.)
to make it even clearer, especially when there is a space involved.

Fixes #12315.

Change-Id: I31d30659965e940d0bd9ce92a475aab3e2369ef0
Reviewed-on: https://go-review.googlesource.com/17150
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile: fix TODO in tracing code
Robert Griesemer [Fri, 20 Nov 2015 17:58:22 +0000 (09:58 -0800)]
cmd/compile: fix TODO in tracing code

For #13243.

Change-Id: I214945278255a49f93120f9407f536a6c01a29fb
Reviewed-on: https://go-review.googlesource.com/17101
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile: better syntax error recovery
Robert Griesemer [Fri, 20 Nov 2015 00:11:09 +0000 (16:11 -0800)]
cmd/compile: better syntax error recovery

Use a combination of follow- and stop-token lists and nesting levels
to better synchronize parser after a syntax error.

Fixes #13319.

Change-Id: I9592e0b5b3ba782fb9f9315fea16163328e204f7
Reviewed-on: https://go-review.googlesource.com/17080
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile: match markdcl and popdcl even in case of errors
Robert Griesemer [Thu, 19 Nov 2015 23:43:05 +0000 (15:43 -0800)]
cmd/compile: match markdcl and popdcl even in case of errors

Change-Id: I22a8a233bc157fa09cd0283fcd4bc14d90faed70
Reviewed-on: https://go-review.googlesource.com/17066
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile: no need to keep ()'s for all pseudocalls
Robert Griesemer [Thu, 19 Nov 2015 21:54:40 +0000 (13:54 -0800)]
cmd/compile: no need to keep ()'s for all pseudocalls

Minor internal optimization.

Change-Id: I229d4a9df3da542b77f830c2830f63ec23ec1d61
Reviewed-on: https://go-review.googlesource.com/17065
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile: print regular error message in BOM corner-case
Robert Griesemer [Thu, 19 Nov 2015 01:50:21 +0000 (17:50 -0800)]
cmd/compile: print regular error message in BOM corner-case

This never happens but for pathological input where a BOM sequence
is unfinished and ends in EOF (src: "package p\n\nfunc \xef\xef").
No test case added because the /test framework doesn't lend itself
easily to it in this case (file must end in EOF rather than comment).
Instead, tested manually.

Fixes #13268.

Change-Id: I049034e6dde7ad884b0a8c329921adac1866ff18
Reviewed-on: https://go-review.googlesource.com/17047
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agodoc: add FAQ entry about covariant result types
Ian Lance Taylor [Fri, 20 Nov 2015 15:00:09 +0000 (07:00 -0800)]
doc: add FAQ entry about covariant result types

Change-Id: If22b8f358e78deca31bd0b1a25e7966987853405
Reviewed-on: https://go-review.googlesource.com/17083
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime/pprof: disable TestStackBarrierProfiling on ppc64
Austin Clements [Fri, 20 Nov 2015 19:12:04 +0000 (14:12 -0500)]
runtime/pprof: disable TestStackBarrierProfiling on ppc64

This test depends on GODEBUG=gcstackbarrierall, which doesn't work on
ppc64.

Updates #13334.

Change-Id: Ie554117b783c4e999387f97dd660484488499d85
Reviewed-on: https://go-review.googlesource.com/17120
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: fix new stack barrier check
Russ Cox [Fri, 20 Nov 2015 19:02:33 +0000 (14:02 -0500)]
runtime: fix new stack barrier check

During a crash showing goroutine stacks of all threads
(with GOTRACEBACK=crash), it can be that f == nil.

Only happens on Solaris; not sure why.

Change-Id: Iee2c394a0cf19fa0a24f6befbc70776b9e42d25a
Reviewed-on: https://go-review.googlesource.com/17110
Reviewed-by: Austin Clements <austin@google.com>
9 years agoruntime/pprof: check if test can fork
David Crawshaw [Fri, 20 Nov 2015 17:03:07 +0000 (12:03 -0500)]
runtime/pprof: check if test can fork

(TestStackBarrierProfiling is failing on darwin/arm.)

Change-Id: I8006d6222ccafc213821e02105896440079caa37
Reviewed-on: https://go-review.googlesource.com/17091
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoos: use different test files on android
David Crawshaw [Fri, 20 Nov 2015 15:42:05 +0000 (10:42 -0500)]
os: use different test files on android

Some Android OS installations have very strange permissions on their
/system/etc directory, meaning that Readdir fails. Instead use
/system/framework, which is far more regular.

Change-Id: Iefc140614183cda0f875e0f6ef859f4d4eaad9da
Reviewed-on: https://go-review.googlesource.com/17078
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd: allow buildmode=c-shared for android/386
Hyang-Ah Hana Kim [Fri, 6 Nov 2015 22:28:58 +0000 (17:28 -0500)]
cmd: allow buildmode=c-shared for android/386

Update golang/go#9327.

Change-Id: Iab7dad31cf6b9f9347c3f34faebb67ecb38b17fc
Reviewed-on: https://go-review.googlesource.com/16701
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agotest: add another test that gccgo failed to compile
Ian Lance Taylor [Fri, 20 Nov 2015 06:07:53 +0000 (22:07 -0800)]
test: add another test that gccgo failed to compile

Change-Id: Ife9e019063473bb0a976cfef4b6e78d951fcb09e
Reviewed-on: https://go-review.googlesource.com/17081
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agoruntime: make it possible to call syscall on solaris without g
Shenghou Ma [Fri, 20 Nov 2015 05:23:52 +0000 (00:23 -0500)]
runtime: make it possible to call syscall on solaris without g

The nosplit stack is now much bigger, so we can afford to allocate
libcall on stack.

Fix asmsysvicall6 to not update errno if g == nil.

These two fixes TestCgoCallbackGC on solaris, which used to stuck
in a loop.

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

9 years agohash/crc32: rename iEEETable to ieeeTable
Joe Tsai [Fri, 20 Nov 2015 01:36:59 +0000 (17:36 -0800)]
hash/crc32: rename iEEETable to ieeeTable

iEEETable violates the Go naming conventions and is inconsistent
with the rest of the package. Use ieeeTable instead.

Change-Id: I04b201aa39759d159de2b0295f43da80488c2263
Reviewed-on: https://go-review.googlesource.com/17068
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

9 years agocmd/dist: run testcshared test on linux/386
Hyang-Ah Hana Kim [Thu, 19 Nov 2015 23:36:41 +0000 (18:36 -0500)]
cmd/dist: run testcshared test on linux/386

Change-Id: Iaa0fb133e5fc2078bfaf59ed721fd07a1a713ab3
Reviewed-on: https://go-review.googlesource.com/17075
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/go, cmd/link: enable -buildmode=c-shared on linux/386
Hyang-Ah Hana Kim [Thu, 19 Nov 2015 23:18:03 +0000 (18:18 -0500)]
cmd/go, cmd/link: enable -buildmode=c-shared on linux/386

All the heavy lifting was done by Michael Hudson-Doyle.

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

9 years agoruntime: make asmcgocall work without a g
Russ Cox [Thu, 19 Nov 2015 20:51:39 +0000 (15:51 -0500)]
runtime: make asmcgocall work without a g

Solaris needs to make system calls without a g,
and Solaris uses asmcgocall to make system calls.
I know, I know.

I hope this makes CL 16915, fixing #12277, work on Solaris.

Change-Id: If988dfd37f418b302da9c7096f598e5113ecea87
Reviewed-on: https://go-review.googlesource.com/17072
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Run-TryBot: Russ Cox <rsc@golang.org>

9 years agocmd/go: make it clearer that go generate accepts all build flags
Rob Pike [Thu, 19 Nov 2015 20:33:32 +0000 (12:33 -0800)]
cmd/go: make it clearer that go generate accepts all build flags

Just add one word to clarify that -n -v -x are not the only build flags supported.

Fixes #13237.

Change-Id: I880472639bf2fc1a0751a83041bc7ddd0c9e55f4
Reviewed-on: https://go-review.googlesource.com/17062
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/cgo: final docs for pointer passing
Ian Lance Taylor [Thu, 19 Nov 2015 22:41:08 +0000 (14:41 -0800)]
cmd/cgo: final docs for pointer passing

Update #12416.

Change-Id: I39eb0d1090c08ef9be9dc38d27abab62672cf664
Reviewed-on: https://go-review.googlesource.com/17064
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/cgo: put the real C function in the dynamic symbol table
Ian Lance Taylor [Thu, 19 Nov 2015 18:23:20 +0000 (10:23 -0800)]
cmd/cgo: put the real C function in the dynamic symbol table

In the past, cgo generated Go code and C code.  The C code was linked
into a shared library.  The Go code was built into an executable that
dynamically linked against that shared library.  C wrappers were
exported from the shared library, and the Go code called them.

It was all a long time ago, but in order to permit C code to call back
into Go, somebody implemented #pragma dynexport (https://golang.org/cl/661043)
to export a Go symbol into the dynamic symbol table.  Then that same
person added code to cgo to recognize //export comments
(https://golang.org/cl/853042).  The //export comments were implemented
by generating C code, to be compiled by GCC, that would refer to C code,
to be compiled by 6c, that would call the Go code.  The GCC code would
go into a shared library.  The code compiled by 6c would be in the Go
executable.  The GCC code needed to refer to the 6c code, so the 6c
function was marked with #pragma dynexport.  The important point here is
that #pragma dynexport was used to expose an internal detail of the
implementation of an exported function, because at the time it was
necessary.

Moving forward to today, cgo no longer generates a shared library and 6c
no longer exists.  It's still true that we have a function compiled by
GCC that refers to a wrapper function now written in Go.  In the normal
case today we are doing an external link, and we use a
//go:cgo_export_static function to make the Go wrapper function visible
to the C code under a known name.

The #pragma dynexport statement has become a //go:cgo_export_dynamic
comment on the Go code.  That comment only takes effect when doing
internal linking.  The comment tells the linker to put the symbol in the
dynamic symbol table.  That still makes sense for the now unusual case
of using internal linking with a shared library.

However, all the changes to this code have carefully preserved the
property that the //go:cgo_export_dynamic comment refers to an internal
detail of the implementation of an exported function.  That was
necessary a long time ago, but no longer makes sense.

This CL changes the code to put the actual C-callable function into the
dynamic symbol table.  I considered dropping the comment entirely, but
it turns out that there is even a test for this, so I preserved it.

Change-Id: I66a7958e366e5974363099bfaa6ba862ca327849
Reviewed-on: https://go-review.googlesource.com/17061
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/compile: set log prefix and suppress date
Shenghou Ma [Thu, 19 Nov 2015 04:39:53 +0000 (23:39 -0500)]
cmd/compile: set log prefix and suppress date

Fixes #13320.

Change-Id: I3a96a6707982629caf89656c479d096891783328
Reviewed-on: https://go-review.googlesource.com/17050
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoreflect: mark mapassign as noescape
Keith Randall [Wed, 18 Nov 2015 19:13:19 +0000 (11:13 -0800)]
reflect: mark mapassign as noescape

The lack of this annotation causes Value.SetMapIndex to allocate
when it doesn't need to.

Add comments about why it's safe to do so.

Add a test to make sure we stay allocation-free.

Change-Id: I00826e0d73e317a31bdeae5c7e46bf95b0c6ae6a
Reviewed-on: https://go-review.googlesource.com/17060
Reviewed-by: David Chase <drchase@google.com>
9 years agocmd/go: skip TestNoteReading2K on Windows
Russ Cox [Thu, 19 Nov 2015 21:20:41 +0000 (16:20 -0500)]
cmd/go: skip TestNoteReading2K on Windows

It's intended primarily as a torture test for OS X.
Apparently Windows can't take it.

Updates fix for #12327.

Change-Id: If2af249ea8e2f55bff8f232dce06172e6fef9f49
Reviewed-on: https://go-review.googlesource.com/17073
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: recursively disallow write barriers in sysmon
Austin Clements [Tue, 17 Nov 2015 22:31:04 +0000 (17:31 -0500)]
runtime: recursively disallow write barriers in sysmon

sysmon runs without a P. This means it can't interact with the garbage
collector, so write barriers not allowed in anything that sysmon does.

Fixes #10600.

Change-Id: I9de1283900dadee4f72e2ebfc8787123e382ae88
Reviewed-on: https://go-review.googlesource.com/17006
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agocmd/compile: special case nowritebarrierrec for allocm
Austin Clements [Tue, 17 Nov 2015 22:28:35 +0000 (17:28 -0500)]
cmd/compile: special case nowritebarrierrec for allocm

allocm is a very unusual function: it is specifically designed to
allocate in contexts where m.p is nil by temporarily taking over a P.
Since allocm is used in many contexts where it would make sense to use
nowritebarrierrec, this commit teaches the nowritebarrierrec analysis
to stop at allocm.

Updates #10600.

Change-Id: I8499629461d4fe25712d861720dfe438df7ada9b
Reviewed-on: https://go-review.googlesource.com/17005
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agoruntime: eliminate write barriers from mem_plan9.go
Austin Clements [Wed, 18 Nov 2015 15:28:59 +0000 (10:28 -0500)]
runtime: eliminate write barriers from mem_plan9.go

This replaces *memHdr with memHdrPtr.

Updates #10600.

Change-Id: I673aa2cd20f29abec8ab91ed7e783718c8479ce1
Reviewed-on: https://go-review.googlesource.com/17009
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
9 years agoruntime: eliminate traceAllocBlock write barriers
Austin Clements [Tue, 17 Nov 2015 22:27:11 +0000 (17:27 -0500)]
runtime: eliminate traceAllocBlock write barriers

This replaces *traceAllocBlock with traceAllocBlockPtr.

Updates #10600.

Change-Id: I94a20d90f04cca7c457b29062427748e315e4857
Reviewed-on: https://go-review.googlesource.com/17004
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agoruntime: eliminate write barriers from gentraceback
Austin Clements [Tue, 17 Nov 2015 22:14:32 +0000 (17:14 -0500)]
runtime: eliminate write barriers from gentraceback

gentraceback is used in many contexts where write barriers are
disallowed. This currently works because the only write barrier is in
assigning frame.argmap in setArgInfo and in practice frame is always
on the stack, so this write barrier is a no-op.

However, we can easily eliminate this write barrier, which will let us
statically disallow write barriers (using go:nowritebarrierrec
annotations) in many more situations. As a bonus, this makes the code
a little more idiomatic.

Updates #10600.

Change-Id: I45ba5cece83697ff79f8537ee6e43eadf1c18c6d
Reviewed-on: https://go-review.googlesource.com/17003
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
9 years agocmd/go: fix loading of buildid on OS X executables
Russ Cox [Wed, 18 Nov 2015 20:38:26 +0000 (15:38 -0500)]
cmd/go: fix loading of buildid on OS X executables

This is a bit of a belt-and-suspenders fix.
On OS X, we now parse the Mach-O file to find the __text section,
which is arguably the more proper fix. But it's a bit worrisome to
depend on a name like __text not changing, so we also read more
of the initial file (now 32 kB, up from 8 kB) and scan that too.

Fixes #12327.

Change-Id: I3a201a3dc278d24707109bb3961c3bdd8b8a0b7b
Reviewed-on: https://go-review.googlesource.com/17038
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/dist: rewrite mkdeps.bash to work on OS X
Russ Cox [Thu, 19 Nov 2015 19:43:27 +0000 (14:43 -0500)]
cmd/dist: rewrite mkdeps.bash to work on OS X

My version of bash doesn't know what 'declare -A' means.

Change-Id: Icf6b0e60ebaea3feaa8661ec0423012f213b53e8
Reviewed-on: https://go-review.googlesource.com/17070
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/asm: add doc.go
Rob Pike [Tue, 17 Nov 2015 21:23:25 +0000 (13:23 -0800)]
cmd/asm: add doc.go

There was no documentation produced by "go doc cmd/asm".
Follow the style set by cmd/compile.

Fixes #13148.

Change-Id: I02e08ce2e7471f855bfafbbecee98ffdb7096995
Reviewed-on: https://go-review.googlesource.com/16997
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/compile: fix crash with -race on large expr containing string->[]byte conversion
Russ Cox [Wed, 18 Nov 2015 19:37:12 +0000 (14:37 -0500)]
cmd/compile: fix crash with -race on large expr containing string->[]byte conversion

The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile: identify the runtime pkg using myimportpath
Michael Matloob [Thu, 19 Nov 2015 19:09:33 +0000 (14:09 -0500)]
cmd/compile: identify the runtime pkg using myimportpath

Because there are now multiple packages that compose the runtime
we need to distinguish between the case where a runtime package
is being compiled versus the case the "runtime" package is being
compiled. In golang.org/cl/14204 I mistakenly used
  localpkg.Name == "runtime"
to check against the "runtime" package, but doing this would treat
a package with the path "foo.org/bar/runtime" as the runtime package.
The correct check is
  myimportpath == "runtime"
.

Change-Id: If90e95cef768d91206f2df1c06e27be876722e4e
Reviewed-on: https://go-review.googlesource.com/17059
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agocmd/cgo, runtime: exported Go functions can't return a Go pointer
Ian Lance Taylor [Thu, 19 Nov 2015 05:25:44 +0000 (21:25 -0800)]
cmd/cgo, runtime: exported Go functions can't return a Go pointer

Update #12416.

Change-Id: Iccbcb12709d1ca9bea87274f44f93cfcebadb070
Reviewed-on: https://go-review.googlesource.com/17048
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/internal/obj/x86: still use (fake) local exec TLS mode on android/386
Michael Hudson-Doyle [Thu, 19 Nov 2015 09:14:13 +0000 (22:14 +1300)]
cmd/internal/obj/x86: still use (fake) local exec TLS mode on android/386

golang.org/cl/16383 broke android/386 because by a sort of confluence of hacks
no TLS relocations were emitted at all when Flag_shared != 0. The hack in
runtime/cgo works as well in a PIE executable as it does with a position
dependent one, so the simplest fix is to still emit a R_TLS_LE reloc when goos
== "android".

A real fix is to use something more like the IE model code but loading the
offset from %gs to the thread local storage from a global variable rather than
from a location chosen by the system linker (this is how android/arm works).

Issue #9327.

Change-Id: I9fbfc890ec7fe191f80a595b6cf8e2a1fcbe3034
Reviewed-on: https://go-review.googlesource.com/17049
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
9 years agoruntime/pprof: test that stack barriers never appear in profile
Austin Clements [Wed, 18 Nov 2015 19:59:09 +0000 (14:59 -0500)]
runtime/pprof: test that stack barriers never appear in profile

This adds a test that runs CPU profiling with a high load of stack
barriers and stack barrier insertion/removal operations and checks
that both 1) the runtime doesn't crash and 2) stackBarrier itself
never appears in a profile. Prior to the fix for gentraceback starting
in the middle of stackBarrier, condition 2 often failed.

Change-Id: Ic28860448859029779844c4bf3bb28ca84611e2c
Reviewed-on: https://go-review.googlesource.com/17037
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoruntime: prevent sigprof during all stack barrier ops
Austin Clements [Wed, 18 Nov 2015 19:10:40 +0000 (14:10 -0500)]
runtime: prevent sigprof during all stack barrier ops

A sigprof during stack barrier insertion or removal can crash if it
detects an inconsistency between the stkbar array and the stack
itself. Currently we protect against this when scanning another G's
stack using stackLock, but we don't protect against it when unwinding
stack barriers for a recover or a memmove to the stack.

This commit cleans up and improves the stack locking code. It
abstracts out the lock and unlock operations. It uses the lock
consistently everywhere we perform stack operations, and pushes the
lock/unlock down closer to where the stack barrier operations happen
to make it more obvious what it's protecting. Finally, it modifies
sigprof so that instead of spinning until it acquires the lock, it
simply doesn't perform a traceback if it can't acquire it. This is
necessary to prevent self-deadlock.

Updates #11863, which introduced stackLock to fix some of these
issues, but didn't go far enough.

Updates #12528.

Change-Id: I9d1fa88ae3744d31ba91500c96c6988ce1a3a349
Reviewed-on: https://go-review.googlesource.com/17036
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoruntime: handle sigprof in stackBarrier
Austin Clements [Wed, 18 Nov 2015 18:20:35 +0000 (13:20 -0500)]
runtime: handle sigprof in stackBarrier

Currently, if a profiling signal happens in the middle of
stackBarrier, gentraceback may see inconsistencies between stkbar and
the barriers on the stack and it will certainly get the wrong return
PC for stackBarrier. In most cases, the return PC won't be a PC at all
and this will immediately abort the traceback (which is considered
okay for a sigprof), but if it happens to be a valid PC this may sent
gentraceback down a rabbit hole.

Fix this by detecting when the gentraceback starts in stackBarrier and
simulating the completion of the barrier to get the correct initial
frame.

Change-Id: Ib11f705ac9194925f63fe5dfbfc84013a38333e6
Reviewed-on: https://go-review.googlesource.com/17035
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: start of making all relevant tests test both http1 and http2
Brad Fitzpatrick [Wed, 18 Nov 2015 23:36:51 +0000 (15:36 -0800)]
net/http: start of making all relevant tests test both http1 and http2

This CL adds skipped failing tests, showing differences between HTTP/1
and HTTP/2 behavior. They'll be fixed in later commits.

Only a tiny fraction of the net/http tests have been split into their
"_h1" and "_h2" variants. That will also continue. (help welcome)

Updates #6891
Updates #13315
Updates #13316
Updates #13317

Change-Id: I16c3c381dbe267a3098fb266ab0d804c36473a64
Reviewed-on: https://go-review.googlesource.com/17046
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agonet/http: accept empty method in Transport again
Brad Fitzpatrick [Wed, 18 Nov 2015 20:22:29 +0000 (20:22 +0000)]
net/http: accept empty method in Transport again

Fix regression from https://golang.org/cl/16829 ("require valid methods
in NewRequest and Transport.RoundTrip").

An empty string is a valid method (it means "GET", per the docs).

Fixes #13311

Change-Id: I26b71dc4ccc146498b5d7e38fbe31ed11dd5a6cf
Reviewed-on: https://go-review.googlesource.com/16952
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/dist: run testshared on linux/386
Michael Hudson-Doyle [Tue, 27 Oct 2015 23:16:41 +0000 (12:16 +1300)]
cmd/dist: run testshared on linux/386

Change-Id: I22d40248e83fcad5ab73c0d402183d06e91064c7
Reviewed-on: https://go-review.googlesource.com/16388
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/link, runtime: call addmoduledata when dynamically linking on linux/386
Michael Hudson-Doyle [Tue, 27 Oct 2015 23:15:43 +0000 (12:15 +1300)]
cmd/link, runtime: call addmoduledata when dynamically linking on linux/386

Change-Id: If1faa2bba28a4e9a8061693173797c4114a7d699
Reviewed-on: https://go-review.googlesource.com/16387
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile/internal/gc: add line numbers for complit elts if needed (addresses TODO)
Robert Griesemer [Wed, 18 Nov 2015 22:16:28 +0000 (14:16 -0800)]
cmd/compile/internal/gc: add line numbers for complit elts if needed (addresses TODO)

For #13243.

Change-Id: I802cef3dad5d1236e70d0cd52047008a6a7a311a
Reviewed-on: https://go-review.googlesource.com/17045
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: address TODO (better comment)
Robert Griesemer [Wed, 18 Nov 2015 21:09:14 +0000 (13:09 -0800)]
cmd/compile/internal/gc: address TODO (better comment)

For #13243.

Change-Id: I544a8c44971fad126103157575e983ab528309bf
Reviewed-on: https://go-review.googlesource.com/17044
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: better error message for parenthesized go/defer exprs
Robert Griesemer [Wed, 18 Nov 2015 19:24:48 +0000 (11:24 -0800)]
cmd/compile/internal/gc: better error message for parenthesized go/defer exprs

Change-Id: Ie24d56422ae2196198a6c306716fa867c1442d6e
Reviewed-on: https://go-review.googlesource.com/17043
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {
Robert Griesemer [Wed, 18 Nov 2015 18:57:27 +0000 (10:57 -0800)]
cmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {

Handling of &(T{}) assumed that the parser would not introduce ()'s.

Also: Better comments around handling of OPAREN syntax tree optimization.

Fixes #13261.

Change-Id: Ifc5047a0448f5e7d74cd42f6608b87dcc9c2f2fb
Reviewed-on: https://go-review.googlesource.com/17040
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)
Robert Griesemer [Tue, 17 Nov 2015 01:27:32 +0000 (17:27 -0800)]
cmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)

Also:
- better error messages in some cases
- factored out function to produce syntax error at given line number

Fixes #13273.

Change-Id: I0192a94731cc23444680a26bd0656ef663e6da0b
Reviewed-on: https://go-review.googlesource.com/16992
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agonet: use t.Fatalf, not t.Fatal, in test
Ian Lance Taylor [Wed, 18 Nov 2015 19:10:59 +0000 (11:10 -0800)]
net: use t.Fatalf, not t.Fatal, in test

Found by cmd/vet.

Change-Id: Id570ecd76c3f1efd9696680ccd9799610217f8f7
Reviewed-on: https://go-review.googlesource.com/17042
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/internal/obj/x86, cmd/link: enable access to global data via GOT when -dynlink...
Michael Hudson-Doyle [Tue, 17 Nov 2015 23:30:23 +0000 (12:30 +1300)]
cmd/internal/obj/x86, cmd/link: enable access to global data via GOT when -dynlink on 386

Change-Id: I97504a11291ee60e656efb7704e37387e864d74f
Reviewed-on: https://go-review.googlesource.com/16385
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/internal/obj/x86: position independent access to global data on 386 when -shared
Michael Hudson-Doyle [Tue, 17 Nov 2015 23:14:07 +0000 (12:14 +1300)]
cmd/internal/obj/x86: position independent access to global data on 386 when -shared

This works by adding a call to __x86.get_pc_thunk.cx immediately before any
instruction that accesses global data and then assembling the instruction to
use the appropriate offset from CX instead of the absolute address. Some forms
cannot be assembled that way and are rewritten to load the address into CX
first.

-buildmode=pie works now, but is not yet tested.

Fixes #13201 (I think)

Change-Id: I32a8561e7fc9dd4ca6ae3b0e57ad78a6c50bf1f5
Reviewed-on: https://go-review.googlesource.com/17014
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/internal/obj/x86: factor rewriting to use GOT into separate function
Michael Hudson-Doyle [Wed, 11 Nov 2015 02:57:42 +0000 (15:57 +1300)]
cmd/internal/obj/x86: factor rewriting to use GOT into separate function

I was prodded into doing this in review comments for the ARM version, and it's
going to make shared libs for 386 easier.

Change-Id: Id12de801b1425b8c6b5736fe91b418fc123a4e40
Reviewed-on: https://go-review.googlesource.com/17012
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agocmd/link: link go.o first
Russ Cox [Mon, 16 Nov 2015 20:45:12 +0000 (15:45 -0500)]
cmd/link: link go.o first

Does not fix #12327 but nicer anyway.

Change-Id: I4ad730a4ca833d76957b7571895b3a08a6a530d4
Reviewed-on: https://go-review.googlesource.com/16964
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile: fix Val vs Opt collision
Russ Cox [Tue, 17 Nov 2015 21:34:06 +0000 (16:34 -0500)]
cmd/compile: fix Val vs Opt collision

Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: fix bad signal stack when using cgo-created threads and async signals
Russ Cox [Fri, 13 Nov 2015 21:21:01 +0000 (16:21 -0500)]
runtime: fix bad signal stack when using cgo-created threads and async signals

Cgo-created threads transition between having associated Go g's and m's and not.
A signal arriving during the transition could think it was safe and appropriate to
run Go signal handlers when it was in fact not.
Avoid the race by masking all signals during the transition.

Fixes #12277.

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

9 years agocmd/dist: don't run internal link tests on arm or darwin/arm64
Ian Lance Taylor [Wed, 18 Nov 2015 17:28:24 +0000 (09:28 -0800)]
cmd/dist: don't run internal link tests on arm or darwin/arm64

Change-Id: I373a64fc30dee804d99e106d4627b780e1846917
Reviewed-on: https://go-review.googlesource.com/16999
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agoRevert "runtime: use a proper type, sigset, for m.sigmask"
Russ Cox [Wed, 18 Nov 2015 17:18:08 +0000 (17:18 +0000)]
Revert "runtime: use a proper type, sigset, for m.sigmask"

This reverts commit 7db77271e423604c3b58b4c4da60ddc3c3eecc0d.

Change-Id: I6d8855eb05ca331025dc49a5533c6da4d1fa4e84
Reviewed-on: https://go-review.googlesource.com/17030
Reviewed-by: Russ Cox <rsc@golang.org>
9 years agostrings: fix period placement in Search doc comment
Caleb Spare [Wed, 18 Nov 2015 02:41:00 +0000 (18:41 -0800)]
strings: fix period placement in Search doc comment

Change-Id: Ieba62c0cb668daeb343f72fdd568e46b0b21b7d6
Reviewed-on: https://go-review.googlesource.com/16998
Reviewed-by: Andrew Gerrand <adg@golang.org>
9 years agocmd/link: add -libgcc option
Ian Lance Taylor [Tue, 17 Nov 2015 02:11:35 +0000 (18:11 -0800)]
cmd/link: add -libgcc option

An internal link may need the C compiler support library, libgcc.a.  Add
a -libgcc option to set the name of the compiler support library.  If
-libgcc is not used, run the compiler to find it.  Permit -libgcc=none
to skip using libgcc at all and hope for the best.

Change cmd/dist to not copy libgcc into the distribution.  Add tests to
ensure that all the standard packages that use cgo can be linked in
internal mode without using libgcc.  This ensures that somebody with a
Go installation without a C compiler can build programs.

Change-Id: I8ba35fb87ab0dd20e5cc0166b5f4145b04ce52a4
Reviewed-on: https://go-review.googlesource.com/16993
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
9 years agocmd/internal/obj/x86, cmd/link/internal/x86: support IE model TLS on linux/386
Michael Hudson-Doyle [Tue, 27 Oct 2015 22:40:22 +0000 (11:40 +1300)]
cmd/internal/obj/x86, cmd/link/internal/x86: support IE model TLS on linux/386

This includes the first parts of the general approach to PIC: load PC into CX
whenever it is needed. This is going to lead to large binaries and poor
performance but it's a start and easy to get right.

Change-Id: Ic8bf1d0a74284cca0d94a68cf75024e8ab063b4e
Reviewed-on: https://go-review.googlesource.com/16383
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independe...
Michael Hudson-Doyle [Tue, 27 Oct 2015 22:43:15 +0000 (11:43 +1300)]
cmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independent code

We might be able to do better than this, but it's a start.

Change-Id: I80ebce9094e084a4746039106ccf1ad9c4b8bb7c
Reviewed-on: https://go-review.googlesource.com/16384
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoruntime: handle volatility of CX when dynamically linking on linux/386
Michael Hudson-Doyle [Tue, 27 Oct 2015 23:10:28 +0000 (12:10 +1300)]
runtime: handle volatility of CX when dynamically linking on linux/386

Mostly by avoiding CX entirely, sometimes by reloading it.

I also vetted the assembly in other packages, it's all fine.

Change-Id: I50059669aaaa04efa303cf22ac228f9d14d83db0
Reviewed-on: https://go-review.googlesource.com/16386
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agocmd/go: enable -buildmode=pie on linux/386
Michael Hudson-Doyle [Tue, 17 Nov 2015 23:04:32 +0000 (12:04 +1300)]
cmd/go: enable -buildmode=pie on linux/386

Change-Id: Ie4cdf50fdaf7b368a189a84f4e2aea4cedd5ca7d
Reviewed-on: https://go-review.googlesource.com/17013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agoencoding/asn1: enforce use of short form lengths.
David Benjamin [Sun, 1 Nov 2015 01:30:00 +0000 (21:30 -0400)]
encoding/asn1: enforce use of short form lengths.

BER allows the sender to choose either short form or long form where
both are legal, but DER requires the minimal one be used. Enforce this
and add a test. Fix one test which was not minimally-encoded and another
which would not distinguish rejecting the input because the long form
length wasn't minimally-encoded from rejecting it because long form was
chosen when short form was allowed.

Change-Id: I1b56fcca594dcdeddea9378b4fab427cbe7cd26d
Reviewed-on: https://go-review.googlesource.com/16517
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>

9 years agotime: _2006 is a literal _, followed by 2006
Edward Muller [Sun, 25 Oct 2015 21:04:48 +0000 (14:04 -0700)]
time: _2006 is a literal _, followed by 2006

Otherwise _2006 is treated as _2 and then an error.

Fixes #11334

Change-Id: I40a385b45e279e9f4538bf419baab72781cdb215
Reviewed-on: https://go-review.googlesource.com/16311
Reviewed-by: Rob Pike <r@golang.org>
9 years agopath/filepath: in Rel use case-insensitive comparison on Windows
Mohit Agarwal [Mon, 16 Nov 2015 15:29:35 +0000 (20:59 +0530)]
path/filepath: in Rel use case-insensitive comparison on Windows

Compare basepath and targetpath using strings.EqualFold.  The absence
of this on Windows causes an unterminating condition in `for` statement
later in the function.

Fixes #13258

Change-Id: Ib5a0caba864ee425dc75ece47b9cf6fb626f47f1
Reviewed-on: https://go-review.googlesource.com/16857
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agonet: fix IPv4 address selection
Matthew Dempsky [Tue, 17 Nov 2015 04:26:24 +0000 (20:26 -0800)]
net: fix IPv4 address selection

Only apply RFC 6724's CommonPrefixLen rule for IPv4 source/destination
pairs that are members of the same IPv4 special purpose block.

Fixes #13283.

Change-Id: I2f7c26b408dd4675dfc5c1959e22d05b43bb8241
Reviewed-on: https://go-review.googlesource.com/16995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agopath/filepath: include the original paths in error messages
Mohit Agarwal [Mon, 16 Nov 2015 17:46:00 +0000 (23:16 +0530)]
path/filepath: include the original paths in error messages

On Windows, Rel emits error messages of the form `Rel: can't make
\windows relative to \windows`. Rather than emitting paths after
stripping volume names, emit the original paths so as to make those of
the form `Rel: can't make d:\windows relative to c:\windows`.  Fixed a
test that expected the error message to emit clean path instead of the
original.

Fixes #13259

Change-Id: I3a9bd5b137205f22794ec8046b4e917ee48cf750
Reviewed-on: https://go-review.googlesource.com/16858
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 years agocmd: enable android/386 build (buildmode=pie by default)
Hyang-Ah Hana Kim [Wed, 11 Nov 2015 21:34:06 +0000 (16:34 -0500)]
cmd: enable android/386 build (buildmode=pie by default)

no buildmode=c-shared yet.

Update golang/go#9327.

Change-Id: I9989d954d574807bac105da401c3463607fe8a99
Reviewed-on: https://go-review.googlesource.com/16700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agoruntime: use a proper type, sigset, for m.sigmask
Elias Naur [Tue, 17 Nov 2015 10:41:06 +0000 (11:41 +0100)]
runtime: use a proper type, sigset, for m.sigmask

Replace the cross platform but unsafe [4]uintptr type with a OS
specific type, sigset. Most OSes already define sigset, and this
change defines a suitable sigset for the OSes that don't (darwin,
openbsd). The OSes that don't use m.sigmask (windows, plan9, nacl)
now defines sigset as the empty type, struct{}.

The gain is strongly typed access to m.sigmask, saving a dynamic
size sanity check and unsafe.Pointer casting. Also, some storage is
saved for each M, since [4]uinptr was conservative for most OSes.

The cost is that OSes that don't need m.sigmask has to define sigset.

completes ./all.bash with GOOS linux, on amd64
completes ./make.bash with GOOSes openbsd, android, plan9, windows,
darwin, solaris, netbsd, freebsd, dragonfly, all amd64.

With GOOS=nacl ./make.bash failed with a seemingly unrelated error.

R=go1.7

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

9 years agocmd/doc: fix strange indentation artifacts with unexported fields
Joe Tsai [Sat, 24 Oct 2015 00:09:39 +0000 (17:09 -0700)]
cmd/doc: fix strange indentation artifacts with unexported fields

The NamePos value was not being set, and would default to a value
of zero. This would cause the printing logic to get confused as
to where exactly to place the "Has unexported fields" string.

A trivial package changes from

<
type A struct {
A int // A
B int
// B
// Has unexported fields.
}
>

to

<
type A struct {
A int // A
B int // B
// Has unexported fields.
}
>

Fixes #12971

Change-Id: I53b7799a1f1c0ad7dcaddff83d9aaeb1d6b7823e
Reviewed-on: https://go-review.googlesource.com/16286
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 years agoruntime, syscall: use int $0x80 to invoke syscalls on android/386
Michael Hudson-Doyle [Tue, 17 Nov 2015 07:00:20 +0000 (20:00 +1300)]
runtime, syscall: use int $0x80 to invoke syscalls on android/386

golang.org/cl/16796 broke android/386 by assuming behaviour specific to glibc's
dynamic linker. Copy bionic by using int $0x80 to invoke syscalls on
android/386 as the old alternative (CALL *runtime_vdso(SB)) cannot be compiled
without text relocations, which we want to get rid of on android.

Also remove "CALL *runtime_vdso(SB)" variant from the syscall package.

Change-Id: I6c01849f8dcbd073d000ddc8f13948a836b8b261
Reviewed-on: https://go-review.googlesource.com/16996
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
9 years agonet: don't require recursion be available in DNS responses
Dan Peterson [Mon, 16 Nov 2015 15:43:22 +0000 (11:43 -0400)]
net: don't require recursion be available in DNS responses

Fixes #12778

Change-Id: I2ca53180d46180b951749abe453fd560d0f1d9d6
Reviewed-on: https://go-review.googlesource.com/16950
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agogo/build: in TestDependencies, crypto/tls does not use cgo
Ian Lance Taylor [Tue, 17 Nov 2015 01:08:37 +0000 (17:08 -0800)]
go/build: in TestDependencies, crypto/tls does not use cgo

Change-Id: Id164a099e0ac8bd231ee7ed8d7b7a34c91f5f68f
Reviewed-on: https://go-review.googlesource.com/16991
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agonet/http: add/update mp4 sniffing
Emmanuel Odeke [Tue, 17 Nov 2015 03:24:58 +0000 (20:24 -0700)]
net/http: add/update mp4 sniffing

Completes sniffing for mp4 signature according
to the spec at:
  https://mimesniff.spec.whatwg.org/#signature-for-mp4
Clause 6.2.1

Fixes #8773

Change-Id: Icfc4a23324ae249db52c94a21c0e8509e1833e19
Reviewed-on: https://go-review.googlesource.com/16951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoruntime: android/arm64 support
David Crawshaw [Tue, 27 Oct 2015 23:46:49 +0000 (19:46 -0400)]
runtime: android/arm64 support

Not all tests passing yet, but a good chunk are.

Change-Id: I5daebaeabf3aecb380674ece8830a86751a8d139
Reviewed-on: https://go-review.googlesource.com/16458
Reviewed-by: Rahul Chaudhry <rahulchaudhry@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
9 years agonet/http: detect when an HTTPS client contacts an HTTP server
Caleb Spare [Tue, 20 Oct 2015 07:35:42 +0000 (00:35 -0700)]
net/http: detect when an HTTPS client contacts an HTTP server

Inspect the crypto/tls error to recognize this case and give a more
helpful error.

Fixes #11111.

Change-Id: I63f6af8c375aa892326ccccbd29655d54d68df0b
Reviewed-on: https://go-review.googlesource.com/16079
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
9 years agocmd/compile/internal/gc: add dropped line correction again
Robert Griesemer [Mon, 16 Nov 2015 21:25:48 +0000 (13:25 -0800)]
cmd/compile/internal/gc: add dropped line correction again

The line correction when reporting a missing package clause
was removed before since it wasn't clear that it was needed.
Added it again because of issue 13267.

No explicit test case has been added to test/fixedbugs because
it would require a file that contains a single byte and such a
file doesn't fit the existing test harness. Instead documented
the problematic line in the parser for future reference.

Fixes #13267.

Change-Id: I590fe8f358042aab73acf16c2ed9567872b174f4
Reviewed-on: https://go-review.googlesource.com/16975
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agotest: add test case for issue #13248
Robert Griesemer [Mon, 16 Nov 2015 20:40:45 +0000 (12:40 -0800)]
test: add test case for issue #13248

Issue #13248 was fixed by https://go-review.googlesource.com/#/c/16930/.
This is the corresponding test case (original offending program).

Change-Id: I7c99783db74a5422704409cea7e5073094beadd3
Reviewed-on: https://go-review.googlesource.com/16973
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: don't ignore EOF in new parser
Robert Griesemer [Mon, 16 Nov 2015 20:29:55 +0000 (12:29 -0800)]
cmd/compile/internal/gc: don't ignore EOF in new parser

Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agocmd/compile/internal/gc: correctly use internal call to error reporting
Robert Griesemer [Mon, 16 Nov 2015 19:24:43 +0000 (11:24 -0800)]
cmd/compile/internal/gc: correctly use internal call to error reporting

Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
9 years agoruntime: check for updated arena_end overflow
Austin Clements [Mon, 16 Nov 2015 19:37:59 +0000 (14:37 -0500)]
runtime: check for updated arena_end overflow

Currently, if an allocation is large enough that arena_end + size
overflows (which is not hard to do on 32-bit), we go ahead and call
sysReserve with the impossible base and length and depend on this to
either directly fail because the kernel can't possibly fulfill the
requested mapping (causing mheap.sysAlloc to return nil) or to succeed
with a mapping at some other address which will then be rejected as
outside the arena.

In order to make this less subtle, less dependent on the kernel
getting all of this right, and to eliminate the hopeless system call,
add an explicit overflow check.

Updates #13143. This real issue has been fixed by 0de59c2, but this is
a belt-and-suspenders improvement on top of that. It was uncovered by
my symbolic modeling of that bug.

Change-Id: I85fa868a33286fdcc23cdd7cdf86b19abf1cb2d1
Reviewed-on: https://go-review.googlesource.com/16961
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 years agotest: fix test case
Robert Griesemer [Mon, 16 Nov 2015 23:34:41 +0000 (15:34 -0800)]
test: fix test case

Issue introduced by https://go-review.googlesource.com/#/c/16920/ .

TBR=rsc

Change-Id: I2a0e0c81f641f869568230837c566913f6538f37
Reviewed-on: https://go-review.googlesource.com/16990
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
9 years agoruntime: make mcache.tiny a uintptr
Austin Clements [Mon, 16 Nov 2015 20:31:50 +0000 (15:31 -0500)]
runtime: make mcache.tiny a uintptr

mcache.tiny is in non-GC'd memory, but points to heap memory. As a
result, there may or may not be write barriers when writing to
mcache.tiny. Make it clearer that funny things are going on by making
mcache.tiny a uintptr instead of an unsafe.Pointer.

Change-Id: I732a5b7ea17162f196a9155154bbaff8d4d00eac
Reviewed-on: https://go-review.googlesource.com/16963
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

9 years agoruntime: clear tiny alloc cache in mark term, not sweep term
Austin Clements [Mon, 16 Nov 2015 20:20:59 +0000 (15:20 -0500)]
runtime: clear tiny alloc cache in mark term, not sweep term

The tiny alloc cache is maintained in a pointer from non-GC'd memory
(mcache) to heap memory and hence must be handled carefully.

Currently we clear the tiny alloc cache during sweep termination and,
if it is assigned to a non-nil value during concurrent marking, we
depend on a write barrier to keep the new value alive. However, while
the compiler currently always generates this write barrier, we're
treading on thin ice because write barriers may not happen for writes
to non-heap memory (e.g., typedmemmove). Without this lucky write
barrier, the GC may free a current tiny block while it's still
reachable by the tiny allocator, leading to later memory corruption.

Change this code so that, rather than depending on the write barrier,
we simply clear the tiny cache during mark termination when we're
clearing all of the other mcaches. If the current tiny block is
reachable from regular pointers, it will be retained; if it isn't
reachable from regular pointers, it may be freed, but that's okay
because there won't be any pointers in non-GC'd memory to it.

Change-Id: I8230980d8612c35c2997b9705641a1f9f865f879
Reviewed-on: https://go-review.googlesource.com/16962
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>