1
0
mirror of https://github.com/golang/go synced 2024-10-05 20:41:22 -06:00
Commit Graph

20532 Commits

Author SHA1 Message Date
Keith Randall
4f97ec0866 cmd/compile: captureless closures are constants
In particular, we can initialize globals with them at link time instead
of generating code for them in an init() function.  Less code, less
startup cost.

But the real reason for this change is binary size.  This change reduces
the binary size of hello world by ~4%.

The culprit is fmt.ssFree, a global variable which is a sync.Pool of
scratch scan states.  It is initalized with a captureless closure as the
pool's New action.  That action in turn references all the scanf code.

If you never call any of the fmt.Scanf* routines, ssFree is never used.
But before this change, ssFree is still referenced by fmt's init
function.  That keeps ssFree and all the code it references in the
binary.  With this change, ssFree is initialized at link time.  As a
result, fmt.init never mentions ssFree.  If you don't call fmt.Scanf*,
ssFree is unreferenced and it and the scanf code are not included.

This change is an easy fix for what is generally a much harder problem,
the unnecessary initializing of unused globals (and retention of code
that they reference).  Ideally we should have separate init code for
each global and only include that code if the corresponding global is
live.  (We'd need to make sure that the initializing code has no side
effects, except on the global being initialized.)  That is a much harder
change.

Update #6853

Change-Id: I19d1e33992287882c83efea6ce113b7cfc504b67
Reviewed-on: https://go-review.googlesource.com/17398
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 19:55:33 +00:00
Rob Pike
5ef899111e time: reject invalid day of month in Parse
There was back-and-forth on this but it has been decided to fix the original
complaint, which was easy.

Fixes #7268.

Change-Id: I6b607c49ad44579086aba2c4f4c5424b97fbed64
Reviewed-on: https://go-review.googlesource.com/17710
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-10 19:12:13 +00:00
Brad Fitzpatrick
9ccdc4edac net/http/httptest: don't crash in mime sniffing if HeaderMap is nil
Fixes some failing Google tests when run under Go tip (1.6).

Updates #12986

Change-Id: I0ca4d20f6103d10ea9464e45730085401336dada
Reviewed-on: https://go-review.googlesource.com/17698
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Nodir Turakulov <nodir@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-10 18:51:54 +00:00
Brad Fitzpatrick
8233ecd1b2 net/http: make NewRequest with empty method mean GET
Until recently, we always permitted an empty string to NewRequest.
Keep that property, since it broke tests within in Google when trying
out Go 1.6, and probably would've broken others too.

Change-Id: Idddab1ae7b9423d5caac00af2c897fe1065b600b
Reviewed-on: https://go-review.googlesource.com/17699
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 18:51:50 +00:00
Rob Pike
2aa5874490 cmd/doc: search the tree in breadth-first order
This is a simple change to the command that should resolve problems like finding
vendored packages before their non-vendored siblings. By searching in breadth-first
order, we find the matching package lowest in the hierarchy, which is more likely
to be correct than the deeper one, such as a vendored package, that will be found
in a depth-first scan.

This may be sufficient to resolve the issue, and has the merit that it is very easy
to explain. I will leave the issue open for now in case my intuition is wrong.

Update #12423

Change-Id: Icf69e8beb1845277203fcb7d19ffb7cca9fa41f5
Reviewed-on: https://go-review.googlesource.com/17691
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-10 18:08:16 +00:00
Robert Griesemer
732e2cd746 cmd/compile: don't truncate tiny float constants to 0 in error messages
Fixes #13559.

Change-Id: I6fe8b5083192e8eb6c1b3ca1919fde81a00ccb7e
Reviewed-on: https://go-review.googlesource.com/17695
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-12-10 16:39:46 +00:00
Mikio Hara
e05b48e22c net, internal/syscall/windows: fix interface and address identification on windows
The current implementation including Go 1.5 through 1.5.2 misuses
Windows API and mishandles the returned values from GetAdapterAddresses
on Windows. This change fixes various issues related to network facility
information by readjusting interface and interface address parsers.

Updates #5395.
Updates #10530.
Updates #12301.
Updates #12551.
Updates #13542.
Fixes #12691.
Fixes #12811.
Fixes #13476.
Fixes #13544.

Also fixes fragile screen scraping test cases in net_windows_test.go.

Additional information for reviewers:

It seems like almost all the issues above have the same root cause and
it is misunderstanding of Windows API. If my interpretation of the
information on MSDN is correctly, current implementation contains the
following bugs:

- SIO_GET_INTERFACE_LIST should not be used for IPv6. The behavior of
  SIO_GET_INTERFACE_LIST is different on kernels and probably it doesn't
  work correctly for IPv6 on old kernels such as Windows XP w/ SP2.
  Unfortunately MSDN doesn't describe the detail of
  SIO_GET_INTERFACE_LIST, but information on the net suggests so.

- Fetching IP_ADAPTER_ADDRESSES structures with fixed size area may not
  work when using IPv6. IPv6 generates ton of interface addresses for
  various addressing scopes. We need to adjust the area appropriately.

- PhysicalAddress field of IP_ADAPTER_ADDRESSES structure may have extra
  space. We cannot ignore PhysicalAddressLength field of
  IP_ADAPTER_ADDRESS structure.

- Flags field of IP_ADAPTER_ADDRESSES structure doesn't represent any of
  administratively and operatinal statuses. It just represents settings
  for windows network adapter.

- MTU field of IP_ADAPTER_ADDRESSES structure may have a uint32(-1) on
  64-bit platform. We need to convert the value to interger
  appropriately.

- IfType field of IP_ADAPTER_ADDRESSES structure is not a bit field.
  Bitwire operation for the field is completely wrong.

- OperStatus field of IP_ADAPTER_ADDRESSES structure is not a bit field.
  Bitwire operation for the field is completely wrong.

- IPv6IfIndex field of IP_ADAPTER_ADDRESSES structure is just a
  substitute for IfIndex field. We cannot prefer IPv6IfIndex to IfIndex.

- Windows XP, 2003 server and below don't set OnLinkPrefixLength field
  of IP_ADAPTER_UNICAST_ADDRESS structure. We cannot rely on the field
  on old kernels. We can use FirstPrefix field of IP_ADAPTER_ADDRESSES
  structure and IP_ADAPTER_PREFIX structure instead.

- Length field of IP_ADAPTER_{UNICAST,ANYCAST,MULTICAST}_ADDRESS
  sturecures doesn't represent an address prefix length. It just
  represents a socket address length.

Change-Id: Icabdaf7bd1d41360a981d2dad0b830b02b584528
Reviewed-on: https://go-review.googlesource.com/17412
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-10 08:04:07 +00:00
Brad Fitzpatrick
c2ef005486 net/http: run more tests in http2 mode
Failing ones are marked skipped.

Fixes #13543 (was just a test issue)
Updates #13555 (to be fixed later)
Updates #13556 (to be fixed later)
Updates #13557 (to be fixed later)
Fixes bug in golang.org/cl/17428 (http1 now uses HTTP status 431, not 413)

