1
0
mirror of https://github.com/golang/go synced 2024-10-01 11:18:32 -06:00
Commit Graph

21513 Commits

Author SHA1 Message Date
Michalis Kargakis
f34964ed34 flag: Some idiomatic fixes
Make golint a bit happier

Change-Id: I8a14342f3e492e92bf5efa611f9ef91176624031
Reviewed-on: https://go-review.googlesource.com/1891
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-21 00:24:39 +00:00
Jed Denlea
474ce6903b net/http: Fix Range off-by-one error
Given a file of size N, a request for "Range: bytes=N-*" should
return a 416 [1].  Currently, it returns a 206 and a body of 0
bytes, with the illegal Content-Range of "bytes N-(N-1)/N" [2].

[1]: RFC 7233, sec 2.1: "If a valid byte-range-set includes at least one
byte-range-spec with a first-byte-pos that is less than the current
length of the representation, [...]".  sec 3.1: "If all of the
preconditions are true, the server supports the Range header field for
the target resource, and the specified range(s) are invalid or
unsatisfiable, the server SHOULD send a 416 (Range Not Satisfiable)
response."

[2]: RFC 7233, sec 4.2: "A Content-Range field value is invalid if it
contains a byte-range-resp that has a last-byte-pos value less than its
first-byte-pos value, [...]"

Fixes #8988

Change-Id: If3e1134e7815f5d361efea01873b29aafe3de817
Reviewed-on: https://go-review.googlesource.com/1862
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-20 23:42:44 +00:00
mischief
640c0f3849 runtime: fix brk_ signature for plan9
with uintptr, the check for < 0 will never succeed in mem_plan9.go's
sbrk() because the brk_ syscall returns -1 on failure. fixes the plan9/amd64 build.

this failed on plan9/amd64 because of the attempt to allocate 136GB in mallocinit(),
which failed. it was just by chance that on plan9/386 allocations never failed.

Change-Id: Ia3059cf5eb752e20d9e60c9619e591b80e8fb03c
Reviewed-on: https://go-review.googlesource.com/1590
Reviewed-by: Anthony Martin <ality@pbrane.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2014-12-20 21:41:44 +00:00
Dave Cheney
64e6fe2d29 image/draw: fix crash in clip
Fixes #9177

Change-Id: I1c7e57f0f0a9b00fb3ddc7fa4844ac53ea6df46f
Reviewed-on: https://go-review.googlesource.com/1876
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-20 06:00:38 +00:00
Brad Fitzpatrick
01b2560068 net/http: make Client.Timeout return net.Error errors indicating timeout
Co-hacking with Dave Cheney.

Fixes #9405

Change-Id: I14fc3b6a47dcdb5e514e93d062b804bb24e89f47
Reviewed-on: https://go-review.googlesource.com/1875
Reviewed-by: Dave Cheney <dave@cheney.net>
2014-12-20 05:00:24 +00:00
Ian Lance Taylor
421c01706f misc/cgo/test: skip test7978 when using gccgo
Gccgo can only get a backtrace for the currently running thread, which
means that it can only get a backtrace for goroutines currently running
Go code.  When a goroutine is running C code, gccgo has no way to stop
it and get the backtrace.  This test is all about getting a backtrace
of goroutines running C code, so it can't work for gccgo.

Change-Id: I2dff4403841fb544da7396562ab1193875fc14c3
Reviewed-on: https://go-review.googlesource.com/1904
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-20 02:38:38 +00:00
Ian Lance Taylor
35dc312e72 misc/cgo/test/backdoor: add gc build tag for thunk.s
Change-Id: I6be5f610af5c56131a9d887569919372bab1d02c
Reviewed-on: https://go-review.googlesource.com/1903
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-20 02:08:50 +00:00
Ian Lance Taylor
1303f0d3d8 cmd/cgo: don't #include cgo_export.h in gccgo _cgo_main.c
Instead of relying on the asm names declared in the gccgo version of
cgo_export.h, just emit a dummy symbol with the right asm name.  This
is enough to let the _cgo_main link succeed, which is all that matters
here.

Fixes #9294.

Change-Id: I803990705b6b226ed0adf17dc57b58a9f501b213
Reviewed-on: https://go-review.googlesource.com/1901
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-20 01:42:00 +00:00
Ian Lance Taylor
1e65616e1a testing: style change: omit unnecessary new
This was brought to my attention because a user thought that because
the file was named "example.go" it served as an example of good coding
practice.  It's not an example, of course, but may as well use a more
idiomatic style anyhow.

