Adam Langley [Tue, 21 May 2013 14:47:31 +0000 (10:47 -0400)]
crypto/tls: don't send NPN extension if NextProtos is not set.
This isn't clearly a bug on Go's part, but it triggers a bug in Firefox
which means that crypto/tls and net/http cannot be wired up together
unless NextProtos includes "http/1.1". When net/http sets up the
tls.Config, it does this and so works fine. But anyone setting up the
tls.Config themselves will hit the Firefox bug.
Fixes #5445.
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/9539045
Robert Griesemer [Mon, 20 May 2013 21:01:07 +0000 (14:01 -0700)]
spec: removed old or invalid TODOs
Several old TODOs are either resolved now (e.g. when is a return
needed), or are from a time the language wasn't frozen (^ for uints
only). Consolidated the others.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9599044
Adam Langley [Mon, 20 May 2013 18:20:26 +0000 (14:20 -0400)]
crypto/x509: provide better error messages for X.509 verify failures.
Failures caused by errors like invalid signatures or missing hash
functions cause rather generic, unhelpful error messages because no
trust chain can be constructed: "x509: certificate signed by unknown
authority."
With this change, authority errors may contain the reason why an
arbitary candidate step in the chain was rejected. For example, in the
event of a missing hash function the error looks like:
x509: certificate signed by unknown authority (possibly because of
"crypto/x509: cannot verify signature: algorithm unimplemented" while
trying to verify candidate authority certificate 'Thawte SGC CA')
Fixes 5058.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9104051
Keith Randall [Fri, 17 May 2013 19:53:49 +0000 (12:53 -0700)]
runtime: faster x86 memmove (a.k.a. built-in copy())
REP instructions have a high startup cost, so we handle small
sizes with some straightline code. The REP MOVSx instructions
are really fast for large sizes. The cutover is approximately
1K. We implement up to 128/256 because that is the maximum
SSE register load (loading all data into registers before any
stores lets us ignore copy direction).
Carl Shapiro [Thu, 16 May 2013 17:42:39 +0000 (10:42 -0700)]
runtime: fix scanning of not started goroutines
The stack scanner for not started goroutines ignored the arguments
area when its size was unknown. With this change, the distance
between the stack pointer and the stack base will be used instead.
Adam Langley [Thu, 16 May 2013 16:29:23 +0000 (12:29 -0400)]
crypto/tls: fix flakey test.
A test added in b37d2fdcc4d9 didn't work with some values of GOMAXPROCS
because the defer statements were in the wrong order: the Pipe could be
closed before the TLS Client was.
Dmitriy Vyukov [Wed, 15 May 2013 19:50:32 +0000 (23:50 +0400)]
runtime: fix GC scanning of slices
If a slice points to an array embedded in a struct,
the whole struct can be incorrectly scanned as the slice buffer.
Fixes #5443.
Dmitriy Vyukov [Wed, 15 May 2013 17:22:32 +0000 (21:22 +0400)]
runtime: add simple malloc benchmarks
Allocs of size 16 can bypass atomic set of the allocated bit, while allocs of size 8 can not.
Allocs with and w/o type info hit different paths inside of malloc.
Current results on linux/amd64:
BenchmarkMalloc8 50000000 43.6 ns/op
BenchmarkMalloc16 50000000 46.7 ns/op
BenchmarkMallocTypeInfo8 50000000 61.3 ns/op
BenchmarkMallocTypeInfo16 50000000 63.5 ns/op
Dmitriy Vyukov [Wed, 15 May 2013 14:35:05 +0000 (18:35 +0400)]
runtime: transfer whole span from MCentral to MCache
Finer-grained transfers were relevant with per-M caches,
with per-P caches they are not relevant and harmful for performance.
For few small size classes where it makes difference,
it's fine to grab the whole span (4K).
benchmark old ns/op new ns/op delta
BenchmarkMalloc 42 40 -4.45%
Adam Langley [Wed, 15 May 2013 14:27:34 +0000 (10:27 -0400)]
crypto/rsa: check for minimal PKCS#1 v1.5 padding.
The PKCS#1 spec requires that the PS padding in an RSA message be at
least 8 bytes long. We were not previously checking this. This isn't
important in the most common situation (session key encryption), but
the impact is unclear in other cases.
Adam Langley [Wed, 15 May 2013 14:25:54 +0000 (10:25 -0400)]
crypto/tls: ignore empty TLS records.
OpenSSL can be configured to send empty records in order to randomise
the CBC IV. This is an early version of 1/n-1 record splitting (that Go
does) and is quite reasonable, but it results in tls.Conn.Read
returning (0, nil).
This change ignores up to 100 consecutive, empty records to avoid
returning (0, nil) to callers.
Adam Langley [Wed, 15 May 2013 14:03:22 +0000 (10:03 -0400)]
math/big: save some copies in binaryGCD.
This patch resulted from a bit of quick optimisation in response to a
golang-nuts post. It looks like one could save a couple other copies in
this function, but this addresses the inner loop and is fairly simple.
Dmitriy Vyukov [Wed, 15 May 2013 12:48:41 +0000 (16:48 +0400)]
runtime: unset m->locks after actual lock unlock
This is needed for preemptive scheduler,
it will preempt only when m->locks==0,
and we do not want to be preempted while
we have not completely unlocked the lock.
Alexey Borzenkov [Wed, 15 May 2013 03:24:54 +0000 (13:24 +1000)]
os/user: faster user lookup on Windows
Trying to lookup user's display name with directory services can
take several seconds when user's computer is not in a domain.
As a workaround, check if computer is joined in a domain first,
and don't use directory services if it is not.
Additionally, don't leak tokens in user.Current().
Fixes #5298.
Jonathan Hseu [Wed, 15 May 2013 00:14:59 +0000 (17:14 -0700)]
testing/quick: fix for aliased types, delete duplicate uint8 test, and fix randFloat64() to give random numbers from (-math.MaxFloat64, math.MaxFloat64).
Brad Fitzpatrick [Tue, 14 May 2013 22:50:46 +0000 (15:50 -0700)]
encoding/json: allocate less in NewEncoder
The *Encoder is almost always garbage. It doesn't need an
encodeState inside of it (and its bytes.Buffer), since it's
only needed locally inside of Encode.
benchmark old ns/op new ns/op delta
BenchmarkEncoderEncode 2562 2553 -0.35%
benchmark old bytes new bytes delta
BenchmarkEncoderEncode 283 102 -63.96%
Alberto García Hierro [Tue, 14 May 2013 22:33:46 +0000 (15:33 -0700)]
net/http: Fix basic authentication with empty password
The encoded string must include the : separating the username
and the password, even when the latter is empty. See
http://www.ietf.org/rfc/rfc2617.txt for more information.
Bill Thiede [Tue, 14 May 2013 16:54:16 +0000 (09:54 -0700)]
misc/vim: test.sh seems to only work on Mac OS X.
cmp(1) on FreeBSD requires two file arguments. grep -P on Linux (at least
Ubuntu 12.04) is described in the man page as "This is highly
experimental" and doesn't seem to work. On FreeBSD the man page states
"This option is not supported in FreeBSD." Needed this to work while
debugging some funky behavior of 'Import' in my local vim setup.
Dmitriy Vyukov [Mon, 13 May 2013 06:28:12 +0000 (10:28 +0400)]
runtime/race: improve public documentation
Move the documentation from race.go to doc.go, because
race.go uses +build race, so it's not normally parsed by go doc.
Rephrase the documentation for end users, provide link to race
detector manual.
Fixes #5444.
R=golang-dev, minux.ma, adg, r
CC=golang-dev
https://golang.org/cl/9144050
Ian Lance Taylor [Wed, 8 May 2013 21:58:34 +0000 (14:58 -0700)]
runtime: fix crash in select
runtime.park() can access freed select descriptor
due to a racing free in another thread.
See the comment for details.
Slightly modified version of dvyukov's CL 9259045.
No test yet. Before this CL, the test described in issue 5422
would fail about every 40 times for me. With this CL, I ran
the test 5900 times with no failures.
Fixes #5422.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9311043
Dmitriy Vyukov [Mon, 6 May 2013 23:15:03 +0000 (16:15 -0700)]
runtime: fix crash in badsignal()
The linker can generate split stack prolog when a textflag 7 function
makes an indirect function call. If it happens, badsignal() crashes
trying to dereference g.
Fixes #5337.
Shenghou Ma [Mon, 6 May 2013 22:53:02 +0000 (06:53 +0800)]
runtime: reduce max arena size on windows/amd64 to 32 GiB
Update #5236
Update #5402
This CL reduces gofmt's committed memory from 545864 KiB to 139568 KiB.
Note: Go 1.0.3 uses about 70MiB.
Jeremiah Harmsen [Mon, 6 May 2013 17:15:16 +0000 (10:15 -0700)]
go/doc/example: Fix bug causing false negatives for Example playability.
Allows Examples with KeyValue expressions to be playable in godoc.
During the traversal of the abstract syntax tree any KeyValueExpr Key.Name was incorrectly being added as an unresolved identifier.
Since this identifier could not be provided the Example was marked as unplayable.
This updates the AST traversal to skip Keys (but continue traversing the Values).
Example of problematic AST now fixed (see L99 where "UpperBound" was being added as a missing identifier):