Change-Id: I8f7431fee35f2fc081cfe2c232ae75a00800a60b
Reviewed-on: https://go-review.googlesource.com/17683
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 04:43:08 +00:00
Matthew Dempsky
07f9c25b35 cmd/compile: remove unneeded error message cleanup pass
This code used to be necessary because of the error messages generated
by the YACC-based parser, but they're no longer relevant under the new
recursive descent parser:

  - LBRACE no longer exists, so "{ or {" can never occur.

  - The parser never generates error messages about "@" or "?" now
    (except in import sections, where they're actually legitimate).

  - The s/LLITERAL/litbuf/ substitution is handled in p.syntax_error.

Change-Id: Id39f747e4aa492c5830d14a47b161920bd4589ad
Reviewed-on: https://go-review.googlesource.com/17690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 21:25:05 +00:00
Ian Lance Taylor
0b37a6f47b cmd/compile, cmd/internal/obj: ignore AUSEFIELD
When using GOEXPERIMENT=fieldtrack, we can see AUSEFIELD instructions.
We generally want to ignore them.

No tests because as far as I can tell there are no tests for
GOEXPERIMENT=fieldtrack.

Change-Id: Iee26f25592158e5db691a36cf8d77fc54d051314
Reviewed-on: https://go-review.googlesource.com/17610
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 21:07:32 +00:00
Brad Fitzpatrick
371e44e5a1 runtime/race: update two stale references
Fixes #13550

Change-Id: I407daad8b94f6773d7949ba27981d26cbfd2cdf4
Reviewed-on: https://go-review.googlesource.com/17682
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-09 18:11:42 +00:00
Brad Fitzpatrick
efc806e92e net/http: clarify some RoundTripper behaviors
Fixes #12796
Updates #13444

Change-Id: I56840c0baf9b32a683086a80f5db1c5ea0a7aedf
Reviewed-on: https://go-review.googlesource.com/17680
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-09 17:35:43 +00:00
Brad Fitzpatrick
7e1791b97f math/big: fix typo
Found by github user asukakenji.

Change-Id: I4c76316b69e8a243fb6bf280283f3722e728d853
Reviewed-on: https://go-review.googlesource.com/17641
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-09 16:59:52 +00:00
Emmanuel Odeke
b8b65c10e0 net/http: make testCaseSensitiveMethod also test http2
Change-Id: I6427b0914fc4ccd9b841eae3aefe3b7a355fc436
Reviewed-on: https://go-review.googlesource.com/17596
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 14:56:13 +00:00
Alex Brainman
9a89ac35fe net: add TestInterfaceHardwareAddrWithGetmac
Use Windows getmac command to verify interface
MAC addresses net package returns.

The test is to be enabled once issue #12691 is fixed.

Updates #12691

Change-Id: Ic28c83303590cb4d48ee025250d4b6e30683bfd4
Reviewed-on: https://go-review.googlesource.com/17632
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 06:48:26 +00:00
Alex Brainman
2fb931d08f path/filepath: remove code working around Join bug
EvalSymlinks code assumes that Join has a bug
(see issue #11551 for details). But issue #11551 has
been fixed. Remove the workaround so it does not
confuses us when we read code next time.

Change-Id: I06bea20189f01f9922237c05516847353d8e4736
Reviewed-on: https://go-review.googlesource.com/17620
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 06:10:46 +00:00
Alex Brainman
1b7a2273e5 net: add TestInterfaceAddrsWithNetsh
Use windows netsh command to verify interface
addresses and netmasks net package returns.

The test is to be enabled once issue #12811
is fixed.

Updates #12811

Change-Id: I191e350a1403e5133791d4ec59561fefa24f5c61
Reviewed-on: https://go-review.googlesource.com/17478
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 04:41:16 +00:00
Robert Griesemer
c488548967 cmd/compile: recognize labels even if they have the same name as packages
Another (historic) artifact due to partially resolving symbols too early.

Fixes #13539.

Change-Id: Ie720c491cfa399599454f384b3a9735e75d4e8f1
Reviewed-on: https://go-review.googlesource.com/17600
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 02:02:11 +00:00
Emmanuel Odeke
560937434d net/http: testClientHead now in http2 mode
Change-Id: I21317e3f60502759efc026cdfdb0b1d5f411cae9
Reviewed-on: https://go-review.googlesource.com/17521
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:10:10 +00:00
Emmanuel Odeke
b220d41666 net/http: sniffTest for 5953 set in http2 mode
Change-Id: I345b6ea7024a1c85c805b2d2e22f9f79aeca5816
Reviewed-on: https://go-review.googlesource.com/17462
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:00:44 +00:00
Emmanuel Odeke
5d7dc23ec5 net/http: clientHeadContentLength test now in http2 mode
Change-Id: If6cc1298ad550790ee981c1b5dc618a14947dc4a
Reviewed-on: https://go-review.googlesource.com/17526
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:00:35 +00:00
Emmanuel Odeke
cdc65778a2 net/http: testClientRedirectEatsBody test now in http2 mode
Change-Id: I181346a8d2a8a96fd790cde087c8fd73af911298
Reviewed-on: https://go-review.googlesource.com/17529
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:24:26 +00:00
Brad Fitzpatrick
3d3d6eb79d net/http: update bundled http2 and add tests for two fixed issues
Updates to http2's golang.org/cl/17590 (git rev 1796f9b8b)

Fixes #13495
Fixes #13532

Change-Id: I9b95ab438e1d895c75d031d8fcf2605921182a5e
Reviewed-on: https://go-review.googlesource.com/17591
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:22:09 +00:00
Emmanuel Odeke
1092257f7e net/http: zeroLengthPostAndResponse test now in http2 mode
Change-Id: I282a399657c71f7b6406fcdde8afc82a13bdfe5f
Reviewed-on: https://go-review.googlesource.com/17530
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:13:30 +00:00
Emmanuel Odeke
10d1d5b673 net/http: testStreamingGet now in http2 mode
Change-Id: I9a1fe057f5bf008fa16577a7d71064050aea47e9
Reviewed-on: https://go-review.googlesource.com/17525
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-08 22:23:06 +00:00
Brad Fitzpatrick
9b8080f37e net/http: update bundled http2 copy
Updates golang.org/x/net/http2 to git rev 438097d76

Fixes #13444

Change-Id: I699ac02d23b56db3e8a27d3f599ae56cd0a5b4b2
Reviewed-on: https://go-review.googlesource.com/17570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-08 22:01:01 +00:00
Matt T. Proud
616e45eaa1 encoding/pem: make TestFuzz testing/quick safe
This adapts pem.TestFuzz to sanitize the generated Block fields,
because the encoder and wireformat do not differentiate between nil
and empty slices and maps, while reflect.DeepEqual rightfully does.
In the commit mentioned below, we adapt quick.Value in
testing/quick to generate these value states, which had heretofore
been impossible with the standard library fuzz test facility.

This commit is a piecemeal extraction from ...

  https://go-review.googlesource.com/#/c/16470

..., which rsc requested to be separated from the nil slice and map
generations.

Change-Id: Iec751a2b0082af6e672a09dc9b7f4b4fb309e8a8
Reviewed-on: https://go-review.googlesource.com/17499
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-08 19:27:20 +00:00
Russ Cox
1be2ddda9a encoding/json: document Indent's preservation of trailing spaces
Fixes #13520.

Change-Id: Ia70cc44be3912167b369d7f74d3436331975c300
Reviewed-on: https://go-review.googlesource.com/17561
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-08 19:26:26 +00:00
Adam Langley
f740d717bd crypto/elliptic: resample private keys if out of range.
The orders of the curves in crypto/elliptic are all very close to a
power of two. None the less, there is a tiny bias in the private key
selection.

This change makes the distribution uniform by resampling in the case
that a private key is >= to the order of the curve. (It also switches
from using BitSize to Params().N.BitLen() because, although they're the
same value here, the latter is technically the correct thing to do.)

The private key sampling and nonce sampling in crypto/ecdsa don't have
this issue.

Fixes #11082.

Change-Id: Ie2aad563209a529fa1cab522abaf5fd505c7269a
Reviewed-on: https://go-review.googlesource.com/17460
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-08 17:39:09 +00:00
Robert Griesemer
670642d389 go/parser, go/types: report invalid else branch in if statements
- Only accept valid if statement syntax in go/parser.

- Check AST again in go/types since it may have been modified and the
  AST doesn't preclude other statements in the else branch of an if
  statement.

- Removed a test from gofmt which verified that old-style if statements
  permitting any statement in the else branch were correctly reformatted.
  It's been years since we switched to the current syntax; no need to
  support this anymore.

- Added a comment to go/printer.

Fixes #13475.

Change-Id: Id2c8fbcc68b719cd511027d0412a37266cceed6b
Reviewed-on: https://go-review.googlesource.com/17408
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 21:36:31 +00:00
Aleksandr Demakin
c5aa53c8c5 cmd/go: fix bad shared lib name with buildmode=shared
Use import paths of packages to build a shared lib name.
Use arguments for meta-packages 'std', 'cmd', and 'all'.

Fixes #12236

Change-Id: If274d63301686ef34e198287eb012f9062541ea0
Reviewed-on: https://go-review.googlesource.com/13921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 21:23:48 +00:00
Rob Pike
148b13c3bb encoding/gob: document behavior of zero-valued arrays, slices, and maps
The documentation was inconsistent. It said zero values were not sent, but
that zero-valued elements of arrays and arrays were sent. But which rule
applies if the array is all zero elements, and is therefore itself a zero value?

The answer is: the array is transmitted. In principle the other choice could
be made, but there would be considerable expense and complexity required
to implement this behavior now, not to mention worries about changes of
behavior.

Therefore we just document the situation: Arrays, slices, and maps are
always encoded. It would perhaps be nice to have sorted this out earlier,
but it was a missed opportunity.

Fixes #13378

Change-Id: I8fae345edfa707fcfa7a3e0160d87ff1ac5cc5a2
Reviewed-on: https://go-review.googlesource.com/17394
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:41:31 +00:00
Didier Spezia
70da2d0a2a cmd/compile/internal/gc: fix internal compiler error on invalid declaration
Following an empty import, a declaration involving a ? symbol
generates an internal compiler error when the name of the
symbol (in newname function).

package a
import""
var?

go.go:2: import path is empty
go.go:3: internal compiler error: newname nil

Make sure dclname is not called when the symbol is nil.
The error message is now:

go.go:2: import path is empty
go.go:3: invalid declaration
go.go:4: syntax error: unexpected EOF

This CL was initially meant to be applied to the old parser,
and has been updated to apply to the new parser.

Fixes #11610

Change-Id: I75e07622fb3af1d104e3a38c89d9e128e3b94522
Reviewed-on: https://go-review.googlesource.com/15268
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:21:21 +00:00
Robert Griesemer
715f63778d cmd/compile: avoid converting huge floats to integers
Fixes #13471.

Change-Id: I232ad1729343d020254e313cfff182695ad6fc54
Reviewed-on: https://go-review.googlesource.com/17401
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-07 20:20:56 +00:00
Russ Cox
50c5042047 runtime: best-effort detection of concurrent misuse of maps
If reports like #13062 are really concurrent misuse of maps,
we can detect that, at least some of the time, with a cheap check.

There is an extra pair of memory writes for writing to a map,
but to the same cache line as h.count, which is often being modified anyway,
and there is an extra memory read for reading from a map,
but to the same cache line as h.count, which is always being read anyway.
So the check should be basically invisible and may help reduce the
number of "mysterious runtime crash due to map misuse" reports.

Change-Id: I0e71b0d92eaa3b7bef48bf41b0f5ab790092487e
Reviewed-on: https://go-review.googlesource.com/17501
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-12-07 20:19:52 +00:00
Didier Spezia
7ebb96a489 cmd/compile/internal/gc: fix panic in Type Stringer
The following code:

func n() {(interface{int})}

generates:

3: interface contains embedded non-interface int
3: type %!v(PANIC=runtime error: invalid memory address or nil pointer dereference) is not an expression

It is because the corresponding symbol (Sym field in Type object)
is nil, resulting in a panic in typefmt.

Just skip the symbol if it is nil, so that the error message becomes:

3: interface contains embedded non-interface int
3: type interface { int } is not an expression

Fixes #11614

Change-Id: I219ae7eb01edca264fad1d4a1bd261d026294b00
Reviewed-on: https://go-review.googlesource.com/14015
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-07 20:18:03 +00:00
Matthew Dempsky
423b0cc25a cmd/compile: base mapaccess optimizations on algtype
algtype already controls the behavior of the normal map access code
paths, so it makes sense to base the decision on which optimized paths
are applicable on it too.

Enables use of optimized paths for key types like [8]byte and struct{s
string}.

Fixes #13271.

Change-Id: I48c52d97abaa7259ad5aba9641ea996a967cd359
Reviewed-on: https://go-review.googlesource.com/17464
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-12-07 20:13:32 +00:00
Daniel Theophanes
b2492d16a0 cmd/go: always show current value for GO15VENDOREXPERIMENT
Prior behavior would show empty string when unset. In go1.5 this
would result in "off". In go1.6 this will result in "on". This
change will make empty or "0" off and "1" on for go1.5 and go1.6.
Vendor tools can then rely on this value.

Discussion:
https://groups.google.com/forum/#!topic/golang-dev/oZzcXrlRrkA

Change-Id: I7e145a32e813dfde02dc262a9186c7af28db7b92
Reviewed-on: https://go-review.googlesource.com/17487
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 15:52:15 +00:00
Emmanuel Odeke
3d70475833 net/http: sniffWrite test also in http2 mode
Change-Id: Ifa9f1ed6a3b8d3f7536f2d315259940335b0ee49
Reviewed-on: https://go-review.googlesource.com/17438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 15:50:34 +00:00
Brad Fitzpatrick
c34bc90ffc crypto/x509: convert ErrInsecureAlgorithm into a type
Change-Id: I411aeaf0cf75eb8b1c9005b622f664e9f25e4a68
Reviewed-on: https://go-review.googlesource.com/17400
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 14:24:49 +00:00
Russ Cox
a6869d1c5c net/url: accept non-ASCII bytes in URL per RFC 3986
Fixes #7991.
Fixes #12719.

Change-Id: I5650fa35ec5d49addeda6cc6e7fa93cfbe1cdfc0
Reviewed-on: https://go-review.googlesource.com/17385
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-07 14:01:56 +00:00
andrey mirtchovski
84a875caa6 go/doc, syscall: change 'more then' to 'more than'
This change modifies comments to use the more gramatically correct "more than"
instead of "more then".

Change-Id: Ie3bddcf25eb6b243a21da934f2f3c76a750c083a
Reviewed-on: https://go-review.googlesource.com/17488
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-07 05:34:33 +00:00
Alex Brainman
51a112fefc path/filepath: handle c: as first parameter in Join properly
This is CL 11882 brought back to life.

Fixes #11551

Change-Id: I29810183957745442d1e9937f56a66fc9c6cc82a
Reviewed-on: https://go-review.googlesource.com/17470
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-06 06:11:09 +00:00
Russ Cox
b9fde8605e runtime: fix integer comparison in signal handling
(sig is unsigned, so sig-1 >= 0 is always true.)

Fixes #11281.

Change-Id: I4b9d784da6e3cc80816f2d2f7228d5d8a237e2d5
Reviewed-on: https://go-review.googlesource.com/17457
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 21:23:35 +00:00
Russ Cox
c5a94ba24f runtime: document that NumCPU does not change
Fixes #11609.

Change-Id: I3cf64164fde28ebf739706728b84d8ef5b6dc90e
Reviewed-on: https://go-review.googlesource.com/17456
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-05 20:16:35 +00:00
Russ Cox
025e9b0ca3 mime: fix parsing of empty string attribute value
Fixes #11290.

Change-Id: I312f0731077b78a4bed47062eb7fd1ab52bc3dd1
Reviewed-on: https://go-review.googlesource.com/17453
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-05 20:14:25 +00:00
Shenghou Ma
35e84546d7 runtime: check and fail early with a message if MMX is not available on 386
Fixes #12970.

Change-Id: Id0026e8274e071d65d47df63d65a93110abbec5d
Reviewed-on: https://go-review.googlesource.com/15998
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-05 17:43:51 +00:00
Yuval Pavel Zholkover
4a2915052b Revert "syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL"
This reverts commit f25f6eab0c.

Sorry, this was not meant to go in without the ztypes_freebsd_arm.go and the copyFromV9 function.

Change-Id: I4ac2a8a23809ec1b1b9e42992cd0f3c349848f06
Reviewed-on: https://go-review.googlesource.com/17472
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 07:45:01 +00:00
Russ Cox
5b1a8a5239 cmd/vet: move cmd/vet/whitelist to cmd/vet/internal/whitelist
This was a mistake made when bringing cmd/vet into the main repo.

Fixes #13416.

Change-Id: I03b512ab944577c56085aea06df8ff5e1acc16d7
Reviewed-on: https://go-review.googlesource.com/17455
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-12-05 06:26:17 +00:00
Mikio Hara
d2ca451873 net: adjust Lookup API test cases
This change makes existing Lookup API test cases conform to the new
return value form that all the Lookup APIs except LookupTXT must return
a single or multiple absolute domain names.

Updates #12189.
Fixes #12193.

Change-Id: I03ca09be5bff80e818fbcdc26039daa33d5440a8
Reviewed-on: https://go-review.googlesource.com/17411
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 06:19:47 +00:00
Matthew Dempsky
336c998291 cmd/compile: reject slice/map/func comparisons against converted nil
Fixes #13480.

Change-Id: Icbf4f83e965e84f7020f56c3f346193f8b91e7bf
Reviewed-on: https://go-review.googlesource.com/17461
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 05:46:48 +00:00
Yuval Pavel Zholkover
f25f6eab0c syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL
Switch IfMsghdr and IfaMsghdr to their 'l' variants, make the IfData layout
to be based on FreeBSD-11.0 (freebsdVersion >= 1100011).
Using freebsdVersion, detect the appropriate layout at runtime and decode
routing socket messages into the new IfData layout.

Fixes #11641

Change-Id: Ic7ec550f00c0d15f46a36f560d835e4f138f61e1
Reviewed-on: https://go-review.googlesource.com/14757
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:55:02 +00:00
Didier Spezia
77328b8d12 cmd/link: clean up dwarf.go
Try to remove the most visible artefacts resulting from the
C to Go translation. It includes:

- refactoring the find function to eliminate goto and variable declarations
- removing useless variables still having a _ = xxx
- decreasing the number of upfront variable declarations

No semantic changes.

Change-Id: I84d981c48b2d9e22e6b9db5f2a703c80c60249ba
Reviewed-on: https://go-review.googlesource.com/15681
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:13:18 +00:00
Mohit Agarwal
08ab43eca2 cmd/pprof: exit with non-zero status code on error
Set the status code in case of error.

Fixes #11510

Change-Id: If461c30a1f6d2275539f33a2eabd7b19bbfa411d
Reviewed-on: https://go-review.googlesource.com/16718
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:09:15 +00:00
Konstantin Shaposhnikov
3fb9e08758 cmd/vet: make "-all -shadow" mean all default checks and -shadow
Prior to this change "go tool vet -all -shadow" ran only -shadow check.

Also fix godoc package path in the usage text.

Fixes #13020

Change-Id: I87c60d6b06a02106ae8bff56adb79df032cc4646
Reviewed-on: https://go-review.googlesource.com/16325
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:07:36 +00:00
Didier Spezia
e0c05fcb5b cmd/pprof/internal: map/slice literals janitoring
Simplify slice/map literal expression.
Caught with gofmt -d -s, fixed with gofmt -w -s

Change-Id: I19723900d0649019bf79b9330d68525a68ed69c4
Reviewed-on: https://go-review.googlesource.com/13835
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:01:28 +00:00
Russ Cox
a456e356b2 net/url: accept empty port after colon in IPv6 literal host
Fixes #12200.

Change-Id: I89f2a7326bb9182024c44bf815a06fa48639649d
Reviewed-on: https://go-review.googlesource.com/17384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 03:56:55 +00:00
Russ Cox
cd58f44b20 runtime/cgo: assume Solaris thread stack is at least 1 MB
When run with "ulimit -s unlimited", the misc/cgo/test test binary
finds a stack size of 0x3000 returned by getcontext, causing the
runtime to try to stay within those bounds and then fault when
called back in the test after 64 kB has been used by C.

I suspect that Solaris is doing something clever like reporting the
current stack size and growing the stack as faults happen.
On all the other systems, getcontext reports the maximum stack size.
And when the ulimit is not unlimited, even Solaris reports the
maximum stack size.

Work around this by assuming that any stack on Solaris must be at least 1 MB.

Fixes #12210.

Change-Id: I0a6ed0afb8a8f50aa1b2486f32b4ae470ab47dbf
Reviewed-on: https://go-review.googlesource.com/17452
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-05 03:56:06 +00:00
Yann Kerhervé
5c24832293 syscall: fix ParseRoutingSockaddr name in docs
Change-Id: I3870150fc8e713f6164371299c029b31f18f250a
Reviewed-on: https://go-review.googlesource.com/17426
Reviewed-by: Minux Ma <minux@golang.org>
2015-12-05 00:10:40 +00:00
Emmanuel Odeke
c6d660a330 net/http: make TestRedirect also test in http2 mode
Change-Id: Idfbe91abc11b2b3b735cd8d11fb1938f9e5c0473
Reviewed-on: https://go-review.googlesource.com/17437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-05 00:05:00 +00:00
Emmanuel Odeke
c2290feeeb net/http: sniff tests ported to h2
Change-Id: Icad6cc130252ac177946b23c12f36d6ba3275bf0
Reviewed-on: https://go-review.googlesource.com/17436
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:38:27 +00:00
Emmanuel Odeke
2f2423c81d net/http: TimeoutHandler test ported to HTTP/2
Change-Id: I69e62199140e5cf203696af17d4816f3a5f13bd1
Reviewed-on: https://go-review.googlesource.com/17434
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:09:35 +00:00
Emmanuel Odeke
983926a728 net/http: testHeadResponses port for h2
Change-Id: I4cf4596a305510cd25df34ecebd11a19266415f1
Reviewed-on: https://go-review.googlesource.com/17435
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:09:16 +00:00
Joe Tsai
5ebb374f96 archive/tar: properly parse GNU base-256 encoding
Motivation:
* Previous implementation did not detect integer overflow when
parsing a base-256 encoded field.
* Previous implementation did not treat the integer as a two's
complement value as specified by GNU.

The relevant GNU specification says:
<<<
GNU format uses two's-complement base-256 notation to store values
that do not fit into standard ustar range.
>>>

Fixes #12435

Change-Id: I4639bcffac8d12e1cb040b76bd05c9d7bc6c23a8
Reviewed-on: https://go-review.googlesource.com/17424
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 22:38:15 +00:00
Emmanuel Odeke
c498a45b33 net/http: Connection:close test is h1 specific
Change-Id: I77e4df7ab0bc20d2e251c1eda9ce9026484b8bbc
Reviewed-on: https://go-review.googlesource.com/17433
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 21:52:31 +00:00
Joe Tsai
481eedce62 archive/tar: properly format GNU base-256 encoding
Motivation:
* Previous implementation silently failed when an integer overflow
occurred. Now, we report an ErrFieldTooLong.
* Previous implementation did not encode in two's complement format and was
unable to encode negative numbers.

The relevant GNU specification says:
<<<
GNU format uses two's-complement base-256 notation to store values
that do not fit into standard ustar range.
>>>

Fixes #12436

Change-Id: I09c20602eabf8ae3a7e0db35b79440a64bfaf807
Reviewed-on: https://go-review.googlesource.com/17425
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 21:38:38 +00:00
Russ Cox
e71d64012c sort: improve average quicksort performance
Revert "Revert "sort: improve average quicksort performance""
This reverts commit 30b87bb9aa.

See https://golang.org/cl/15688 for the CL being replayed.

Change-Id: I2ba36334003f4971f95a10536adfdd86be9a50de
Reviewed-on: https://go-review.googlesource.com/17389
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-04 20:41:47 +00:00
Sokolov Yura
43a9e998d2 go/ast: remove many blank lines in SortImports
Currently only one blank line is checked to be removed.
Changing sort.Sort may lead to more blank lines.
Let's remove them all.

It fixes a bug found by https://golang.org/cl/15688

Change-Id: I682cc23ecd7b10d9b6feb160da040a155297f578
Reviewed-on: https://go-review.googlesource.com/17440
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-04 20:01:51 +00:00
Burcu Dogan
a8d9c3103d net/http: test max request body size against both HTTP/1 and HTTP/2
Change-Id: I009eaa52d03f1c3af33a6e884332f41c7cf48edd
Reviewed-on: https://go-review.googlesource.com/17427
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 19:54:05 +00:00
Brad Fitzpatrick
1ea31c7baf net/http: convert TestSetsRemoteAddr to use clientServerTest
This is an example of converting an old HTTP/1-only test to test
against both HTTP/1 and HTTP/2.

Please send more of these!

Also, for comparing the http.Transport's responses between HTTP/1 and
HTTP/2, see clientserver_test.go's h12Compare type and tests using
h12Compare. Sometimes that's the more appropriate option.

Change-Id: Iea24d844481efd5849173b60e15dcc561a32b88f
Reviewed-on: https://go-review.googlesource.com/17409
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 19:16:57 +00:00
Russ Cox
30b87bb9aa Revert "sort: improve average quicksort performance"
Broke the build: http://build.golang.org/log/8159de7e0d6f3832da394c310975ddd4c4c74627
(cmd/gofmt TestRewrite)

This reverts commit 6f6b2f04b5.

Change-Id: Ifd46b0b76c30b0a568521eaaf5ef8968a9549bf5
Reviewed-on: https://go-review.googlesource.com/17383
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-04 17:09:34 +00:00
Russ Cox
c4135dac63 encoding/json: streamline, unexport valid Number checking
Followup to CL 12250.

For #10281.

Change-Id: If25d9cac92f10327bb355f2d11b00c625b464661
Reviewed-on: https://go-review.googlesource.com/17199
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-04 16:18:57 +00:00
Russ Cox
e8cc083ede net/mail: do not parse RFC 2047 tokens in quoted strings
RFC 2047 tokens like =?utf-8?B?whatever?= can only appear
unquoted, but this code was trying to decode them even when
they came out of quoted strings. Quoted strings must be left alone.

Fixes #11294.

Change-Id: I41b371f5b1611f1e56d93623888413d07d4ec878
Reviewed-on: https://go-review.googlesource.com/17381
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 16:11:09 +00:00
Sokolov Yura
6f6b2f04b5 sort: improve average quicksort performance
- change way of protection from O(N^2) on duplicate values.
  Previous algorithm does additional comparisons and swaps
  on every split pass.
  Changed algorithm does one ordinal quicksort split pass,
  and if distribution is skewed, then additional pass to
  separate pivot's duplicates.
  Changed algorithm could be slower on very ununique slice,
  but it is still protected from O(N^2).

- increase small slice size and do simple shell sort pass
  to amortize worst case on small slices.
  Small slice has higher probability to have skewed
  distribution, so lets sort it with simpler algorithm.

benchmark                 old ns/op      new ns/op      delta
BenchmarkSortString1K     458374         388641         -15.21%
BenchmarkSortInt1K        217851         181796         -16.55%
BenchmarkSortInt64K       20539264       16730340       -18.54%
BenchmarkSort1e2          98668          95554          -3.16%
BenchmarkSort1e4          20278500       18316829       -9.67%
BenchmarkSort1e6          3215724392     2795999911     -13.05%

number of operations:
       Size:         Total:     Swap:     Less:
                          %         %         %
Sort     100  Avg    -5.98%   -18.43%    -1.90%
Sort     100  Max   -14.43%   -16.02%    -4.51%
Sort     300  Avg    -7.50%   -12.76%    -5.96%
Sort     300  Max   -11.29%    -9.60%    -4.30%
Sort    1000  Avg   -12.13%   -11.65%   -12.25%
Sort    1000  Max   -13.81%   -11.77%   -11.89%
Sort    3000  Avg   -14.61%    -9.30%   -15.86%
Sort    3000  Max   -15.81%    -8.66%   -15.19%
Sort   10000  Avg   -16.10%    -8.47%   -17.80%
Sort   10000  Max   -17.13%    -7.63%   -16.97%
Sort   30000  Avg   -17.46%    -7.56%   -19.57%
Sort   30000  Max   -18.24%    -7.62%   -17.68%
Sort  100000  Avg   -18.83%    -6.64%   -21.33%
Sort  100000  Max   -19.72%    -6.70%   -20.96%
Sort  300000  Avg   -19.61%    -6.16%   -22.30%
Sort  300000  Max   -20.69%    -6.15%   -21.81%
Sort 1000000  Avg   -20.42%    -5.58%   -23.31%
Sort 1000000  Max   -21.54%    -5.56%   -23.61%

Change-Id: I23868e8b52b5841b358cd5403967c9a97871e4d5
Reviewed-on: https://go-review.googlesource.com/15688
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-04 15:17:47 +00:00
Mikio Hara
8854bdbd76 net: fix parsing literal IPv6 address with zone identifier when using cgo
Parsing literal IPv6 address with zone identifier is already supported
when not using cgo. This change enables it when using cgo too.

Fixes #12241.

Change-Id: I3ed78c9e750e75eff0dae76ba8608df39503cf85
Reviewed-on: https://go-review.googlesource.com/17215
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-12-04 02:50:00 +00:00
Mikio Hara
d41d47306a net/mail: gofmt
Change-Id: Ic704a2614e310bc7aa3bdee89a020c27f4292efa
Reviewed-on: https://go-review.googlesource.com/17410
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 02:38:34 +00:00
David du Colombier
cd294636c8 net: return rooted DNS names on Plan 9
This change returns rooted DNS names on Plan 9,
for consistency with other operating systems.

Updates #12193.

Change-Id: If983920c5b9a8f67d4ccb51bb295fac8dfb87e88
Reviewed-on: https://go-review.googlesource.com/15581
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-04 01:47:18 +00:00
Brad Fitzpatrick
6dd4e5dd3a encoding/asn1: export tag and class constants
Fixes #9236

Change-Id: I744d7f071e945ea6e6e50203d931f4678c8b545d
Reviewed-on: https://go-review.googlesource.com/17311
Reviewed-by: Adam Langley <agl@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-03 22:09:09 +00:00
Brad Fitzpatrick
71d2fa8bae net/http: deflake a non-short test, clean up export_test.go
This makes TestTransportResponseCloseRace much faster and no longer
flaky.

In the process it also cleans up test hooks in net/http which were
inconsistent and scattered.

Change-Id: Ifd0b11dbc7e8915c24eb5bdc36731ed6751dd7ec
Reviewed-on: https://go-review.googlesource.com/17316
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 21:58:29 +00:00
Matthew Dempsky
7a4022ee36 cmd/compile: fix live variable reuse in orderstmt
The call "poptemp(t, order)" at line 906 should match up with the
assignment "t := marktemp(order)" at line 770, so use a new temporary
variable for stripping the ODCL nodes from a "case x := <-ch" node's
Ninit list.

Fixes #13469.
Passes toolstash/buildall.

Change-Id: Ia7eabd40c79cfdcb83df00b6fbd0954e0c44c5c7
Reviewed-on: https://go-review.googlesource.com/17393
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2015-12-03 21:29:22 +00:00
Austin Clements
7648387705 debug/elf: transparently decompress compressed sections
This adds support for compressed ELF sections. This compression is
treated as a framing issue and hence the package APIs all
transparently decompress compressed sections. This requires some
subtlety for (*Section).Open, which returns an io.ReadSeeker: since
the decompressed data comes from an io.Reader, this commit introduces
a Reader-to-ReadSeeker adapter that is efficient for common uses of
Seek and does what it can otherwise.

Fixes #11773.

Change-Id: Ic0cb7255a85cadf4c1d15fb563d5a2e89dbd3c36
Reviewed-on: https://go-review.googlesource.com/17341
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
2015-12-03 20:53:11 +00:00
Austin Clements
e1544d3bb6 dwbug/elf: support old-style compressed DWARF
GCC and LLVM support zlib-compressing DWARF debug sections (and
there's some evidence that this may be happening by default in some
circumstances now).

Add support for reading compressed DWARF sections. Since ELF
relocations apply to the decompressed data, decompression is done
before applying relocations. Since relcations are applied by
debug/elf, decompression must also be handled there.

Note that this is different from compressed ELF sections, which is a
more general mechanism used by very recent versions of GCC.

Updates #11773.

Change-Id: I3f4bf1b04d0802cc1e8fcb7c2a5fcf6c467c5089
Reviewed-on: https://go-review.googlesource.com/17340
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-03 20:53:04 +00:00
Russ Cox
606d9a7e18 crypto/x509: introduce ErrInsecureAlgorithm for insecure algorithms
Until now we've used ErrUnknownAlgorithm but that's a bit confusing
when it is returned for obviously-known things like MD5.

Fixes #10431.

Change-Id: Ief8a8ef46e5b99bd4fd18e1acd7ae398a484bac3
Reviewed-on: https://go-review.googlesource.com/17380
Reviewed-by: Adam Langley <agl@golang.org>
2015-12-03 20:02:09 +00:00
Brad Fitzpatrick
a778ac5d76 net/http: make Client follow redirects even if Request.Method is empty
Fixes #12705

Change-Id: I69639d2b03777835b2697ff349a00ccab410aa49
Reviewed-on: https://go-review.googlesource.com/17318
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-03 19:53:44 +00:00
Benjamin Prosnitz
723605e918 net: fix failing TestGoLookupIPOrderFallbackToFile
Change-Id: I17ef4e221e5cd0fb8dc553785248ccac59380c6f
Reviewed-on: https://go-review.googlesource.com/17321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 19:01:30 +00:00
Volker Dobler
008e96c056 os: be more specific on what flags are used for
The flags are used in OpenFile, not Open.

Change-Id: I45c1639e36694529cb29c2b580c43a22e6fd10ac
Reviewed-on: https://go-review.googlesource.com/17352
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 16:27:11 +00:00
Russ Cox
3e6529d202 encoding/json: revise docs for Unmarshal into map, slice, array
Fixes #12972.

Change-Id: Id0611667e6149753c351c0c5e01211340a87d3fd
Reviewed-on: https://go-review.googlesource.com/17230
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-03 14:54:24 +00:00
Russ Cox
92b02e3131 encoding/xml: document new chardata tag
Followup to CL 16047.
For #12963.

Change-Id: I596cd5109b25a4079b966427411860fde8b9b54a
Reviewed-on: https://go-review.googlesource.com/17232
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-03 14:47:57 +00:00
Austin Clements
bb6fb929d6 runtime: fix sanity check in stackBarrier
stackBarrier on amd64 sanity checks that it's unwinding the correct
entry in the stack barrier array. However, this check is wrong in two
ways that make it unlikely to catch anything, right or wrong:

1) It checks that savedLRPtr == SP, but, in fact, it should be that
   savedLRPtr+8 == SP because the RET that returned to stackBarrier
   popped the saved LR. However, we didn't notice this check was wrong
   because,

2) the sense of the conditional branch is also wrong.

