Adam Langley [Mon, 12 Jan 2015 21:58:30 +0000 (13:58 -0800)]
crypto/x509: write exact BitLength in ASN.1 encoding for certificate KeyUsage
The encoded value of the certificate KeyUsage did contain additonal padding
that was not present with other certificate generators. According to ITU-T
X.690 the BitLength value should have no padding in a DER encoding.
See discussion:
https://groups.google.com/forum/#!topic/golang-nuts/dzaJ3hMpDcs
This CL has been discussed at: http://golang.org/cl/168990043
Change-Id: I1eff3f441b0566966a2d279631901ad9287c917d
Reviewed-on: https://go-review.googlesource.com/2255 Reviewed-by: Adam Langley <agl@golang.org>
Martin Möhrmann [Wed, 7 Jan 2015 18:56:06 +0000 (19:56 +0100)]
time: correctly parse large input durations and avoid precision loss
Do not lose precision for durations specified without fractions
that can be represented by an int64 such as 1<<53+1 nanoseconds.
Previously there was some precision lost in floating point conversion.
Handle overflow for durations above 1<<63-1 nanoseconds but not earlier.
Rob Pike [Wed, 14 Jan 2015 23:43:04 +0000 (10:43 +1100)]
test: comment the behavior and use of cmplxdivide*
The various files are confusingly named and their operation
not easy to see. Add a comment to cmplxdivide.c, one of the few
C files that will endure in the repository, to explain how to build
and run the test.
Matthew Dempsky [Wed, 14 Jan 2015 21:30:34 +0000 (13:30 -0800)]
runtime: fix *bsd/amd64 build
6g does not implement dead code elimination for const switches like it
does for const if statements, so the undefined raiseproc() function
was resulting in a link-time failure.
Russ Cox [Wed, 14 Jan 2015 21:36:41 +0000 (16:36 -0500)]
runtime: avoid race checking for preemption
Moving the "don't really preempt" check up earlier in the function
introduced a race where gp.stackguard0 might change between
the early check and the later one. Since the later one is missing the
"don't really preempt" logic, it could decide to preempt incorrectly.
Pull the result of the check into a local variable and use an atomic
to access stackguard0, to eliminate the race.
I believe this will fix the broken OS X and Solaris builders.
David du Colombier [Wed, 14 Jan 2015 21:20:03 +0000 (22:20 +0100)]
runtime: define netpollinited on Plan 9
Since CL 2750, the build is broken on Plan 9,
because a new function netpollinited was added
and called from findrunnable in proc1.go.
However, netpoll is not implemented on Plan 9.
Thus, we define netpollinited in netpoll_stub.go.
Russ Cox [Wed, 14 Jan 2015 19:13:55 +0000 (14:13 -0500)]
runtime: change tinyalloc, persistentalloc not to point past allocated data
During all.bash I got a crash in the GOMAXPROCS=2 runtime test reporting
that the write barrier in the assignment 'c.tiny = add(x, size)' had been
given a pointer pointing into an unexpected span. The problem is that
the tiny allocation was at the end of a span and c.tiny was now pointing
to the end of the allocation and therefore to the end of the span aka
the beginning of the next span.
Rewrite tinyalloc not to do that.
More generally, it's not okay to call add(p, size) unless you know that p
points at > (not just >=) size bytes. Similarly, pretty much any call to
roundup doesn't know how much space p points at, so those are all
broken.
Rewrite persistentalloc not to use add(p, totalsize) and not to use roundup.
There is only one use of roundup left, in vprintf, which is dead code.
I will remove that code and roundup itself in a followup CL.
Russ Cox [Wed, 14 Jan 2015 19:57:10 +0000 (14:57 -0500)]
runtime: fix accounting race in printlock
It could happen that mp.printlock++ happens, then on entry to lock,
the goroutine is preempted and then rescheduled onto another m
for the actual call to lock. Now the lock and the printlock++ have
happened on different m's. This can lead to printlock not being
unlocked, which either gives a printing deadlock or a crash when
the goroutine reschedules, because m.locks > 0.
Change-Id: Ib0c08740e1b53de3a93f7ebf9b05f3dceff48b9f
Reviewed-on: https://go-review.googlesource.com/2819 Reviewed-by: Rick Hudson <rlh@golang.org>
Russ Cox [Mon, 12 Jan 2015 20:17:10 +0000 (15:17 -0500)]
liblink: adjustments for c2go conversion
Mostly this is using uint32 instead of int32 for unsigned values
like instruction encodings or float32 bit representations,
removal of ternary operations, and removal of #defines.
Delete sched9.c, because it is not compiled (it is still in the history
if we ever need it).
Russ Cox [Wed, 14 Jan 2015 16:18:24 +0000 (11:18 -0500)]
runtime: log all thread stack traces during GODEBUG=crash on Linux and OS X
Normally, a panic/throw only shows the thread stack for the current thread
and all paused goroutines. Goroutines running on other threads, or other threads
running on their system stacks, are opaque. Change that when GODEBUG=crash,
by passing a SIGQUIT around to all the threads when GODEBUG=crash.
If this works out reasonably well, we might make the SIGQUIT relay part of
the standard panic/throw death, perhaps eliding idle m's.
Change-Id: If7dd354f7f3a6e326d17c254afcf4f7681af2f8b
Reviewed-on: https://go-review.googlesource.com/2811 Reviewed-by: Rick Hudson <rlh@golang.org>
David Crawshaw [Wed, 14 Jan 2015 15:20:58 +0000 (10:20 -0500)]
syscall: match seek argument size to signature
Caught by go vet:
asm_linux_arm.s:110: [arm] seek: wrong argument size 32; expected $...-28
Change-Id: I62ec5327a25bff9ef501c42cc1e28ea7ec78510f
Reviewed-on: https://go-review.googlesource.com/2810 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Dmitry Vyukov [Tue, 13 Jan 2015 17:12:50 +0000 (20:12 +0300)]
runtime: fix spurious deadlock in netpoll
There is a small possibility that runtime deadlocks when netpoll is just activated.
Consider the following scenario:
GOMAXPROCS=1
epfd=-1 (netpoll is not activated yet)
A thread is in findrunnable, sets sched.lastpoll=0, calls netpoll(true),
which returns nil. Now the thread is descheduled for some time.
Then sysmon retakes a P from syscall and calls handoffp.
The "If this is the last running P and nobody is polling network" check in handoffp fails,
since the first thread set sched.lastpoll=0. So handoffp decides that there is already
a thread that polls network and so it calls pidleput.
Now the first thread is scheduled again, finds no work and calls stopm.
There is no thread that polls network and so checkdead reports deadlock.
To fix this, don't set sched.lastpoll=0 when netpoll is not activated.
The deadlock can happen if cgo is disabled (-tag=netgo) and only on program startup
(when netpoll is just activated).
The test is from issue 5216 that lead to addition of the
"If this is the last running P and nobody is polling network" check in handoffp.
Update issue 9576.
Change-Id: I9405f627a4d37bd6b99d5670d4328744aeebfc7a
Reviewed-on: https://go-review.googlesource.com/2750 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Mon, 12 Jan 2015 18:45:40 +0000 (13:45 -0500)]
runtime: rename var checkmark to checkmarkphase
The old name was too ambiguous (is it a verb? is it a predicate? is
it a constant?) and too close to debug.gccheckmark. Hopefully the new
name conveys that this variable indicates that we are currently doing
mark checking.
Change-Id: I031cd48b0906cdc7774f5395281d3aeeb8ef3ec9
Reviewed-on: https://go-review.googlesource.com/2656 Reviewed-by: Rick Hudson <rlh@golang.org>
Russ Cox [Tue, 13 Jan 2015 20:55:16 +0000 (15:55 -0500)]
runtime: fix a few GC-related bugs
1) Move non-preemption check even earlier in newstack.
This avoids a few priority inversion problems.
2) Always use atomic operations to update bitmap for 1-word objects.
This avoids lost mark bits during concurrent GC.
3) Stop using work.nproc == 1 as a signal for being single-threaded.
The concurrent GC runs with work.nproc == 1 but other procs are
running mutator code.
The use of work.nproc == 1 in getfull *is* safe, but remove it anyway,
since it is saving only a single atomic operation per GC round.
Fixes #9225.
Change-Id: I24134f100ad592ea8cb59efb6a54f5a1311093dc
Reviewed-on: https://go-review.googlesource.com/2745 Reviewed-by: Rick Hudson <rlh@golang.org>
Russ Cox [Wed, 14 Jan 2015 06:23:26 +0000 (01:23 -0500)]
cmd/go: adjust error for custom import checkout mismatch
Before:
...
imports golang.org/x/net/context: /Users/rsc/g/src/golang.org/x/net is from https://code.google.com/p/go.net, should be from https://go.googlesource.com/net
After:
...
imports golang.org/x/net/context: golang.org/x/net is a custom import path for https://go.googlesource.com/net, but /Users/rsc/g/src/golang.org/x/net is checked out from https://code.google.com/p/go.net
Change-Id: I93c35b85f955c7de684f71fbd4baecc717405318
Reviewed-on: https://go-review.googlesource.com/2808 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Rob Pike <r@golang.org>
David Crawshaw [Tue, 13 Jan 2015 19:18:13 +0000 (14:18 -0500)]
syscall: use name+(NN)FP for darwin
Generated from a script using go vet then read by a human.
Change-Id: Ie5f7ab3a1075a9c8defbf5f827a8658e3eb55cab
Reviewed-on: https://go-review.googlesource.com/2746 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Nigel Tao [Mon, 5 Jan 2015 05:08:40 +0000 (16:08 +1100)]
image/draw: fold TestClipWithNilMP into TestClip.
https://go-review.googlesource.com/#/c/1876/ introduced a new
TestClipWithNilMP test, along with a code change that fixed a panic,
but the existing TestClip test already contained almost enough machinery
to cover that bug.
There is a small code change in this CL, but it is a no-op: (*x).y is
equivalent to x.y for a pointer-typed x, but the latter is cleaner.
Change-Id: I79cf6952a4999bc4b91f0a8ec500acb108106e56
Reviewed-on: https://go-review.googlesource.com/2304 Reviewed-by: Dave Cheney <dave@cheney.net>
Dave Cheney [Sun, 11 Jan 2015 03:40:08 +0000 (03:40 +0000)]
runtime: use runtime.sysargs to parse auxv on linux/arm
Make auxv parsing in linux/arm less of a special case.
* rename setup_auxv to sysargs
* exclude linux/arm from vdso_none.go
* move runtime.checkarm after runtime.sysargs so arm specific
values are properly initialised
Change-Id: I1ca7f5844ad5a162337ff061a83933fc9a2b5ff6
Reviewed-on: https://go-review.googlesource.com/2681 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Martin Möhrmann [Fri, 9 Jan 2015 22:25:42 +0000 (23:25 +0100)]
sort: reduce number of comparisons needed by medianOfThree
For some cases we can ensure the correct order of elements in two
instead of three comparisons. It is unnecessary to compare m0 and
m1 again if m2 and m1 are not swapped.
Andrew Gerrand [Tue, 13 Jan 2015 05:33:55 +0000 (16:33 +1100)]
runtime: allow fake time writes to both stdout and stderr
In the previous sandbox implementation we read all sandboxed output
from standard output, and so all fake time writes were made to
standard output. Now we have a more sophisticated sandbox server
(see golang.org/x/playground/sandbox) that is capable of recording
both standard output and standard error, so allow fake time writes to
go to either file descriptor.
Change-Id: I79737deb06fd8e0f28910f21f41bd3dc1726781e
Reviewed-on: https://go-review.googlesource.com/2713 Reviewed-by: Minux Ma <minux@golang.org>
Brad Fitzpatrick [Tue, 13 Jan 2015 01:23:18 +0000 (17:23 -0800)]
net/http: deflake TestResponseWriterWriteStringAllocs, test interface instead
Skip the allocation testing (which was only used as a signal for
whether the interface was implemented by ResponseWriter), and just
test for it directly.
Fixes #9575
Change-Id: Ie230f1d21b104537d5647e9c900a81509d692469
Reviewed-on: https://go-review.googlesource.com/2720 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Paul van Brouwershaven [Mon, 5 Jan 2015 11:27:40 +0000 (11:27 +0000)]
crypto/x509: Correction of incrorrect default version number in TBSCertificateList and Certificate.CreateCRL
RFC5280 states:
"This optional field describes the version of the encoded CRL. When
extensions are used, as required by this profile, this field MUST be
present and MUST specify version 2 (the integer value is 1)."
This CL has been discussed at: http://golang.org/cl/172560043
Change-Id: I8a72d7593d5ca6714abe9abd6a37437c3b69ab0f
Reviewed-on: https://go-review.googlesource.com/2259 Reviewed-by: Adam Langley <agl@golang.org>
David Leon Gil [Sat, 27 Dec 2014 02:24:39 +0000 (18:24 -0800)]
crypto/elliptic: add Name field to CurveParams struct
And add names for the curve implemented in crypto/elliptic.
This permits a safer alternative to switching on BitSize
for code that implements curve-dependent cryptosystems.
(E.g., ECDSA on P-xxx curves with the matched SHA-2
instances.)
Change-Id: I653c8f47506648028a99a96ebdff8389b2a95fc1
Reviewed-on: https://go-review.googlesource.com/2133 Reviewed-by: Adam Langley <agl@golang.org>
Paul van Brouwershaven [Mon, 5 Jan 2015 11:10:05 +0000 (11:10 +0000)]
crypto/x509: NULL parameter MUST be present in the Signature Algorithm (RSA)
According to RFC4055 a NULL parameter MUST be present in the signature
algorithm. This patch adds the NULL value to the Signature Algorithm
parameters in the signingParamsForPrivateKey function for RSA based keys.
Section 2.1 states:
"There are two possible encodings for the AlgorithmIdentifier
parameters field associated with these object identifiers. The two
alternatives arise from the loss of the OPTIONAL associated with the
algorithm identifier parameters when the 1988 syntax for
AlgorithmIdentifier was translated into the 1997 syntax. Later the
OPTIONAL was recovered via a defect report, but by then many people
thought that algorithm parameters were mandatory. Because of this
history some implementations encode parameters as a NULL element
while others omit them entirely. The correct encoding is to omit the
parameters field; however, when RSASSA-PSS and RSAES-OAEP were
defined, it was done using the NULL parameters rather than absent
parameters.
All implementations MUST accept both NULL and absent parameters as
legal and equivalent encodings.
To be clear, the following algorithm identifiers are used when a NULL
parameter MUST be present:
Shenghou Ma [Mon, 12 Jan 2015 05:12:59 +0000 (00:12 -0500)]
cmd/cgo: also rewrite C.var in selector expressions
While we're here, rename TestIssue7234 to Test7234 for consistency
with other tests.
Fixes #9557.
Change-Id: I22b0a212b31e7b4f199f6a70deb73374beb80f84
Reviewed-on: https://go-review.googlesource.com/2654 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Shenghou Ma [Fri, 9 Jan 2015 02:49:28 +0000 (21:49 -0500)]
syscall: fix nacl builds
Please see golang.org/cl/2588 for reasons behind the name change.
We also need NO_LOCAL_POINTERS for assembly function with non-zero
local frame size.
Change-Id: Iac60aa7e76f4c2ece3726e28878fd539bfebf7a4
Reviewed-on: https://go-review.googlesource.com/2589 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Fri, 9 Jan 2015 19:00:40 +0000 (14:00 -0500)]
runtime: add GODEBUG=gccheckmark=0/1
Previously, gccheckmark could only be enabled or disabled by calling
runtime.GCcheckmarkenable/GCcheckmarkdisable. This was a necessary
hack because GODEBUG was broken.
Now that GODEBUG works again, move control over gccheckmark to a
GODEBUG variable and remove these runtime functions. Currently,
gccheckmark is enabled by default (and will probably remain so for
much of the 1.5 development cycle).
Change-Id: I2bc6f30c21b795264edf7dbb6bd7354b050673ab
Reviewed-on: https://go-review.googlesource.com/2603 Reviewed-by: Rick Hudson <rlh@golang.org>
Shenghou Ma [Fri, 9 Jan 2015 00:09:56 +0000 (19:09 -0500)]
runtime: source startupRandomData from auxv AT_RANDOM on linux/arm.
Fixes #9541.
Change-Id: I5d659ad50d7c3d1c92ed9feb86cda4c1a6e62054
Reviewed-on: https://go-review.googlesource.com/2584 Reviewed-by: Dave Cheney <dave@cheney.net> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Wed, 7 Jan 2015 17:25:23 +0000 (09:25 -0800)]
cmd/gc: pad structs which end in zero-sized fields
For a non-zero-sized struct with a final zero-sized field,
add a byte to the size (before rounding to alignment). This
change ensures that taking the address of the zero-sized field
will not incorrectly leak the following object in memory.
Rick Hudson [Tue, 6 Jan 2015 19:58:49 +0000 (14:58 -0500)]
runtime: increase GC concurrency.
run GC in its own background goroutine making the
caller runnable if resources are available. This is
critical in single goroutine applications.
Allow goroutines that allocate a lot to help out
the GC and in doing so throttle their own allocation.
Adjust test so that it only detects that a GC is run
during init calls and not whether the GC is memory
efficient. Memory efficiency work will happen later
in 1.5.
Austin Clements [Wed, 7 Jan 2015 20:34:02 +0000 (15:34 -0500)]
runtime: improve GC times printing
This improves the printing of GC times to be both more human-friendly
and to provide enough information for the construction of MMU curves
and other statistics. The new times look like:
This prints gomaxprocs and the number of procs used in each phase for
the benefit of analyzing mutator utilization during concurrent phases.
This also means the analysis doesn't have to hard-code which phases
are STW.
This prints the absolute start time only for the GC cycle. The other
start times can be derived from the phase durations. This declutters
the view for humans readers and doesn't pose any additional complexity
for machine readers.
This removes the confusing "cycle" terminology. Instead, this places
the phase duration after the phase name and adds a "ns" unit, which
both makes it implicitly clear that this is the duration of that phase
and indicates the units of the times.
This adds a "GC:" prefix to all lines for easier identification.
Finally, this generally cleans up the code as well as the placement of
spaces in the output and adds print locking so the statistics blocks
are never interrupted by other prints.
Change-Id: Ifd056db83ed1b888de7dfa9a8fc5732b01ccc631
Reviewed-on: https://go-review.googlesource.com/2542 Reviewed-by: Rick Hudson <rlh@golang.org>
Robert Griesemer [Wed, 7 Jan 2015 19:11:57 +0000 (11:11 -0800)]
math/big: faster "pure Go" addition/subtraction for long vectors
(platforms w/o corresponding assembly kernels)
For short vector adds there's some erradic slow-down, but overall
these routines have become significantly faster. This only matters
for platforms w/o native (assembly) versions of these kernels, so
we are not concerned about the minor slow-down for short vectors.
This code was already reviewed under Mercurial (golang.org/cl/172810043)
but wasn't submitted before the switch to git.
Benchmarks run on 2.3GHz Intel Core i7, running OS X 10.9.5,
with the respective AddVV and AddVW assembly routines disabled.
Robert Griesemer [Thu, 8 Jan 2015 01:16:59 +0000 (17:16 -0800)]
math/big: faster assembly kernels for AddVx/SubVx for amd64.
Replaced use of rotate instructions (RCRQ, RCLQ) with ADDQ/SBBQ
for restoring/saving the carry flag per suggestion from Torbjörn
Granlund (author of GMP bignum libs for C).
The rotate instructions tend to be slower on todays machines.
Brad Fitzpatrick [Thu, 8 Jan 2015 04:10:32 +0000 (20:10 -0800)]
build: add GOTESTONLY environment test for Plan 9's run.rc
$GOTESTONLY controls which set of tests gets run. Only "std" is
supported. This should bring the time of plan9 builder down
from 90 minutes to a maybe 10-15 minutes when running on GCE.
(Plan 9 has performance problems when running on GCE, and/or with the
os/exec package)
This is a temporary workaround for one builder. The other Plan 9
builders will continue to do full builds. The plan9 buidler will be
renamed plan9-386-gcepartial or something to indicate it's not running
the 'test/*' directory, or API tests. Go on Plan 9 has bigger problems
for now. This lets us get trybots going sooner including Plan 9,
without waiting 90+ minutes.
Update #9491
Change-Id: Ic505e9169c6b304ed4029b7bdfb77bb5c8fa8daa
Reviewed-on: https://go-review.googlesource.com/2522 Reviewed-by: Rob Pike <r@golang.org>
Matthew Dempsky [Thu, 8 Jan 2015 00:30:24 +0000 (16:30 -0800)]
cmd/cgo, go/build: finish a cleanup TODO
Removing #cgo directive parsing from cmd/cgo was done in
https://golang.org/cl/8610044.
Change-Id: Id1bec58c6ec1f932df0ce0ee84ff253655bb73ff
Reviewed-on: https://go-review.googlesource.com/2501 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Shenghou Ma [Wed, 7 Jan 2015 06:23:45 +0000 (01:23 -0500)]
misc/swig/stdio: fix broken nil pointer test
SWIG has always returned a typed interface value for a C++ class,
so the interface value will never be nil even if the pointer itself
is NULL. ptr == NULL in C/C++ should be ptr.Swigcptr() == 0 in Go.
Fixes #9514.
Change-Id: I3778b91acf54d2ff22d7427fbf2b6ec9b9ce3b43
Reviewed-on: https://go-review.googlesource.com/2440 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Matthew Dempsky [Wed, 7 Jan 2015 21:23:45 +0000 (13:23 -0800)]
cmd/cgo: remove obsolete -cdefs flag
Now that there's no 6c compiler anymore, there's no need for cgo to
generate C headers that are compatible with it.
Fixes #9528
Change-Id: I43f53869719eb9a6065f1b39f66f060e604cbee0
Reviewed-on: https://go-review.googlesource.com/2482 Reviewed-by: Ian Lance Taylor <iant@golang.org>
cmd/6g, cmd/8g, liblink: improve handling of float constants
* Enable basic constant propagation for floats.
The constant propagation is still not as aggressive as it could be.
* Implement MOVSS $(0), Xx and MOVSD $(0), Xx as XORPS Xx, Xx.
Keith Randall [Wed, 7 Jan 2015 00:42:48 +0000 (16:42 -0800)]
runtime: remove size argument from hash and equal algorithms
The equal algorithm used to take the size
equal(p, q *T, size uintptr) bool
With this change, it does not
equal(p, q *T) bool
Similarly for the hash algorithm.
The size is rarely used, as most equal functions know the size
of the thing they are comparing. For instance f32equal already
knows its inputs are 4 bytes in size.
For cases where the size is not known, we allocate a closure
(one for each size needed) that points to an assembly stub that
reads the size out of the closure and calls generic code that
has a size argument.
Reduces the size of the go binary by 0.07%. Performance impact
is not measurable.
Keith Randall [Sun, 28 Dec 2014 03:26:40 +0000 (19:26 -0800)]
runtime: faster version of findfunc
Use a lookup table to find the function which contains a pc. It is
faster than the old binary search. findfunc is used primarily for
stack copying and garbage collection.
benchmark old ns/op new ns/op delta
BenchmarkStackCopy 294746596255400980 -13.35%
(findfunc is one of several tasks done by stack copy, the findfunc
time itself is about 2.5x faster.)
The lookup table is built at link time. The table grows the binary
size by about 0.5% of the text segment.
We impose a lower limit of 16 bytes on any function, which should not
have much of an impact. (The real constraint required is <=256
functions in every 4096 bytes, but 16 bytes/function is easier to
implement.)
Austin Clements [Tue, 16 Dec 2014 23:34:55 +0000 (18:34 -0500)]
cmd/cgo, runtime/cgo: support ppc64
This implements support for calls to and from C in the ppc64 C ABI, as
well as supporting functionality such as an entry point from the
dynamic linker.
Austin Clements [Tue, 16 Dec 2014 18:52:09 +0000 (13:52 -0500)]
cmd/9g: don't use R13
R13 is the C TLS pointer. Once we're calling to and from C code, if
we clobber R13 in our code, sigtramp won't know whether to get the
current g from REGG or from C TLS. The simplest solution is for Go
code to preserve the C TLS pointer. This is equivalent to what other
platforms do, except that on other platforms the TLS pointer is in a
special register.
Austin Clements [Tue, 16 Dec 2014 19:59:59 +0000 (14:59 -0500)]
cmd/9l: support internal linking
This implements the ELF relocations and dynamic linking tables
necessary to support internal linking on ppc64. It also marks ppc64le
ELF files as ABI v2; failing to do this doesn't seem to confuse the
loader, but it does confuse libbfd (and hence gdb, objdump, etc).
Austin Clements [Mon, 22 Dec 2014 19:42:37 +0000 (14:42 -0500)]
cmd/ld: support for relocation variants
Most ppc64 relocations come in six or more variants where the basic
relocation formula is the same, but which bits of the computed value
are installed where changes. Introduce the concept of "variants" for
internal relocations to support this. Since this applies to
architecture-independent relocation types like R_PCREL, we do this in
relocsym.
Currently there is only an identity variant. A later CL that adds
support for ppc64 ELF relocations will introduce more.
Austin Clements [Tue, 16 Dec 2014 19:01:08 +0000 (14:01 -0500)]
cmd/ld: decode local entry offset from ppc64 symbols
ppc64 function symbols have both a global entry point and a local
entry point, where the difference is stashed in sym.other. We'll need
this information to generate calls to ELF ABI functions.
Keith Randall [Sat, 27 Dec 2014 02:10:59 +0000 (18:10 -0800)]
runtime: increase number of stack orders to 4
Cache 2KB, 4KB, 8KB, and 16KB stacks. Larger stacks
will be allocated directly. There is no point in cacheing
32KB+ stacks as we ask for and return 32KB at a time
from the allocator.
Note that the minimum stack is 8K on windows/64bit and 4K on
windows/32bit and plan9. For these os/arch combinations,
the number of stack orders is less so that we have the same
maximum cached size.
Keith Randall [Wed, 7 Jan 2015 04:38:44 +0000 (20:38 -0800)]
runtime: remove trailing empty arrays in structs
The ones at the end of M and G are just used to compute
their size for use in assembly. Generate the size explicitly.
The one at the end of itab is variable-sized, and at least one.
The ones at the end of interfacetype and uncommontype are not
needed, as the preceding slice references them (the slice was
originally added for use by reflect?).
The one at the end of stackmap is already accessed correctly,
and the runtime never allocates one.
Update #9401
Change-Id: Ia75e3aaee38425f038c506868a17105bd64c712f
Reviewed-on: https://go-review.googlesource.com/2420 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
Keith Randall [Tue, 6 Jan 2015 17:06:44 +0000 (09:06 -0800)]
runtime: use some startup randomness in the fallback hashes
Fold in some startup randomness to make the hash vary across
different runs. This helps prevent attackers from choosing
keys that all map to the same bucket.
Also, reorganize the hash a bit. Move the *m1 multiply to after
the xor of the current hash and the message. For hash quality
it doesn't really matter, but for DDOS resistance it helps a lot
(any processing done to the message before it is merged with the
random seed is useless, as it is easily inverted by an attacker).
Update #9365
Change-Id: Ib19968168e1bbc541d1d28be2701bb83e53f1e24
Reviewed-on: https://go-review.googlesource.com/2344 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Matthew Dempsky [Tue, 6 Jan 2015 23:08:02 +0000 (15:08 -0800)]
cmd/cgo: update code and docs to reflect post-6c world
The gc toolchain no longer includes a C compiler, so mentions of "6c"
can be removed or replaced by 6g as appropriate. Similarly, some cgo
functions that previously generated C source output no longer need to.
Change-Id: I1ae6b02630cff9eaadeae6f3176c0c7824e8fbe5
Reviewed-on: https://go-review.googlesource.com/2391 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Fri, 2 Jan 2015 18:02:15 +0000 (10:02 -0800)]
bufio: add Reader.Discard
Reader.Discard is the complement to Peek. It discards the next n bytes
of input.
We already have Reader.Buffered to see how many bytes of data are
sitting available in memory, and Reader.Peek to get that that buffer
directly. But once you're done with the Peek'd data, you can't get rid
of it, other than Reading it.
Both Read and io.CopyN(ioutil.Discard, bufReader, N) are relatively
slow. People instead resort to multiple blind ReadByte calls, just to
advance the internal b.r variable.
I've wanted this previously, several people have asked for it in the
past on golang-nuts/dev, and somebody just asked me for it again in a
private email. There are a few places in the standard library we'd use
it too.
Shenghou Ma [Wed, 7 Jan 2015 01:40:16 +0000 (20:40 -0500)]
runtime: fix build for race detector
This CL only fixes the build, there are two failing tests:
RaceMapBigValAccess1 and RaceMapBigValAccess2
in runtime/race tests. I haven't investigated why yet.
Russ Cox [Wed, 31 Dec 2014 03:39:48 +0000 (22:39 -0500)]
runtime: allocate wbshadow at high address
sysReserve doesn't actually reserve the full amount requested on
64-bit systems, because of problems with ulimit. Instead it checks
that it can get the first 64 kB and assumes it can grab the rest as
needed. This doesn't work well with the "let the kernel pick an address"
mode, so don't do that. Pick a high address instead.
Change-Id: I4de143a0e6fdeb467fa6ecf63dcd0c1c1618a31c
Reviewed-on: https://go-review.googlesource.com/2345 Reviewed-by: Rick Hudson <rlh@golang.org>
Russ Cox [Tue, 6 Jan 2015 18:46:13 +0000 (13:46 -0500)]
misc/cgo: disable TestAllocateFromC in wbshadow mode
This test is doing pointer graph manipulation from C, and we
cannot support that with concurrent GC. The wbshadow mode
correctly diagnoses missing write barriers.
Disable the test in that mode for now. There is a bigger issue
behind it, namely SWIG, but for now we are focused on making
all.bash pass with wbshadow enabled.
Change-Id: I55891596d4c763e39b74082191d4a5fac7161642
Reviewed-on: https://go-review.googlesource.com/2346 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Adam Langley [Fri, 19 Dec 2014 23:14:03 +0000 (15:14 -0800)]
crypto/tls: fix renegotiation extension.
There are two methods by which TLS clients signal the renegotiation
extension: either a special cipher suite value or a TLS extension.
It appears that I left debugging code in when I landed support for the
extension because there's a "+ 1" in the switch statement that shouldn't
be there.
The effect of this is very small, but it will break Firefox if
security.ssl.require_safe_negotiation is enabled in about:config.
(Although almost nobody does this.)
This change fixes the original bug and adds a test. Sadly the test is a
little complex because there's no OpenSSL s_client option that mirrors
that behaviour of require_safe_negotiation.