Change-Id: I7aa720f603f09f7d597fb7536dbf46ef09144e28
Reviewed-on: https://go-review.googlesource.com/1902
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-20 01:40:11 +00:00
Josh Bleecher Snyder
6ceb60444d sort: deduplicate inner loop of Stable
benchmark                   old ns/op      new ns/op      delta
BenchmarkStableInt1K        117212         116287         -0.79%
BenchmarkStableInt64K       9632002        9587872        -0.46%
BenchmarkStable1e4          40044309       39865644       -0.45%
BenchmarkStable1e2          126985         126456         -0.42%
BenchmarkStableString1K     389774         391052         +0.33%
BenchmarkStable1e6          8183202516     8157693442     -0.31%

Change-Id: I14e518ad49ecce3d1fc2b056e1acd5e5a2de8144
Reviewed-on: https://go-review.googlesource.com/1821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-19 18:26:26 +00:00
Emil Hessman
ddb24da850 doc: fix typo in gccgo contribute
Change-Id: Ib9699fc9c45f61e9d75e9d9ae69167f039a66dfc
Reviewed-on: https://go-review.googlesource.com/1890
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-19 17:57:33 +00:00
Matthew Dempsky
481ce36ec4 runtime: simplify cpuprof hash calculation
"x*41" computes the same value as "x*31 + x*7 + x*3" and (when
compiled by gc) requires just one multiply instruction instead of
three.

Alternatively, the expression could be written as "(x<<2+x)<<3 + x" to
use shifts instead of multiplies (which is how GCC optimizes "x*41").
But gc currently emits suboptimal instructions for this expression
anyway (e.g., separate SHL+ADD instructions rather than LEA on
386/amd64). Also, if such an optimization was worthwhile, it would
seem better to implement it as part of gc's strength reduction logic.

Change-Id: I7156b793229d723bbc9a52aa9ed6111291335277
Reviewed-on: https://go-review.googlesource.com/1830
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-19 02:50:40 +00:00
Brad Fitzpatrick
7a8e897979 doc: start go1.5.txt
Change-Id: I0f9cf081cb280f0a805ee7f5178a5cbed0d4ad88
Reviewed-on: https://go-review.googlesource.com/1842
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-19 02:49:31 +00:00
Alex Brainman
3f19541752 runtime: use go generate for zcallback_windows.go
replacement for CL 180640043

Change-Id: I8ff36645cfcbbda338faf7b29cbfdb95c47d5ec4
Reviewed-on: https://go-review.googlesource.com/1765
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-19 02:45:40 +00:00
David Crawshaw
895e4b8550 compress/bzip2: s/repeat_power/repeatPower/
Change-Id: I64c8c247acd5d134b2f17ed7aab0a035d7710679
Reviewed-on: https://go-review.googlesource.com/1804
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-19 01:29:00 +00:00
Shenghou Ma
c5089a7a81 test/fixedbugs/issue9355: fix build on windows and skip on nacl
Change-Id: If367cc1e8c2d744569513bc71da6e6c454c74e9a
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1802
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2014-12-19 01:06:33 +00:00
Austin Clements
62eb6fef6e cmd/ld: add fallthrough comment
Change-Id: Ia6739c164575751a63cc0d4d41d1f6887fbbaee3
Reviewed-on: https://go-review.googlesource.com/1803
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:54:50 +00:00
Austin Clements
9b1b0a46dd liblink: fail for too-large register offset constants
Previously, liblink would silently truncate register offset constants
to 32 bits.  For example,

    MOVD $0x200000004(R2),R3

would assemble to

    addis   r31,r2,0
    addi    r3,r31,4

To fix this, limit C_LACON to 32 bit (signed) offsets and introduce a
new C_DACON operand type for larger register offsets.  We don't
implement this currently, but at least liblink will now give an error
if it encounters an address like this.