Fix both of these.

Change-Id: I38ba1f652b0168b5b2c11b81637656241262af7c
Reviewed-on: https://go-review.googlesource.com/17039
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-03 03:53:35 +00:00
Shenghou Ma
08b80ca880 runtime: note interactions between GC and MemProfile
Change-Id: Icce28fc4937cc73c0712c054161222f034381c2f
Reviewed-on: https://go-review.googlesource.com/16876
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-12-03 02:11:52 +00:00
Alex Brainman
92cc3c4e76 net: return rooted DNS names on windows
This CL also changes windows LookupSRV to return
_xmpp-server._tcp.google.com. as cname instead of google.com
similar to linux. Otherwise TestLookupDots still fails.

Updates #12193 (with plan9 still to do)

Change-Id: Id225e15bee95037cdb4226803506cce690c5d341
Reviewed-on: https://go-review.googlesource.com/13887
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 01:44:43 +00:00
Rahul Chaudhry
3afee4380b os: skip TestHardLink on Android.
From Android release M (Marshmallow), hard linking files is blocked
and an attempt to call link() on a file will return EACCES.
- https://code.google.com/p/android-developer-preview/issues/detail?id=3150

Change-Id: Ifdadaa31e3d5ee330553f45db6c001897dc955be
Reviewed-on: https://go-review.googlesource.com/17339
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 01:24:13 +00:00
Alexandre Cesaro
69c09afb0d net/mail: add test index to error messages in a recent test
Add the test index so it is easier to find which test case failed.

