math/big: correct quadratic space complexity in Mul.
The previous implementation used to have a O(n) recursion
depth for unbalanced inputs. A test is added to check that a
reasonable amount of bytes is allocated in this case.
Adam Langley [Wed, 11 Jul 2012 16:47:12 +0000 (12:47 -0400)]
crypto/rsa: left-pad PKCS#1 v1.5 outputs.
OpenSSL requires that RSA signatures be exactly the same byte-length
as the modulus. Currently it'll reject ~1/256 of our signatures: those
that end up a byte shorter.
Fixes #3796.
R=golang-dev, edsrzf, r
CC=golang-dev
https://golang.org/cl/6352093
Adam Langley [Tue, 10 Jul 2012 22:23:30 +0000 (18:23 -0400)]
encoding/asn1: promote untyped strings to UTF8 as needed.
Previously, strings that didn't have an explicit ASN.1 string type
were taken to be ASN.1 PrintableStrings. This resulted in an error if
a unrepresentable charactor was included.
For compatibility reasons, I'm too afraid to switch the default string
type to UTF8String, but this patch causes untyped strings to become
UTF8Strings if they contain a charactor that's not valid in a
PrintableString.
Fixes #3791.
R=golang-dev, bradfitz, r, r
CC=golang-dev
https://golang.org/cl/6348074
David G. Andersen [Sun, 8 Jul 2012 23:16:10 +0000 (09:16 +1000)]
pkg: Removing duplicated words ("of of", etc.), mostly from comments.
Ran 'double.pl' on the pkg tree to identify doubled words.
One change to an error string return in x509; the rest are in comments.
Thanks to Matt Jibson for the idea.
Made the following changes:
- Export errprintf() from all three OS-specific modules
- Added errprintf() to a.h
- Moved errprintf() in windows.c under xprintf(), since they are so similar
- Replaced all instances of xprintf() with errprintf() where a vflag check is done
Fixes #3788.
Shenghou Ma [Thu, 5 Jul 2012 20:52:13 +0000 (16:52 -0400)]
misc/chrome/gophertool: fix manifest
according to http://code.google.com/chrome/extensions/browserAction.html,
it should use "default_popup" instead of "popup".
runtime: move panic/defer/recover-related stuff to a separate file
Move panic/defer/recover-related stuff from proc.c/runtime.c to a new file panic.c.
No semantic changes.
proc.c is 1800+ LOC and is a bit difficult to work with.
R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6343071
The use of math.Pow for mere squaring can be extremely
slow on soft-float ARM. Even on systems with hardware
floating-point, a speedup in test duration is observed.
On amd64
Before: ok math/rand 2.009s
After: ok math/rand 0.340s
Fixes #3740.
R=dave, golang-dev, r, r
CC=golang-dev
https://golang.org/cl/6348061
David G. Andersen [Tue, 3 Jul 2012 15:16:43 +0000 (08:16 -0700)]
syscall: fix FreeBSD 386 sendfile
The previous version was not handling an off_t (64 bit)
parameter on 32 bit i386 systems. This patch splits sendfile
into two implementations in their respective arch-specific files.
Tested on FreeBSD amd64 and i386.
runtime: refactor proc.c
1. Rename 'g' and 'm' local vars to 'gp' and 'mp' (convention already used in some functions)
'g' and 'm' are global vars that mean current goroutine and current machine,
when they are shadowed by local vars, it's confusing, no ability to debug log both, etc.
2. White-space shuffling.
No semantic changes.
In preparation to bigger changes.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6355061
Nigel Tao [Mon, 2 Jul 2012 23:09:05 +0000 (09:09 +1000)]
cmd/gc: cache itab lookup in convT2I.
There may be further savings if convT2I can avoid the function call
if the cache is good and T is uintptr-shaped, a la convT2E, but that
will be a follow-up CL.
src/pkg/runtime:
benchmark old ns/op new ns/op delta
BenchmarkConvT2ISmall 43 15 -64.01%
BenchmarkConvT2IUintptr 45 14 -67.48%
BenchmarkConvT2ILarge 130 101 -22.31%
David G. Andersen [Mon, 2 Jul 2012 22:30:00 +0000 (15:30 -0700)]
math/big: Remove unnecessary test from nat.go multiplication
The switch at the beginning of the function already ensures n > 1,
so testing for n < 2 is redundant.
reflect: set GOMAXPROCS=1 in the malloc test
Occasionally I see:
--- FAIL: TestAllocations-15 (0.00 seconds)
all_test.go:1575: 6 mallocs after 100 iterations
Tested:
$ go test -cpu=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 reflect
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/6354063
test: enforce 1 proc in the test
otherwise it fails spuriously with "newfunc allocated unexpectedly" message
when run with GOMAXPROCS>1 (other goroutine allocates).
Pieter Droogendijk [Sat, 30 Jun 2012 14:27:05 +0000 (00:27 +1000)]
cmd/dist: Make windows.c's fatal() print to stderr
Generating env.bat using dist env -wp > env.bat failed silently
if case of an error, because the message was redirected to env.bat.
Verbose messages still go to stdout, causing problems, but that's
a seperate change.
Made errprintf() identical to xprintf(), except for the output handle.
Yes, it's duplicate code, but most of the function is unpacking
the argument list and preparing it for WriteFile(), which has to be
done anyway.
Robert Griesemer [Thu, 28 Jun 2012 19:22:24 +0000 (12:22 -0700)]
go spec: clean up section on selectors
- point out difference between selectors and qualified identifiers
- differentiate between illegal selectors and run-time panics
- use "indirect" as opposed to "dereference" consistently
- add extra links
Fixes #3779.
R=r, rsc, iant, ken
CC=golang-dev
https://golang.org/cl/6326059
Pieter Droogendijk [Mon, 25 Jun 2012 21:20:48 +0000 (17:20 -0400)]
go/build: fix doc typo
go/build section "Build Constraints", first paragraph said:
"... they must be appear near the top of the file ..."
fixed to:
"... they must appear near the top of the file ..."
Amir Mohammad Saied [Mon, 25 Jun 2012 21:19:08 +0000 (17:19 -0400)]
misc/chrome/gophertool: Support for manifest version 1 is being phased out.
Manifest version 1 was deprecated in Chrome 18, and support will be phased
out according to the schedule available at:
http://code.google.com/chrome/extensions/manifestVersion.html
Micah Stetson [Mon, 25 Jun 2012 20:03:18 +0000 (16:03 -0400)]
encoding/json: simplify (*decodeState).indirect
Removes an incorrect code comment and some superfluous variables.
The comment I removed says that struct fields which implement
Unmarshaler must be pointers, even if they're in an addressable
struct. That's not the case, and there's already a test in decode_test.go
that demonstrates as much.
Encoding/json has quite a few assignments of reflect.Values to extra
variables – things like "iv := v" when there's no need to make a copy. I
think these are left over from a previous version of the reflect API. If they
aren't wanted, I wouldn't mind going through the package and getting
rid of the rest of them.
Dave Cheney [Mon, 25 Jun 2012 13:01:34 +0000 (23:01 +1000)]
runtime: remove memset/memclr shim
This CL resolves https://golang.org/cl/6300043/#msg3
by renaming memset_arm.s to memclr_arm.s and merging the function
of the same name from asm_arm.s.
Dmitriy Vyukov [Mon, 25 Jun 2012 07:08:09 +0000 (11:08 +0400)]
runtime: fix potential GC deadlock
The issue seems to not be triggered right now,
but I've seen the deadlock after some other legal
modifications to runtime.
So I think we are safer this way.
R=rsc, r
CC=golang-dev
https://golang.org/cl/6339051
Russ Cox [Sun, 24 Jun 2012 23:47:50 +0000 (19:47 -0400)]
runtime: detect hash map collision problems
This can only happen if the hash function we're using is getting
far more than it's fair share of collisions, but that has happened
to us repeatedly as we've expanded the allowed use cases for
hash tables (issue 1544, issue 2609, issue 2630, issue 2883, issue 3695).
Maybe this will help the next time we try something new.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6306083
Charles L. Dorian [Sun, 24 Jun 2012 23:39:07 +0000 (19:39 -0400)]
math: improve Atan, Asin and Acos accuracy
pkg/math/all_test.go tests Atan (and therefore Asin and Acos) to a
relative accuracy of 4e-16, but the test vector misses values where
the old algorithm was in error by more than that. For example:
David G. Andersen [Fri, 22 Jun 2012 22:07:22 +0000 (15:07 -0700)]
net/rpc: fix typo in documentation, clarify semantics of error return
Several of my students were confused by trying to use both the error
return and a reply return, so I figured it was worth explicitly clarifying
that returning an error overrides the reply.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6327051
Adam Langley [Wed, 20 Jun 2012 20:18:56 +0000 (16:18 -0400)]
crypto/x509: add extended key usage support.
Flame motivated me to get around to adding extended key usage support
so that code signing certificates can't be used for TLS server
authentication and vice versa.