Change-Id: I8e87def8cc4cc5b75498b0fb543ac7666cf2964e
Reviewed-on: https://go-review.googlesource.com/1758
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:32:18 +00:00
Austin Clements
15c67e21da cmd/ld: set ELF ABI version for ppc64x
On ppc64, there are three ELF ABI versions an ELF file can request.
Previously, we used 0, which means "unspecified".  On our test
machines, this meant to use the default (v1 for big endian and v2 for
little endian), but apparently some systems can pick the wrong ABI if
neither is requested.  Leaving this as 0 also confuses libbfd, which
confuses gdb, objdump, etc.

Fix these problems by specifying ABI v1 for big endian and v2 for
little endian.

Change-Id: I4d3d5478f37f11baab3681a07daff3da55802322
Reviewed-on: https://go-review.googlesource.com/1800
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 22:30:56 +00:00
Keith Randall
2fc29a83ae cmd/gc: resolve static addresses of the form &x.f at link time
When we do y = &x for global variables x and y, y gets initialized
at link time.  Do the same for y = &x.f if x is a struct and y=&x[5]
if x is an array.

fixes #9217
fixes #9355

Change-Id: Iea3c0ce2ce1b309e2b760e345608fd95460b5713
Reviewed-on: https://go-review.googlesource.com/1691
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 21:53:03 +00:00
Shenghou Ma
340ef004d6 runtime/cgo: guard against redefinition of PTHREAD_KEYS_MAX
Fixes #9374.

Change-Id: Ic53757eba98fc43bcd24e25e03876fef917b4da1
Reviewed-on: https://go-review.googlesource.com/1751
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-18 21:23:25 +00:00
Guobiao Mei
6ce3cd18fa runtime: fix a minor typo in comments
Change-Id: I13a8aacd1b8243c992b539ab6bf7b5dff2a1393a
Reviewed-on: https://go-review.googlesource.com/1757
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 20:35:56 +00:00
Adam Langley
604fa4d5a1 crypto/tls: change default minimum version to TLS 1.0.
SSLv3 (the old minimum) is still supported and can be enabled via the
tls.Config, but this change increases the default minimum version to TLS
1.0. This is now common practice in light of the POODLE[1] attack
against SSLv3's CBC padding format.

[1] https://www.imperialviolet.org/2014/10/14/poodle.html

Fixes #9364.

Change-Id: Ibae6666ee038ceee0cb18c339c393155928c6510
Reviewed-on: https://go-review.googlesource.com/1791
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 19:49:41 +00:00
Ben Burkert
1965b03584 crypto/tls: enable TLS_FALLBACK_SCSV in server with default max version
Fix TLS_FALLBACK_SCSV check when comparing the client version to the
default max version. This enables the TLS_FALLBACK_SCSV check by default
in servers that do not explicitly set a max version in the tls config.

Change-Id: I5a51f9da6d71b79bc6c2ba45032be51d0f704b5e
Reviewed-on: https://go-review.googlesource.com/1776
Reviewed-by: Adam Langley <agl@golang.org>
2014-12-18 19:36:01 +00:00
Josh Bleecher Snyder
8e0686a071 test: add missing linkx test
This test was added in CL 151000043.
It got lost in CL 144630044.

Change-Id: I318ab11be8e3e7489fc1395457c029c8bdb2aa41
Reviewed-on: https://go-review.googlesource.com/1773
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-18 17:41:27 +00:00
Ian Lance Taylor
24bf8f62be cmd/go: gc never permits C files; gccgo always does
Change-Id: I513665626ec0866f32036c26207dc234c17acea1
Reviewed-on: https://go-review.googlesource.com/1540
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 16:16:10 +00:00
Jan Mercl
a034e478a7 cmd/yacc: Prevent index out of range. Fixes #9099.
Change-Id: I7ef01a738b6ca49af1c148146d439c81b0a33b16
Reviewed-on: https://go-review.googlesource.com/1785
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-18 16:11:50 +00:00
Emil Hessman
ddd666b122 path/filepath: remove named result parameter for VolumeName
Fix style by removing unnecessary named result parameter.

Fix doc comment while here.

Change-Id: If8394e696ab37e00a95484d5137955aa06c59520
Reviewed-on: https://go-review.googlesource.com/1781
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-18 16:05:07 +00:00
Austin Clements
b21e936f3e liblink: generate correct code for MOVD $-n(Rm), x on ppc64
On ppc64, liblink rewrites MOVD's of >32-bit constants by putting the
constant in memory and rewriting the MOVD to load from that memory
address.  However, there were two bugs in the condition:

a) owing to an incorrect sign extension, it triggered for all negative
   constants, and

b) it could trigger for constant offsets from registers (addresses of
   the form $n(Rm) in assembly)

Together, these meant instructions of the form MOVD $-n(Rm), x were
compiled by putting -n in memory and rewriting the MOVD to load this
constant from memory (completely dropping Rm).

Change-Id: I1f6cc980efa3e3d6f164b46c985b2c3b55971cca
Reviewed-on: https://go-review.googlesource.com/1752
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 15:31:47 +00:00
Daniel Morsing
e0e1cee8e9 cmd/gc: remove outdated warning from pre-go1.
People are probably not making this mistake anymore.

Fixes #9164

Change-Id: I86b440ed63d09b4ca676bba7034838860f1a5d8b
Reviewed-on: https://go-review.googlesource.com/1782
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 08:52:30 +00:00
David du Colombier
1ba13a5ae8 cmd/gc: fix warning on Plan 9
warning: src/cmd/gc/bits.c:101 non-interruptable temporary

Change-Id: I74661fefab50455b912b8085d913fc45ba13c5c8
Reviewed-on: https://go-review.googlesource.com/1780
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-18 07:37:46 +00:00
Shenghou Ma
fc71d7b8ca misc/chrome/gophertool: update for the git/gerrit transition
Change-Id: I7b9601ae6e1cfb18ef79a7b189aa7e689c0fe942
Reviewed-on: https://go-review.googlesource.com/1621
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-18 07:34:46 +00:00
Shenghou Ma
0fa6e7fe82 api: update next.txt
Change-Id: I9eac8b23eb9e6b6940069811177365b4772c2fb1
Reviewed-on: https://go-review.googlesource.com/1513
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-18 03:21:48 +00:00
Ian Lance Taylor
6cd4d59db6 test: add bug494: test case miscompiled by gccgo
Gccgo incorrectly executed functions multiple times when they appeared
in a composite literal that required a conversion between different
interface types.

Change-Id: I7b40e76ed23fa8440ffa03b262041265c109adf7
Reviewed-on: https://go-review.googlesource.com/1710
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 02:45:00 +00:00
Andrew Gerrand
0293b7ee37 doc: fixes to contributor docs
Change-Id: Ib31fb1f8239d8113728bc4c6e411416721571341
Reviewed-on: https://go-review.googlesource.com/1743
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-18 02:17:32 +00:00
Andrew Gerrand
968f0df5d8 doc: update source install instructions
Change-Id: I794a5773ed47d470ff91fcdd82f9747a91424eb4
Reviewed-on: https://go-review.googlesource.com/1402
Reviewed-by: Rob Pike <r@golang.org>
2014-12-18 00:54:43 +00:00
Andrew Gerrand
722f7d280b doc: use 'git-codereview' in contributor docs
Change-Id: I63d5c81fdaf9aca2fc3da3defcc6e9c4094c690b
Reviewed-on: https://go-review.googlesource.com/1742
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-18 00:45:35 +00:00
Kato Kazuyoshi
6262902070 os: handle the sticky bit separately for *BSD and Solaris
open(2) and mkdir(2) won't set the sticky bit on *BSD and Solaris.
This behavior is mentioned on sticky(8).
see also: https://github.com/dotcloud/docker/pull/6587

Fixes #8383.

Change-Id: Ic4733700f9926b9fc2b6fd1f998acec34e518764
Reviewed-on: https://go-review.googlesource.com/1673
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-17 16:07:28 +00:00
Ian Lance Taylor
60ea2c594b test: add test that gccgo failed to compile
Gccgo failed to create the type descriptor for the type used to
allocate the nil value passed to append as the second argument when
append is called with only one argument.  Calling append with only one
argument is unusual but obviously should not cause a compiler crash.