Change-Id: Ic04682651b26b137355950ff0c51bdbdb1d85a9c
Reviewed-on: https://go-review.googlesource.com/17351
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 22:41:51 +00:00
Rahul Chaudhry
e65db59c12 cmd/go: allow buildmode=c-shared for android/arm64.
Also, enable test misc/cgo/testcshared for android/arm64.
c/17245 and c/17246 provide the missing pieces for making
this test work.

"androidtest.bash" now passes on a Nexus 9 (volantis)
device running Android build "LMY48T".

Change-Id: Icb9fd2d17d97e0f04cb18d0cd91640c80fbd3fb4
Reviewed-on: https://go-review.googlesource.com/17333
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-02 22:00:15 +00:00
Rahul Chaudhry
c091d4cd25 runtime: set TLSG_IS_VARIABLE for android/arm64.
On android, runtime.tls_g is a normal variable.
TLS offset is computed in x_cgo_inittls.

Change-Id: I18bc9a736d5fb2a89d0f798956c754e3c10d10e2
Reviewed-on: https://go-review.googlesource.com/17246
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-02 22:00:04 +00:00
Rahul Chaudhry
4480d6a927 runtime/cgo: define x_cgo_inittls() for android/arm64.
On android, runtime.tls_g is a normal variable.
TLS offset is computed in x_cgo_inittls.

Change-Id: I64cfd3543040776dcdf73cad8dba54fc6aaf6f35
Reviewed-on: https://go-review.googlesource.com/17245
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-12-02 21:59:52 +00:00
Michael Hudson-Doyle
3a1bed82a6 cmd/internal/obj: fix stack barriers in ppc64le shared libs
runtime.stackBarrier is a strange function: it is only ever "called" by
smashing its address into a LR slot on the stack. Calling it like this
certainly does not adhere to the rule that r12 is set to the global entry point
before calling it and the prologue instrutions that compute r2 from r12 in fact
just corrupt r2, which is bad because the function that stackBarrier returns to
probably uses r2 to access global data.

Fortunately stackBarrier itself does not access any global data and so does not
depend on the value of r2, meaning we can ignore the ABI rules and simply skip
inserting the prologue instructions into this specific function.

Fixes 64bit.go, append.go and fixedbugs/issue13169.go from "cd test; go run
run.go -linkshared".

Change-Id: I606864133a83935899398e2d42edd08a946aab24
Reviewed-on: https://go-review.googlesource.com/17281
Reviewed-by: Austin Clements <austin@google.com>
2015-12-02 21:15:37 +00:00
Ian Lance Taylor
5a049aa4a6 cmd/cgo: error, not panic, if not enough arguments to function
Fixes #13423.

Change-Id: I41bb45790cca36c57a107796f0eca61287acb2a9
Reviewed-on: https://go-review.googlesource.com/17332
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 21:02:28 +00:00
Håvard Haugen
8a34cf7ee0 cmd/compile: don't allow blank method declarations on builtins
Move test for isblank into addmethod so that most of the type checking
for methods is also performed for blank methods.

Fixes #11366.

Change-Id: I13d554723bf96d906d0b3ff390d7b7c87c1a5020
Reviewed-on: https://go-review.googlesource.com/16866
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-02 18:26:38 +00:00
INADA Naoki
0c516c1632 database/sql: Add DB.SetConnMaxLifetime
Long lived connections may make some DB operation difficult.
(e.g. retiring load balanced DB server.)
So SetConnMaxLifetime closes long lived connections.

It can be used to limit maximum idle time, too.
Closing idle connections reduces active connections while application is idle
and avoids connections are closed by server side (cause errBadConn while querying).

fixes #9851

Change-Id: I2e8e824219c1bee7f4b885d38ed96d11b7202b56
Reviewed-on: https://go-review.googlesource.com/6580
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 17:38:31 +00:00
Alexandre Cesaro
2cb265d16c net/mail: use base64 encoding when needed in Address.String()
When the name of an Address contains non-ASCII characters,
Address.String() used mime.QEncoding to encode the name.

However certain characters are forbidden when an encoded-word is
in a phrase context (see RFC 2047 section 5.3) and these
characters are not encoded by mime.QEncoding.

In this case we now use mime.BEncoding (base64 encoding) so that
forbidden characters are also encoded.

Fixes #11292

Change-Id: I52db98b41ece439295e97d7e94c8190426f499c2
Reviewed-on: https://go-review.googlesource.com/16012
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 17:37:36 +00:00
Ian Lance Taylor
b64b3a7713 cmd/go: fix reading PT_NOTE segment with multiple notes
The old code was assuming that a PT_NOTE segment never had more than one
note, but there is no such requirement.

Fixes #13364.

Change-Id: I3f6b3716130bf7af6abe81b8e10571a8c7cd943c
Reviewed-on: https://go-review.googlesource.com/17331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-02 17:21:44 +00:00
Joe Tsai
0ea1c1f671 compress/bzip2/testdata: make Mark.Twain-Tom.Sawyer.txt free
Commit 7a1fb95d50 strips non-free license
from Mark.Twain-Tom.Sawyer.txt, but forgot to remove it from the compressed
version of the file.

Update #13216

Change-Id: I60f53275d56ba5baa6898db47b1d41f85e985c00
Reviewed-on: https://go-review.googlesource.com/17264
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 02:40:38 +00:00
Joe Tsai
b8a12928a6 archive/tar: convert Reader.Next to be loop based
Motivation for change:
* Recursive logic is hard to follow, since it tends to apply
things in reverse. On the other hand, the tar formats tend to
describe meta headers as affecting the next entry.
* Recursion also applies changes in the wrong order. Two test
files are attached that use multiple headers. The previous Go
behavior differs from what GNU and BSD tar do.

Change-Id: Ic1557256fc1363c5cb26570e5d0b9f65a9e57341
Reviewed-on: https://go-review.googlesource.com/14624
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 02:27:27 +00:00
Brad Fitzpatrick
9bad99574a net/http: enable HTTP/2 on all Transports, not just the DefaultTransport
This mirrors the same behavior and API from the server code to the
client side: if TLSNextProto is nil, HTTP/2 is on by default for
both. If it's non-nil, the user was trying to do something fancy and
step out of their way.

Updates #6891

Change-Id: Ia31808b71f336a8d5b44b985591d72113429e1d4
Reviewed-on: https://go-review.googlesource.com/17300
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 02:03:19 +00:00
Ian Lance Taylor
3b3f422afe time: fix handling of -07, handle Z07
The existing code has partial support for -07 (just the hours of a time
zone offset).  Complete the support, add support for Z07, and add a few
tests.

Fixes #13426.

Change-Id: Ic6377bbf3e65b4bb761b9779f7e80c07ce4f57e8
Reviewed-on: https://go-review.googlesource.com/17260
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 01:35:09 +00:00
Joe Tsai
38f8e4407c archive/tar: move parse/format methods to standalone receiver
Motivations for this change:
* It allows these functions to be used outside of Reader/Writer.
* It allows these functions to be more easily unit tested.

Change-Id: Iebe2b70bdb8744371c9ffa87c24316cbbf025b59
Reviewed-on: https://go-review.googlesource.com/15113
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 00:29:33 +00:00
Ingo Oeser
a4f057bcc3 net/mail: better errors on non-ascii characters
Fixes #12492

Change-Id: I8bb512027639301e2f2c41aab84e6d06ae88b137
Reviewed-on: https://go-review.googlesource.com/14312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 00:25:15 +00:00
Benjamin Prosnitz
e614d60759 net: fall back to hosts file if DNS lookup fails, despite order
Fixes #13090