Change-Id: I530821847dfd68f0302de6ca6a84dfbc79653935
Reviewed-on: https://go-review.googlesource.com/1692
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-17 02:22:57 +00:00
Rick Hudson
1b0b0db6fb runtime: add profiling infrastructure for the Concurrent GC
Change-Id: Ia7a007444eeb1503cec27367a5c6699ce0bf4af6
Reviewed-on: https://go-review.googlesource.com/1441
Reviewed-by: Austin Clements <austin@google.com>
2014-12-16 22:15:51 +00:00
Brad Fitzpatrick
895e48cac5 reflect: remove a double negative, use the rtype.pointers method for clarity
Change-Id: Ia24e9f0da1622cededa17b2c54ff9e4bb80cf946
Reviewed-on: https://go-review.googlesource.com/1633
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2014-12-16 21:17:07 +00:00
Keith Randall
50bc3d5bbc runtime: fix deadlock in runtime.Stack
It shouldn't semacquire() inside an acquirem(), the runtime
thinks that means deadlock.  It actually isn't a deadlock, but it
looks like it because acquirem() does m.locks++.

Candidate for inclusion in 1.4.1.  runtime.Stack with all=true
is pretty unuseable in GOMAXPROCS>1 environment.

fixes #9321

Change-Id: Iac6b664217d24763b9878c20e49229a1ecffc805
Reviewed-on: https://go-review.googlesource.com/1600
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2014-12-16 17:04:45 +00:00
Brad Fitzpatrick
8f36655346 net/http/httputil: don't use DisableKeepAlives in DumpRequestOut, fix build
I broke the build in https://golang.org/change/207950a when I made
http.Transport send "Connection: close" request headers when
DisableKeepAlives was set true because I didn't run all the tests
before submitting.

httputil.DumpRequestOut used Transport to get its output, and used it
with DisableKeepAlives, so this changed the output.

Rather than updating golden data in our tests (because surely others
depend on the exact bytes from these in their tests), switch to not
using DisableKeepAlives in DumpRequestOut instead, so the output is
the same as before.

Change-Id: I9fad190be8032e55872e6947802055a6d65244df
Reviewed-on: https://go-review.googlesource.com/1632
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-16 06:58:43 +00:00
Brad Fitzpatrick
207950ad51 net/http: make Transport send 'Connection: close' when DisableKeepAlives
No bug was open, but I found an old email to myself to investigate
when I suspected this was happening.

Change-Id: Icedefec6f15a000eaabb2693b0640b3b6c8bf82c
Reviewed-on: https://go-review.googlesource.com/1578
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-16 06:16:28 +00:00
Brad Fitzpatrick
fccd942803 runtime: gofmt
Fixes #9339

Change-Id: I22faf2593cb73f42612c2c2bfe38de001fb2746b
Reviewed-on: https://go-review.googlesource.com/1630
Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-16 06:16:00 +00:00
Brad Fitzpatrick
5308c6d932 crypto/rand: handle EAGAIN reads from /dev/urandom
Fixes #9205

Change-Id: Iacd608ba43332008984aa8ece17dcb5757f27b3f
Reviewed-on: https://go-review.googlesource.com/1611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-16 04:52:09 +00:00
Andrew Gerrand
8655f04d8e doc: propose $GOPATH as $HOME/work, not $HOME/go
Related to issue #9228

Change-Id: I0819e657f6393788754d1412f9c2126a170d4cf1
Reviewed-on: https://go-review.googlesource.com/1577
Reviewed-by: Rob Pike <r@golang.org>
2014-12-16 04:35:09 +00:00
Brad Fitzpatrick
3185f8620c net/textproto: turn an ancient DoS BUG annotation into a comment
Actually fixing this "bug" would be weird, since io.LimitReader already
does what we need, as demonstrated by net/http's use.

Thanks to @davidfstr for pointing this out.

Change-Id: If707bcc698d1666a369b39ddfa9770685fbe3879
Reviewed-on: https://go-review.googlesource.com/1579
Reviewed-by: Rob Pike <r@golang.org>
2014-12-16 04:17:30 +00:00
Keith Randall
df1739c77d runtime: if key type is reflexive, don't call equal(k, k)
Most types are reflexive (k == k for all k of type t), so don't
bother calling equal(k, k) when the key type is reflexive.

Change-Id: Ia716b4198b8b298687843b94b878dbc5e8fc2c65
Reviewed-on: https://go-review.googlesource.com/1480
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-15 21:43:49 +00:00
David Crawshaw
324f38a222 runtime: shrink initial arena if reservation fails
Fixes #9311

Change-Id: I2f142e65a54c0391084316d79a42714ba42dd8b9
Reviewed-on: https://go-review.googlesource.com/1514
Reviewed-by: Keith Randall <khr@golang.org>
2014-12-15 20:55:33 +00:00