Change-Id: I5612d792dabdff89bd0cec57dc2cacf9be7ebf64
Reviewed-on: https://go-review.googlesource.com/16341
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 00:15:41 +00:00
Russ Cox
e4e4942387 encoding/base64: add package-level example
Fixes #13011.

Change-Id: Ia4c67880fca83f4298ff6bb1b217ec26c8c83427
Reviewed-on: https://go-review.googlesource.com/17231
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 23:12:09 +00:00
Russ Cox
0680e9c0c1 regexp/syntax: fix handling of \Q...\E
It's not a group: must handle the inside as a sequence of literal chars,
not a single literal string.

That is, \Qab\E+ is the same as ab+, not (ab)+.

Fixes #11187.

Change-Id: I5406d05ccf7efff3a7f15395bdb0cfb2bd23a8ed
Reviewed-on: https://go-review.googlesource.com/17233
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 22:45:12 +00:00
Carlos Cirello
5fc583854f net/http/httputil: add package level examples
Change-Id: I5be18b68602a7ebb740cf05924236ce17e386e55
Reviewed-on: https://go-review.googlesource.com/17295
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 22:25:52 +00:00
Russ Cox
e2071ecd08 testing: document that T and B are safe for concurrent calls
Fixes #13108.

Change-Id: I474cc2a3b7ced1c9eb978fc815f9c6bae9fb3ecc
Reviewed-on: https://go-review.googlesource.com/17235
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-01 22:01:26 +00:00
Blake Gentry
5dd372bd1e net/http: retry idempotent HTTP reqs on dead reused conns
If we try to reuse a connection that the server is in the process of
closing, we may end up successfully writing out our request (or a
portion of our request) only to find a connection error when we try to
read from (or finish writing to) the socket. This manifests as an EOF
returned from the Transport's RoundTrip.

The issue, among others, is described in #4677.

This change follows some of the Chromium guidelines for retrying
idempotent requests only when the connection has been already been used
successfully and no header data has yet been received for the response.

As part of this change, an unexported error was defined for
errMissingHost, which was previously defined inline. errMissingHost is
the only non-network error returned from a Request's Write() method.

Additionally, this breaks TestLinuxSendfile because its test server
explicitly triggers the type of scenario this change is meant to retry
on. Because that test server stops accepting conns on the test listener
before the retry, the test would time out. To fix this, the test was
altered to use a non-idempotent test type (POST).

Change-Id: I1ca630b944f0ed7ec1d3d46056a50fb959481a16
Reviewed-on: https://go-review.googlesource.com/3210
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 20:40:31 +00:00
David Benjamin
7c20ea9311 encoding/asn1: Reject invalid INTEGERs.
The empty string is not a valid DER integer. DER also requires that values be
minimally-encoded, so excess padding with leading 0s (0xff for negative
numbers) is forbidden. (These rules also apply to BER, incidentally.)

Fixes #12622.

Change-Id: I041f94e34a8afa29dbf94dd8fc450944bc91c9c3
Reviewed-on: https://go-review.googlesource.com/17008
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 20:40:17 +00:00
Joe Tsai
7823197e5d archive/tar: fix issues with readGNUSparseMap1x0
Motivations:
* Use of strconv.ParseInt does not properly treat integers as 64bit,
preventing this function from working properly on 32bit machines.
* Use of io.ReadFull does not properly detect truncated streams
when the file suddenly ends on a block boundary.
* The function blindly trusts user input for numEntries and allocates
memory accordingly.
* The function does not validate that numEntries is not negative,
allowing a malicious sparse file to cause a panic during make.

In general, this function was overly complicated for what it was
accomplishing and it was hard to reason that it was free from
bounds errors. Instead, it has been rewritten and relies on
bytes.Buffer.ReadString to do the main work. So long as invariants
about the number of '\n' in the buffer are maintained, it is much
easier to see why this approach is correct.

Change-Id: Ibb12c4126c26e0ea460ea063cd17af68e3cf609e
Reviewed-on: https://go-review.googlesource.com/15174
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 20:22:38 +00:00
Joe Tsai
dd5e14a751 archive/tar: properly handle header-only "files" in Reader
Certain special type-flags, specifically 1, 2, 3, 4, 5, 6,
do not have a data section. Thus, regardless of what the size field
says, we should not attempt to read any data for these special types.

The relevant PAX and USTAR specification says:
<<<
If the typeflag field is set to specify a file to be of type 1 (a link)
or 2 (a symbolic link), the size field shall be specified as zero.
If the typeflag field is set to specify a file of type 5 (directory),
the size field shall be interpreted as described under the definition
of that record type. No data logical records are stored for types 1, 2, or 5.
If the typeflag field is set to 3 (character special file),
4 (block special file), or 6 (FIFO), the meaning of the size field is
unspecified by this volume of POSIX.1-2008, and no data logical records shall
be stored on the medium.
Additionally, for type 6, the size field shall be ignored when reading.
If the typeflag field is set to any other value, the number of logical
records written following the header shall be (size+511)/512, ignoring
any fraction in the result of the division.
>>>

Contrary to the specification, we do not assert that the size field
is zero for type 1 and 2 since we liberally accept non-conforming formats.

Change-Id: I666b601597cb9d7a50caa081813d90ca9cfc52ed
Reviewed-on: https://go-review.googlesource.com/16614
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 20:16:26 +00:00
Russ Cox
829425d3ce bufio: clarify Read docs
Or at least make them true.

Fixes #12237.

Change-Id: I3c92a07233b2174c5731d6fa7fbb9ca3a97beb6b
Reviewed-on: https://go-review.googlesource.com/17237
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 20:05:25 +00:00
Colin Cross
46300a058d archive/zip: enable overriding (de)compressors per file
Implement setting the compression level for a zip archive by registering
a per-Writer compressor through Writer.RegisterCompressor.  If no
compressors are registered, fall back to the ones registered at the
package level.  Also implements per-Reader decompressors.

Fixes #8359

Change-Id: I93b27c81947b0f817b42e0067aa610ff267fdb21
Reviewed-on: https://go-review.googlesource.com/16669
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Klaus Post <klauspost@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 20:04:20 +00:00
Aleksandr Demakin
a4cd0a49c7 go/types: fix race-y initialization of Struct.offsets
Use sync.Once to ensure, that 'offsets' field is initialized
once only in a threadsafe way.

Fixes #12887

Change-Id: I90ef929c421ccd3094339c67a39b02d8f2e47211
Reviewed-on: https://go-review.googlesource.com/16013
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-12-01 19:22:19 +00:00
Brad Fitzpatrick
5ff309f48d mime: let FormatMediaType format slash-less media types, to mirror ParseMediaType.
A Content-Type always has a slash (type/subtype)
A Content-Disposition does not (e.g. "attachment" or "line").
A "media type" is either one of those, plus optional parameters afterwards.

Our ParseMediaType and FormatMediaType weren't consistent in whether
they permitted Content-Dispositions. Now they both do.

Fixes #11289

Change-Id: Ia75723c9d7adb7f4de0f65482780f823cdadb5bd
Reviewed-on: https://go-review.googlesource.com/17135
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 16:29:28 +00:00
Brad Fitzpatrick
a3f99dc4e9 mime: don't accept single-quoted strings in media type parameter values
Fix an old bug where media type parameter values could be escaped by
either double quotes (per the spec) or single quotes (due to my bug).

The original bug was introduced by me in git rev 90e4ece3
(https://golang.org/cl/4430049) in April 2011 when adding more tests
from http://greenbytes.de/tech/tc2231/ and misinterpreting the
expected value of test "attwithfntokensq" and not apparently thinking
about it enough.

No known spec or existing software produces or expects single quotes
around values. In fact, it would have be a parsing ambiguity if it
were allowed: the string `a=', b='` could parse as two keys "a" and
"b" both with value "'", or it could be parse as a single key "a" with
value "', b=".

Fixes #11291

Change-Id: I6de58009dd47dcabb120b017245d237cb7b1e89a
Reviewed-on: https://go-review.googlesource.com/17136
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-01 16:29:07 +00:00
Marcel van Lohuizen
1dae47378c unicode/utf8: add test for FullRune
Check that it now properly handles \xC0 and \xC1.

Fixes #11733.

Change-Id: I66cfe0d43f9d123d4c4509a3fa18b9b6380dfc39
Reviewed-on: https://go-review.googlesource.com/17225
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-01 10:39:06 +00:00
Michael Hudson-Doyle
f000523018 runtime: set r12 to sigpanic before jumping to it in sighandler
The ppc64le shared library ABI demands that r12 is set to a function's global
entrypoint before jumping to the global entrypoint. Not doing so means that
handling signals that usually panic actually crashes (and so, e.g. can't be
recovered). Fixes several failures of "cd test; go run run.go -linkshared".

Change-Id: Ia4d0da4c13efda68340d38c045a52b37c2f90796
Reviewed-on: https://go-review.googlesource.com/17280
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-01 04:51:35 +00:00
Robert Griesemer
06f4cbd3d7 cmd/compile: remove unused global variable loophack
Old parser remains.

Change-Id: I05ef1737802e23afc2c2129f58cb66feef8e3425
Reviewed-on: https://go-review.googlesource.com/17244
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-30 22:23:58 +00:00
Robert Griesemer
8ae423ef84 cmd/compile: document parsing decision for imported interfaces
Fixes #13245.

Change-Id: I87be63cc7b27f70ca2f9fb6bc9908b9061fe3d9d
Reviewed-on: https://go-review.googlesource.com/17203
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-30 22:23:34 +00:00
Brad Fitzpatrick
ccdcd6e903 net/http: update h2_bundle.go
Updates to x/net rev 195180cf
(golang.org/cl/17134, http2: merge duplicate Transport dials)

Change-Id: I50b9c73b30c6a21e725aad80126b713d8b0fa362
Reviewed-on: https://go-review.googlesource.com/17261
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30 20:48:24 +00:00
Burcu Dogan
afc2c45f05 net/http: define File as an io.Seeker
Fixes #13421.

Change-Id: Ic0fc0d0a8e86d2be23db12ddd1a8a8105e26ee56
Reviewed-on: https://go-review.googlesource.com/17250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30 20:43:39 +00:00
Carlos C
b9b6e86c79 io/ioutil: add examples to functions
Change-Id: Ica0cf1ba01ba73bd7e2fe38d653503738a962720
Reviewed-on: https://go-review.googlesource.com/13450
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30 19:47:18 +00:00
Carlos C
11b3dfd286 io: add examples to functions
Change-Id: Id72cf4daceb7669cf9c7247df8e3ba086ccfe96e
Reviewed-on: https://go-review.googlesource.com/12730
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-30 17:09:33 +00:00
Mikio Hara
175bfda49f net: fix typo in test
Change-Id: Ibc55e98c43cebe5a21ab3b280489e1bce6405b8b
Reviewed-on: https://go-review.googlesource.com/17218
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-29 22:06:08 +00:00
Ian Lance Taylor
f3b064ae01 cmd/compile: add 386 special case for testing first field of struct variable
This is the 386 version of the amd64-specific https://golang.org/cl/16933.

Update #12416.

Change-Id: Ibc3a99dcc753d6281839d8b61016d6c21dbd9649
Reviewed-on: https://go-review.googlesource.com/16970
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-29 16:56:03 +00:00
Ian Lance Taylor
17360accab cmd/cgo: make the char * pointer in GoString const
This makes it more convenient for C code to use GoString with string
constants.  Since Go string values are immutable, the const qualifier is
appropriate in C.

Change-Id: I5fb3cdce2ce5079f1f0467a1544bb3a1eb27b811
Reviewed-on: https://go-review.googlesource.com/17067
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-29 16:55:40 +00:00
Mikio Hara
4d6a69f227 net: force LookupAddr results to be rooted DNS paths even in the case of local source
The builtin name resolver using various resolution techniques is a bit
complicated and we sometimes fotget to take care of all the go and cgo
code paths and exchanging information to local and remote sources. This
change makes LookupAddr return absolute domain names even in the case of
local source.

Updates #12189.
Fixes #12240.

Change-Id: Icdd3375bcddc7f5d4d3b24f134d93815073736fc
Reviewed-on: https://go-review.googlesource.com/17216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 08:43:55 +00:00
Shenghou Ma
a0233fdbda path: fix typo
Fixes #13419.

Change-Id: I530d0b714ea0743c72eacd07b390c3f8cc556e21
Reviewed-on: https://go-review.googlesource.com/17239
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-28 05:54:25 +00:00
Robert Griesemer
de531fc255 cmd/compile: remove gratuituous type conversions
Follow-up cleanup for https://go-review.googlesource.com/17248:
Use properly typed local variable op now that that variable use
is not overloaded anymore.

Also: Remove unnecessary if stmt from common lexical path.

Change-Id: I984b0b346f3fdccd5aedc937330c0a5f99acf324
Reviewed-on: https://go-review.googlesource.com/17249
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 03:36:21 +00:00
Robert Griesemer
e18cd34c76 cmd/compile: use correct line number for := (LCOLAS)
- use same local variable name (lno) for line number for LCOLAS everywhere
- remove now unneeded assignment of line number to yylval.i in lexer

Fix per suggestion of mdempsky.

Fixes #13415.

Change-Id: Ie3c7f5681615042a12b81b26724b3a5d8a979c25
Reviewed-on: https://go-review.googlesource.com/17248
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 03:36:00 +00:00
Adam Langley
a0ea93dea5 crypto/x509: permit serial numbers to be negative.
Some software that produces certificates doesn't encode integers
correctly and, about half the time, ends up producing certificates with
serial numbers that are actually negative.

This buggy software, sadly, appears to be common enough that we should
let these errors pass. This change allows a Certificate.SerialNumber to
be negative.

Fixes #8265.

Change-Id: Ief35dae23988fb6d5e2873e3c521366fb03c6af4
Reviewed-on: https://go-review.googlesource.com/17247
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 00:07:16 +00:00
Mikio Hara
85bfa33fdc net: fix case insensitivity lookup for local database such as /etc/hosts
The previous change for #12806 modified internal lookup tables and made
LookupAddr return forcibly lowercased host names by accident.

This change fixes the issue again without any behavioral change for
LookupAddr and adds missing test cases for lookupStaticHost and
lookupStaticAddr.

Updates #12806.
Fixes #13359.

Change-Id: Ifff4741cd79eb8b320b1b0f8c5e02b3a167c9fa8
Reviewed-on: https://go-review.googlesource.com/17217
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-27 22:52:14 +00:00
Shenghou Ma
98abf2937e cmd/cover: allow part selection to be retained across page refreshes
Usually, you are primarily interested to see the coverage of a particular
file (e.g. when you're changing tests that affects a given source file),
it is very valuable if you can just refresh the page and immediately see
changes to the part you're already looking at (without selecting from the
selector again.)

Change-Id: I615207c9be6713f436e444771134fceaf4600ff3
Reviewed-on: https://go-review.googlesource.com/17238
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-27 06:13:12 +00:00
Tamir Duberstein
adf4c38b6e cmd/yacc: memory allocation improvements
Places a fixed size initial stack and the lval inside the parser
struct so that they are allocated together. Places $$char inside the
parser struct to avoid allocating the closure used in Lookahead().

Change-Id: I0de664a6d612279fdc3255633e2dff904030bc36
Reviewed-on: https://go-review.googlesource.com/16705
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 17:42:14 +00:00
Ralph Corderoy
db4ef216cc crypto/tls: Server can specify an unadvertised cipher suite
During the TLS handshake, check the cipher suite the server selects is
one of those offered in the ClientHello.  The code was checking it was
in the larger list that was sometimes whittled down for the ClientHello.

Fixes #13174

Change-Id: Iad8eebbcfa5027f30403b9700c43cfa949e135bb
Reviewed-on: https://go-review.googlesource.com/16698
Reviewed-by: Adam Langley <agl@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 17:22:57 +00:00
Joe Tsai
b717090e01 compress/flate: tweak offsetCode so that it can be inlined
Functions with switches (#13071) cannot be inlined.
Functions with consts (#7655) cannot be inlined.

benchmark                              old MB/s     new MB/s     speedup
BenchmarkEncodeDigitsSpeed1e4-4        10.25        10.20        1.00x
BenchmarkEncodeDigitsSpeed1e5-4        26.44        27.22        1.03x
BenchmarkEncodeDigitsSpeed1e6-4        32.28        33.51        1.04x
BenchmarkEncodeDigitsDefault1e4-4      8.61         8.74         1.02x
BenchmarkEncodeDigitsDefault1e5-4      7.03         6.98         0.99x
BenchmarkEncodeDigitsDefault1e6-4      6.47         6.46         1.00x
BenchmarkEncodeDigitsCompress1e4-4     8.62         8.73         1.01x
BenchmarkEncodeDigitsCompress1e5-4     7.01         6.98         1.00x
BenchmarkEncodeDigitsCompress1e6-4     6.43         6.53         1.02x
BenchmarkEncodeTwainSpeed1e4-4         9.67         10.16        1.05x
BenchmarkEncodeTwainSpeed1e5-4         26.46        26.94        1.02x
BenchmarkEncodeTwainSpeed1e6-4         33.19        34.02        1.03x
BenchmarkEncodeTwainDefault1e4-4       8.12         8.37         1.03x
BenchmarkEncodeTwainDefault1e5-4       8.22         8.21         1.00x
BenchmarkEncodeTwainDefault1e6-4       8.10         8.13         1.00x
BenchmarkEncodeTwainCompress1e4-4      8.24         8.39         1.02x
BenchmarkEncodeTwainCompress1e5-4      6.51         6.58         1.01x
BenchmarkEncodeTwainCompress1e6-4      6.16         6.13         1.00x

Change-Id: Ibafa5e3e2de0529853b5b3180e6fd6cb7090b76f
Reviewed-on: https://go-review.googlesource.com/17171
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 17:20:34 +00:00
Brad Fitzpatrick
e91019d253 net/http: add test that automatic gzip works for HTTP2's Transport
And updates h2_bundle.go with the fix from x/net/http2.

Fixes #13298
Updates #6891

Change-Id: Ia25f22fa10e2a64b9d59211269882681aa18c101
Reviewed-on: https://go-review.googlesource.com/17241
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-26 17:15:22 +00:00
Didier Spezia
8818cc8885 go/build: fix cgo ${SRCDIR} substitution when that variable contains spaces
When the source directory path contains spaces, cgo directives
cannot be properly validated:

$ pwd
/root/src/issue 11868

$ cat main.go
package main
//#cgo CFLAGS: -I${SRCDIR}/../../include
import "C"
func main() {
}

$ go build
can't load package: package issue 11868: /root/src/issue 11868/main.go:
 malformed #cgo argument: -I/root/src/issue 11868/../../include

Make sure spaces are tolerated in ${SRCDIR} when this variable
is expanded. This applies to ${SRCDIR} only. Shell safety
checks are still done in the same exact way for anything else.

Fixes #11868

Change-Id: I93d1d2b5ab167caa7ae353fe46fb8f69f1f06969
Reviewed-on: https://go-review.googlesource.com/16302
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 17:08:14 +00:00
Dmitry Vyukov
7b767f4e52 internal/race: add package
Factor out duplicated race thunks from sync, syscall net
and fmt packages into a separate package and use it.

Fixes #8593

Change-Id: I156869c50946277809f6b509463752e7f7d28cdb
Reviewed-on: https://go-review.googlesource.com/14870
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-26 16:50:31 +00:00
sergey.arseev
e9081b3c76 cmd/internal/obj/x86: add support for TSX instructions
Transactional memory, will later be used for semaphore implementation.
Nacl not supported yet.

Change-Id: Ic18453dcaa08d07bb217c0b95461584f007d518b
Reviewed-on: https://go-review.googlesource.com/16479
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-26 16:39:00 +00:00
Michael Hudson-Doyle
21efa7b2bc syscall: skip tests that create a user namespace when chrooted
The kernel rejects attempts to create user namespaces when in a chroot.

Change-Id: I6548302732c8f5be52f4167cd7233aea16839ad8
Reviewed-on: https://go-review.googlesource.com/17214
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 23:31:47 +00:00
Matthew Dempsky
10cb39afc4 cmd/cgo: fix C.complexfloat and C.complexdouble
This also fixes an unintended behavior where C's "complex float" and
"complex double" types were interchangeable with Go's "complex64" and
"complex128" types.

Fixes #13402.

Change-Id: I73f96d9a4772088d495073783c6982e9634430e8
Reviewed-on: https://go-review.googlesource.com/17208
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-25 23:06:59 +00:00
Matthew Dempsky
de640d369d cmd/cgo: handle another Clang DWARF quirk
Without the fix:

    $ CC=clang-3.5 ./test.bash
    misc/cgo/errors/test.bash: BUG: expected error output to contain "C.ushort" but saw:
    # command-line-arguments
    ./issue13129.go:13: cannot use int(0) (type int) as type C.unsignedshort in assignment

Fixes #13129.

Change-Id: I2c019d2d000f5bfa3e33c477e533aff97031a84f
Reviewed-on: https://go-review.googlesource.com/17207
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 21:13:41 +00:00
Robert Griesemer
c7a3403140 cmd/compile: clearer error for invalid array/slice literal elements
Fixes #13365.

Change-Id: I5a447ff806dbbb11c8c75e2b5cfa7fd4a845fb92
Reviewed-on: https://go-review.googlesource.com/17206
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 19:49:38 +00:00
Caleb Spare
e36bf614c8 regexp: fix one-pass compilation
The one-pass transformation is structured as a search over the input
machine for conditions that violate the one-pass requisites. At each
iteration, we should fully explore all non-input paths that proceed from
the current instruction; this is implemented via recursive check calls.
But when we reach instructions that demand input (InstRune*), these
should be put onto the search queue.

Instead of searching this way, the routine previously (effectively)
proceeded through the machine one instruction at a time until finding an
Inst{Match,Fail,Rune*}, calling check on each instruction. This caused
bug #11905, where the transformation stopped before rewriting all
InstAlts as InstAltMatches.

Further, the check function unnecessarily recurred on InstRune*
instructions. (I believe this helps to mask the above bug.)

This change also deletes some unused functions and duplicate test cases.

Fixes #11905.

Change-Id: I5b0b26efea3d3bd01c7479a518b5ed1b886701cd
Reviewed-on: https://go-review.googlesource.com/17195
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:44:17 +00:00
Caleb Spare
d1eedfe132 regexp: fix LiteralPrefix for certain onepass progs
The prefix computation for onepass was incorrectly returning
complete=true when it encountered a beginning-of-text empty width match
(^) in the middle of an expression.

Fix by returning complete only when the prefix is followed by $ and then
an accepting state.

Fixes #11175.

Change-Id: Ie9c4cf5f76c1d2c904a6fb2f016cedb265c19fde
Reviewed-on: https://go-review.googlesource.com/16200
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:28:33 +00:00
Caleb Spare
937172b247 regexp: add Copy method to Regexp
This helps users who wish to use separate Regexps in each goroutine to
avoid lock contention. Previously they had to parse the expression
multiple times to achieve this.

I used variants of the included benchmark to evaluate this change. I
used the arguments -benchtime 20s -cpu 1,2,4,8,16 on a machine with 16
hardware cores.

Comparing a single shared Regexp vs. copied Regexps, we can see that
lock contention causes huge slowdowns at higher levels of parallelism.
The copied version shows the expected linear speedup.

name              old time/op  new time/op  delta
MatchParallel      366ns ± 0%   370ns ± 0%   +1.09%   (p=0.000 n=10+8)
MatchParallel-2    324ns ±28%   184ns ± 1%  -43.37%  (p=0.000 n=10+10)
MatchParallel-4    352ns ± 5%    93ns ± 1%  -73.70%   (p=0.000 n=9+10)
MatchParallel-8    480ns ± 3%    46ns ± 0%  -90.33%    (p=0.000 n=9+8)
MatchParallel-16   510ns ± 8%    24ns ± 6%  -95.36%   (p=0.000 n=10+8)

I also compared a modified version of Regexp that has no mutex and a
single machine (the "RegexpForSingleGoroutine" rsc mentioned in
https://github.com/golang/go/issues/8232#issuecomment-66096128).

In this next test, I compared using N copied Regexps vs. N separate
RegexpForSingleGoroutines. This shows that, even for this relatively
simple regex, avoiding the lock entirely would only buy about 10-12%
further improvement.

name              old time/op  new time/op  delta
MatchParallel      370ns ± 0%   322ns ± 0%  -12.97%    (p=0.000 n=8+8)
MatchParallel-2    184ns ± 1%   162ns ± 1%  -11.60%  (p=0.000 n=10+10)
MatchParallel-4   92.7ns ± 1%  81.1ns ± 2%  -12.43%  (p=0.000 n=10+10)
MatchParallel-8   46.4ns ± 0%  41.8ns ±10%   -9.78%   (p=0.000 n=8+10)
MatchParallel-16  23.7ns ± 6%  20.6ns ± 1%  -13.14%    (p=0.000 n=8+8)

Updates #8232.

Change-Id: I15201a080c363d1b44104eafed46d8df5e311902
Reviewed-on: https://go-review.googlesource.com/16110
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:26:37 +00:00
Tamir Duberstein
3aa755b8fb regexp/syntax: correctly print ^ BOL and $ EOL
Fixes #12980.

Change-Id: I936db2f57f7c4dc80bb8ec32715c4c6b7bf0d708
Reviewed-on: https://go-review.googlesource.com/16112
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:25:22 +00:00
Giulio Iotti
0b55be1ba2 encoding/xml: case-insensitive encoding recognition
From the XML spec: "XML processors should match character encoding
names in a case-insensitive way"

Fixes #12417.

Change-Id: I678c50152a49c14364be62b3f21ab9b9b009b24b
Reviewed-on: https://go-review.googlesource.com/14084
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:09:28 +00:00
Michal Bohuslávek
97c859f8da encoding/xml: reject invalid comments
Fixes #11112.

Change-Id: I16e7363549a0dec8c61addfa14af0866c1fd7c40
Reviewed-on: https://go-review.googlesource.com/14173
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:08:38 +00:00
Charles Weill
3f6b91b113 encoding/xml: Add CDATA-wrapper output support to xml.Marshal.
Fixes #12963

Change-Id: Icc50dfb6130fe1e189d45f923c2f7408d3cf9401
Reviewed-on: https://go-review.googlesource.com/16047
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:04:43 +00:00
Aliaksandr Valialkin
a48de745b2 encoding/gob: reduce the amount of memory allocations.
Benchmark results:

benchmark                              old ns/op     new ns/op     delta
BenchmarkEndToEndPipe-4                7547          7294          -3.35%
BenchmarkEndToEndByteBuffer-4          5146          5092          -1.05%
BenchmarkEndToEndSliceByteBuffer-4     552779        439768        -20.44%
BenchmarkEncodeComplex128Slice-4       266370        266184        -0.07%
BenchmarkEncodeFloat64Slice-4          111891        110258        -1.46%
BenchmarkEncodeInt32Slice-4            74482         74080         -0.54%
BenchmarkEncodeStringSlice-4           84404         84279         -0.15%
BenchmarkEncodeInterfaceSlice-4        3942925       3045995       -22.75%
BenchmarkDecodeComplex128Slice-4       451837        415282        -8.09%
BenchmarkDecodeFloat64Slice-4          283584        262558        -7.41%
BenchmarkDecodeInt32Slice-4            246571        237383        -3.73%
BenchmarkDecodeStringSlice-4           734210        479625        -34.67%
BenchmarkDecodeInterfaceSlice-4        4778225       4160935       -12.92%

benchmark                              old allocs     new allocs     delta
BenchmarkEndToEndPipe-4                3              2              -33.33%
BenchmarkEndToEndByteBuffer-4          3              2              -33.33%
BenchmarkEndToEndSliceByteBuffer-4     1002           402            -59.88%
BenchmarkEncodeComplex128Slice-4       1              1              +0.00%
BenchmarkEncodeFloat64Slice-4          1              1              +0.00%
BenchmarkEncodeInt32Slice-4            1              1              +0.00%
BenchmarkEncodeStringSlice-4           1              1              +0.00%
BenchmarkEncodeInterfaceSlice-4        3001           1              -99.97%
BenchmarkDecodeComplex128Slice-4       188            185            -1.60%
BenchmarkDecodeFloat64Slice-4          188            185            -1.60%
BenchmarkDecodeInt32Slice-4            188            185            -1.60%
BenchmarkDecodeStringSlice-4           2188           1185           -45.84%
BenchmarkDecodeInterfaceSlice-4        6197           4194           -32.32%

benchmark                              old bytes     new bytes     delta
BenchmarkEndToEndPipe-4                64            48            -25.00%
BenchmarkEndToEndByteBuffer-4          64            48            -25.00%
BenchmarkEndToEndSliceByteBuffer-4     34551         10554         -69.45%
BenchmarkEncodeComplex128Slice-4       55            55            +0.00%
BenchmarkEncodeFloat64Slice-4          33            33            +0.00%
BenchmarkEncodeInt32Slice-4            32            32            +0.00%
BenchmarkEncodeStringSlice-4           36            36            +0.00%
BenchmarkEncodeInterfaceSlice-4        144555        347           -99.76%
BenchmarkDecodeComplex128Slice-4       28240         28097         -0.51%
BenchmarkDecodeFloat64Slice-4          11840         11697         -1.21%
BenchmarkDecodeInt32Slice-4            10817         10673         -1.33%
BenchmarkDecodeStringSlice-4           56128         39985         -28.76%
BenchmarkDecodeInterfaceSlice-4        132565        100421        -24.25%

Change-Id: Ief7c7706b1f2916486ab7190b81aafbb16b70f1e
Reviewed-on: https://go-review.googlesource.com/13660
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 17:01:25 +00:00
Erik Dubbelboer
c4be790c0e encoding/json: check if Number is valid
json.Number is a special case which didn't have any checks and could result in invalid JSON.

Fixes #10281

Change-Id: Ie3e726e4d6bf6a6aba535d36f6107013ceac913a
Reviewed-on: https://go-review.googlesource.com/12250
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 16:18:36 +00:00
Joe Tsai
64cc5fd0b3 hash/crc32: add noescape tags to assembly functions
CRC-32 computation is stateless and the p slice does not get stored
anywhere. Thus, we mark the assembly functions as noescape so that
it doesn't believe that p leaks in:
	func Update(crc uint32, tab *Table, p []byte) uint32

Before:
	./crc32.go:153: leaking param: p

After:
	./crc32.go:153: Update p does not escape

Change-Id: I52ba35b6cc544fff724327140e0c27898431d1dc
Reviewed-on: https://go-review.googlesource.com/17069
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-25 15:01:10 +00:00
Brad Fitzpatrick
e5956bca41 net/http: more HTTP/2 tests and fixes
This compares the behavior of server handlers and the net/http
Transport in both HTTP/1 and HTTP/2 mode and verifies they're the
same.

This also moves some client<->server tests into clientserver_test.go.
Many of them were in serve_test.go or transport_test.go but were
basically testing both.

h2_bundle.go is an update of the golang.org/x/net/http2 code
from https://golang.org/cl/17204 (x/net git rev c745c36eab10)

Fixes #13315
Fixes #13316
Fixes #13317
Fixes other stuff found in the process too
Updates #6891 (http2 support in general)

Change-Id: Id9c45fad44cdf70ac95d2b89e578d66e882d3cc2
Reviewed-on: https://go-review.googlesource.com/17205
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-25 05:18:46 +00:00
Michael Hudson-Doyle
fd2bc8681d runtime: fix conflict resolution in golang.org/cl/14207
Fixes testshared on arm64 and ppc64le.

Change-Id: Ie94bc0c85c7666fbb5ab6fc6d3dbb180407a9955
Reviewed-on: https://go-review.googlesource.com/17212
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-25 01:32:55 +00:00
Shenghou Ma
3583a44ed2 runtime: check that masks and shifts are correct aligned
We need a runtime check because the original issue is encountered
when running cross compiled windows program from linux. It's better
to give a meaningful crash message earlier than to segfault later.

The added test should not impose any measurable overhead to Go
programs.

For #12415.

Change-Id: Ib4a24ef560c09c0585b351d62eefd157b6b7f04c
Reviewed-on: https://go-review.googlesource.com/14207
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-25 00:46:57 +00:00
Robert Griesemer
3cac3b5fca cmd/compile: remove references to go.y and update documentation
This is a comment/documentation change only but for a minor
code change in the file and package_ methods (move recognition
of semi to match grammar better).

Per request from r.

Change-Id: I81ec985cc5831074d9eb5e8ffbf7e59466284819
Reviewed-on: https://go-review.googlesource.com/17202
Reviewed-by: Rob Pike <r@golang.org>
2015-11-24 23:53:42 +00:00
Rob Pike
d0351e9666 text/template,html/template: correct comment in DefinedTemplates
The prefix includes a semicolon.

Change-Id: I4bdb79aa9931e835e297f3ea2c46a001cd123d56
Reviewed-on: https://go-review.googlesource.com/17200
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-24 21:52:36 +00:00
Jakub Čajka
7a1fb95d50 compress: make Mark.Twain-Tom.Sawyer.txt licensed under non-free license free again
This change strips non-free license from Mark.Twain-Tom.Sawyer.txt along with all reference to Project Gutenberg in the file and the whole source tree. Making the file public domain again.

Fixes #13216

Change-Id: I2f41b0de225f627dde152efe93c006a4c24be668
Reviewed-on: https://go-review.googlesource.com/17196
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-24 21:50:01 +00:00
Austin Clements
ab9d5f38be runtime: make gcFlushBgCredit go:nowritebarrierrec
Write barriers in gcFlushBgCredit lead to very subtle bugs because it
executes after the getfull barrier. I tracked some bugs of this form
down before go:nowritebarrierrec was implemented. Ensure that they
don't reappear by making gcFlushBgCredit go:nowritebarrierrec.

Change-Id: Ia5ca2dc59e6268bce8d8b4c87055bd0f6e19bed2
Reviewed-on: https://go-review.googlesource.com/17052
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 19:37:03 +00:00
Austin Clements
e126f30a66 runtime: recursively disallow write barriers in sighandler
sighandler may run during STW, so write barriers are not allowed.

Change-Id: Icdf46be10ea296fd87e73ab56ebb718c5d3c97ac
Reviewed-on: https://go-review.googlesource.com/17007
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 19:36:55 +00:00
Rob Pike
b790ad5ac0 encoding/gob: document that zero elements of arrays and slices are sent
Fixes #13378

Change-Id: Ia78624ca1aa36ee906cef15416ea5554fa8229f2
Reviewed-on: https://go-review.googlesource.com/17201
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-24 19:06:11 +00:00
David du Colombier
1d3e77607d syscall: don't check result of close(fd) in forkAndExecInChild on Plan9
On multiprocessor machines, a file descriptor could be
closed twice in forkAndExecInChild. Consequently, the close
syscall returns the "fd out of range or not open" error
and forkAndExecInChild fails.

This changes forkAndExecInChild to ignore the error
returned by close(fd), as on other operating systems.

Fixes #12851.

Change-Id: I96a8463ce6599bfd1362353283e0329a00f738da
Reviewed-on: https://go-review.googlesource.com/17188
Reviewed-by: Rob Pike <r@golang.org>
2015-11-24 18:57:44 +00:00
Elias Naur
a7383fc467 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.

[Replay of CL 16942 by Elias Naur.]

Change-Id: I98f144d626033ae5318576115ed635415ac71b2c
Reviewed-on: https://go-review.googlesource.com/17033
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-11-24 17:16:47 +00:00
Carlos Cirello
0e771c72ed unicode: add function level examples
Change-Id: I9e968c03c6615a539b18701c84f830898242441d
Reviewed-on: https://go-review.googlesource.com/13926
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 17:13:21 +00:00
Aaron Jacobs
b39329bff5 unicode/utf8: don't imply that the empty string is incorrect UTF-8
Change-Id: Idd9523949ee4f2f304b12be39f8940ba34a420be
Reviewed-on: https://go-review.googlesource.com/16361
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 17:12:35 +00:00
Caleb Spare
a150c4ff24 testing: pause the test timer while waiting in T.Parallel
Before, we reset the timer at the end of T.Parallel, which is okay
assuming that T.Parallel is the first thing in the test.

Snapshot the elapsed time at the beginning of Parallel and include it in
the total duration so that any time spent in the test before calling
Parallel is reported in the test duration as well.

Updates #12243.

Change-Id: Ieca553e1f801e16b9b6416463fa8f7fa65425185
Reviewed-on: https://go-review.googlesource.com/16989
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 17:07:45 +00:00
dvyukov
5526d95019 runtime/race: add tests for channels
These tests were failing on one of the versions of cl/9345
("runtime: simplify buffered channels").

Change-Id: I920ffcd28de428bcb7c2d5a300068644260e1017
Reviewed-on: https://go-review.googlesource.com/16416
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 17:00:43 +00:00
Ilya Tocar
b597e1ed54 runtime: speed up memclr with avx2 on amd64
Results are a bit noisy, but show good improvement (haswell)

name            old time/op    new time/op     delta
Memclr5-48        6.06ns ± 8%     5.65ns ± 8%    -6.81%  (p=0.000 n=20+20)
Memclr16-48       5.75ns ± 6%     5.71ns ± 6%      ~     (p=0.545 n=20+19)
Memclr64-48       6.54ns ± 5%     6.14ns ± 9%    -6.12%  (p=0.000 n=18+20)
Memclr256-48      10.1ns ±12%      9.9ns ±14%      ~     (p=0.285 n=20+19)
Memclr4096-48      104ns ± 8%       57ns ±15%   -44.98%  (p=0.000 n=20+20)
Memclr65536-48    2.45µs ± 5%     2.43µs ± 8%      ~     (p=0.665 n=16+20)
Memclr1M-48       58.7µs ±13%     56.4µs ±11%    -3.92%  (p=0.033 n=20+19)
Memclr4M-48        233µs ± 9%      234µs ± 9%      ~     (p=0.728 n=20+19)
Memclr8M-48        469µs ±11%      472µs ±16%      ~     (p=0.947 n=20+20)
Memclr16M-48       947µs ±10%      916µs ±10%      ~     (p=0.050 n=20+19)
Memclr64M-48      10.9ms ±10%      4.5ms ± 9%   -58.43%  (p=0.000 n=20+20)
GoMemclr5-48      3.80ns ±13%     3.38ns ± 6%   -11.02%  (p=0.000 n=20+20)
GoMemclr16-48     3.34ns ±15%     3.40ns ± 9%      ~     (p=0.351 n=20+20)
GoMemclr64-48     4.10ns ±15%     4.04ns ±10%      ~     (p=1.000 n=20+19)
GoMemclr256-48    7.75ns ±20%     7.88ns ± 9%      ~     (p=0.227 n=20+19)

name            old speed      new speed       delta
Memclr5-48       826MB/s ± 7%    886MB/s ± 8%    +7.32%  (p=0.000 n=20+20)
Memclr16-48     2.78GB/s ± 5%   2.81GB/s ± 6%      ~     (p=0.550 n=20+19)
Memclr64-48     9.79GB/s ± 5%  10.44GB/s ±10%    +6.64%  (p=0.000 n=18+20)
Memclr256-48    25.4GB/s ±14%   25.6GB/s ±12%      ~     (p=0.647 n=20+19)
Memclr4096-48   39.4GB/s ± 8%   72.0GB/s ±13%   +82.81%  (p=0.000 n=20+20)
Memclr65536-48  26.6GB/s ± 6%   27.0GB/s ± 9%      ~     (p=0.517 n=17+20)
Memclr1M-48     17.9GB/s ±12%   18.5GB/s ±11%      ~     (p=0.068 n=20+20)
Memclr4M-48     18.0GB/s ± 9%   17.8GB/s ±14%      ~     (p=0.547 n=20+20)
Memclr8M-48     17.9GB/s ±10%   17.8GB/s ±14%      ~     (p=0.947 n=20+20)
Memclr16M-48    17.8GB/s ± 9%   18.4GB/s ± 9%      ~     (p=0.050 n=20+19)
Memclr64M-48    6.19GB/s ±10%  14.87GB/s ± 9%  +140.11%  (p=0.000 n=20+20)
GoMemclr5-48    1.31GB/s ±10%   1.48GB/s ± 6%   +13.06%  (p=0.000 n=19+20)
GoMemclr16-48   4.81GB/s ±14%   4.71GB/s ± 8%      ~     (p=0.341 n=20+20)
GoMemclr64-48   15.7GB/s ±13%   15.8GB/s ±11%      ~     (p=0.967 n=20+19)

Change-Id: I393f3f20e2f31538d1b1dd70d6e5c201c106a095
Reviewed-on: https://go-review.googlesource.com/16773
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Klaus Post <klauspost@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-24 16:49:30 +00:00
Dave Cheney
984004263d runtime: skip CallbackGC test in short mode on linux/arm
Fixes #11959
Fixes #12035

Skip the CallbackGC test on linux/arm. This test takes between 30 and 60
seconds to run by itself, and is run 4 times over the course of ./run.bash
(once during the runtime test, three times more later in the build).

Change-Id: I4e7d3046031cd8c08f39634bdd91da6e00054caf
Reviewed-on: https://go-review.googlesource.com/14485
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 16:48:32 +00:00
Alex Brainman
1cb53ce36b runtime: fix handling VirtualAlloc failure in sysUsed
Original code is mistakenly panics on VirtualAlloc failure - we want
it to go looking for smaller memory region that VirtualAlloc will
succeed to allocate. Also return immediately if VirtualAlloc succeeds.
See rsc comment on issue #12587 for details.

I still don't have a test for this. So I can only hope that this

Fixes #12587

Change-Id: I052068ec627fdcb466c94ae997ad112016f734b7
Reviewed-on: https://go-review.googlesource.com/17169
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 14:50:23 +00:00
Robert Griesemer
8f931e49f5 cmd/compile: remove dead code
Get rid of residue after removing old parser.

Change-Id: I0dace1037d50959071a082c276f9f374eef6edb2
Reviewed-on: https://go-review.googlesource.com/17179
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 03:30:02 +00:00
Michael Hudson-Doyle
239273d963 runtime: mark {g,m,p}uintptr methods as nosplit
These are methods that are "obviously" going to get inlined -- until you build
with -l, when they can trigger a stack split at a bad time.

Fixes #11482

Change-Id: Ia065c385978a2e7fe9f587811991d088c4d68325
Reviewed-on: https://go-review.googlesource.com/17165
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-24 02:33:04 +00:00
Austin Clements
ecf388f3a4 runtime: take stack barrier lock during copystack
Commit bbd1a1c prevented SIGPROF from scanning stacks that were being
copied, but it didn't prevent a stack copy (specifically a stack
shrink) from happening while SIGPROF is scanning the stack. As a
result, a stack copy may adjust stack barriers while SIGPROF is in the
middle of scanning a stack, causing SIGPROF to panic when it detects
an inconsistent stack barrier.

Fix this by taking the stack barrier lock while adjusting the stack.
In addition to preventing SIGPROF from scanning this stack, this will
block until any in-progress SIGPROF is done scanning the stack.

For 1.5.2.

Fixes #13362.
Updates #12932.

Change-Id: I422219c363054410dfa56381f7b917e04690e5dd
Reviewed-on: https://go-review.googlesource.com/17191
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 01:50:52 +00:00
Alex Brainman
ab4c9298b8 runtime: do not call timeBeginPeriod on windows
Calling timeBeginPeriod changes Windows global timer resolution
from 15ms to 1ms. This used to improve Go runtime scheduler
performance, but not anymore. Thanks to @aclements, scheduler now
behaves the same way if we call timeBeginPeriod or not.

Remove call to timeBeginPeriod, since it is machine global
resource, and there are downsides of using low timer resolution.
See issue #8687 for details.

Fixes #8687

Change-Id: Ib7e41aa4a81861b62a900e0e62776c9ef19bfb73
Reviewed-on: https://go-review.googlesource.com/17164
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2015-11-24 01:11:58 +00:00
Robert Griesemer
b5fe07710f cmd/compile: remove yacc-based parser
- moved yySymType and token constants (L...) to lex.go
- removed oldparser flag and related code
- removed go generate that generated y.go

Fixes #13240.

Change-Id: I2576ec61ee1efe482f2a5132175725c9c02ef977
Reviewed-on: https://go-review.googlesource.com/17176
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-24 00:23:14 +00:00
Ian Lance Taylor
f1b919574c cmd/link: support R_PPC_REL32 relocation
This relocation is found in libgcc.a in the .eh_frame, and therefore
needs to be handled when doing an internal link.

Fixes #13375.

Change-Id: Idd9e8178e08851a101b43261a30939bcfaf394f9
Reviewed-on: https://go-review.googlesource.com/17173
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2015-11-24 00:02:06 +00:00
Rob Pike
009517e0b7 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>
2015-11-23 22:11:16 +00:00
Robert Griesemer
656a732a21 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>
2015-11-23 21:29:27 +00:00
Nodir Turakulov
8331f19d97 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>
2015-11-23 21:11:37 +00:00
Austin Clements
b890333998 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>
2015-11-23 20:59:35 +00:00
Austin Clements
a7c09ad4fb 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>
2015-11-23 19:17:52 +00:00
Austin Clements
22e57c6655 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>
2015-11-23 19:13:15 +00:00
Ian Lance Taylor
0417872809 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>
2015-11-23 04:04:07 +00:00
Russ Cox
5951823853 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>
2015-11-23 02:29:57 +00:00
Dmitri Shuralyov
2221bc35cf 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>
2015-11-22 22:00:21 +00:00
Robert Griesemer
aad18b849b 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>
2015-11-21 07:21:23 +00:00
Robert Griesemer
0383bb473d cmd/compile: simplify tracing code (cleanup)
Change-Id: I7c084542996226f3ed464314a5622fcfaac02d61
Reviewed-on: https://go-review.googlesource.com/17103
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:20:39 +00:00
Mikio Hara
91977d07fe 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>
2015-11-21 02:59:54 +00:00
Ian Lance Taylor
7e31224329 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>
2015-11-21 01:33:40 +00:00
Rob Pike
29499858bf 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>
2015-11-20 21:50:54 +00:00
Robert Griesemer
af8cd3f6bd 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>
2015-11-20 19:56:51 +00:00
Robert Griesemer
64cd86798b 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>
2015-11-20 19:56:27 +00:00
Robert Griesemer
7218b79f23 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>
2015-11-20 19:56:11 +00:00
Robert Griesemer
de2bc5722d 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>
2015-11-20 19:55:51 +00:00
Robert Griesemer
52f111fb34 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>
2015-11-20 19:55:15 +00:00
Austin Clements
624d798a41 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>
2015-11-20 19:39:36 +00:00
Russ Cox
cb859021d1 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>
2015-11-20 19:08:21 +00:00
David Crawshaw
2fa64c4182 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>
2015-11-20 17:52:33 +00:00
David Crawshaw
9fa6a2d42d 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>
2015-11-20 16:37:21 +00:00
Hyang-Ah Hana Kim
bda885511d 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>
2015-11-20 14:55:35 +00:00
Shenghou Ma
35a5bd6431 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>
2015-11-20 08:11:35 +00:00
Joe Tsai
d6ee6c2d06 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>
2015-11-20 04:57:07 +00:00
Hyang-Ah Hana Kim
ec3daf0c62 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>
2015-11-20 04:22:35 +00:00
Hyang-Ah Hana Kim
cbc55971e2 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>
2015-11-20 03:49:13 +00:00
Russ Cox
3af29fb858 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>
2015-11-20 02:51:09 +00:00
Rob Pike
997ed6fd3b 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>
2015-11-20 00:28:11 +00:00
Ian Lance Taylor
f2a0fc10c9 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>
2015-11-20 00:19:48 +00:00
Ian Lance Taylor
5005a33987 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>
2015-11-20 00:19:07 +00:00
Shenghou Ma
23791ee11d 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>
2015-11-19 23:55:50 +00:00
Keith Randall
8d31a86a1e 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>
2015-11-19 21:35:58 +00:00
Russ Cox
476aa95015 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>
2015-11-19 21:22:48 +00:00
Austin Clements
d2c81ad847 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>
2015-11-19 21:17:25 +00:00
Austin Clements
402e37d4a9 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>
2015-11-19 21:17:19 +00:00
Austin Clements
c84ae1c499 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>
2015-11-19 21:17:14 +00:00
Austin Clements
e9aef43d87 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>
2015-11-19 21:17:09 +00:00
Austin Clements
b43b375c6c 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>
2015-11-19 21:17:04 +00:00
Russ Cox
26119179fa 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>
2015-11-19 20:57:16 +00:00
Russ Cox
3ea668a0f2 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>
2015-11-19 20:53:50 +00:00
Rob Pike
4d9f68028a 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>
2015-11-19 20:49:27 +00:00
Russ Cox
8b1b81f463 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>
2015-11-19 19:54:55 +00:00
Michael Matloob
45c3cf68b0 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>
2015-11-19 19:50:03 +00:00
Ian Lance Taylor
0e2c635788 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>
2015-11-19 18:28:39 +00:00
Michael Hudson-Doyle
0fbf0955d4 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>
2015-11-19 17:43:37 +00:00
Austin Clements
9a7893550c 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>
2015-11-19 16:35:43 +00:00
Austin Clements
9c9d74aba7 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>
2015-11-19 16:35:38 +00:00
Austin Clements
3a2fc06833 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>
2015-11-19 16:35:34 +00:00
Brad Fitzpatrick
aae81d948c 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>
2015-11-19 02:41:20 +00:00
Brad Fitzpatrick
e4a1acced7 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>
2015-11-19 01:35:36 +00:00
Michael Hudson-Doyle
e8e0d906dc 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>
2015-11-19 00:23:38 +00:00
Michael Hudson-Doyle
09d7de8d61 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>
2015-11-19 00:22:56 +00:00
Robert Griesemer
34cbccd341 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>
2015-11-18 22:52:58 +00:00
Robert Griesemer
431c232842 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>
2015-11-18 22:26:24 +00:00
Robert Griesemer
fe762b6466 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>
2015-11-18 22:26:07 +00:00
Robert Griesemer
5500d46914 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>
2015-11-18 22:25:48 +00:00
Robert Griesemer
1a111ea2c7 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>
2015-11-18 22:22:56 +00:00
Ian Lance Taylor
9ceb1acbfb 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>
2015-11-18 21:55:38 +00:00
Michael Hudson-Doyle
342f17eaf7 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>
2015-11-18 21:27:45 +00:00
Michael Hudson-Doyle
cb0393866a 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>
2015-11-18 21:26:42 +00:00
Michael Hudson-Doyle
3c85e1b186 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>
2015-11-18 21:25:55 +00:00
Russ Cox
6bf794a36d 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>
2015-11-18 19:00:45 +00:00
Russ Cox
918a2644f2 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>
2015-11-18 18:31:27 +00:00