Andrew Gerrand [Mon, 29 Jul 2013 08:00:58 +0000 (18:00 +1000)]
[release-branch.go1.1] bufio: check buffer availability before reading in ReadFrom
This change was applied by hand, as bufio has seen some refactoring
since 1.1 was branched. The only difference between this and the
original patch is the offset of the change, and s/flush/Flush/.
««« CL 11801043 / 3ffbc06b4874
bufio: check buffer availability before reading in ReadFrom
Backends do not exactly expect receiving binary operators with
constant operands or use workarounds to move them to
register/stack in order to handle them.
Andrew Gerrand [Mon, 22 Jul 2013 23:50:35 +0000 (09:50 +1000)]
[release-branch.go1.1] runtime: prevent sysmon from polling network excessivly
««« CL 11569043 / 6b3c351c7fe6
runtime: prevent sysmon from polling network excessivly
If the network is not polled for 10ms, sysmon starts polling network
on every iteration (every 20us) until another thread blocks in netpoll.
Fixes issue 5922 .
Andrew Gerrand [Mon, 22 Jul 2013 23:40:49 +0000 (09:40 +1000)]
[release-branch.go1.1] cmd/8g: Make clearfat non-interleaved with pointer calculations.
««« CL 11383043 / dc24634de6c5
cmd/8g: Make clearfat non-interleaved with pointer calculations.
clearfat (used to zero initialize structures) will use AX for x86 block ops. If we write to AX while calculating the dest pointer, we will fill the structure with incorrect values.
Since 64-bit arithmetic uses AX to synthesize a 64-bit register, getting an adress by indexing with 64-bit ops can clobber the register.
Andrew Gerrand [Mon, 22 Jul 2013 13:45:28 +0000 (23:45 +1000)]
[release-branch.go1.1] cmd/gc: fix issue with method wrappers not having escape analysis run on them.
««« CL 10383048 / 58e15340e78f
cmd/gc: fix issue with method wrappers not having escape analysis run on them.
Escape analysis needs the right curfn value on a dclfunc node, otherwise it will not analyze the function.
When generating method value wrappers, we forgot to set the curfn correctly.
Andrew Gerrand [Mon, 22 Jul 2013 08:41:32 +0000 (18:41 +1000)]
[release-branch.go1.1] time: prevent a panic from leaving the timer mutex held
««« CL 10373047 / 974a69ed9fcf
time: prevent a panic from leaving the timer mutex held
When deleting a timer, a panic due to nil deref
would leave a lock held, possibly leading to a deadlock
in a defer. Instead return false on a nil timer.
This avoids problems with inlining in genwrappers, which
occurs after functions have been compiled. Compiling a
function may cause some unused local vars to be removed from
the list. Since a local var may be unused due to
optimization, it is possible that a removed local var winds up
beingused in the inlined version, in which case hilarity
ensues.
Fixes #5515.
R=golang-dev, khr, dave
CC=golang-dev
https://golang.org/cl/10210043
»»»
Andrew Gerrand [Wed, 5 Jun 2013 01:12:46 +0000 (11:12 +1000)]
[release-branch.go1.1] runtime: fix heap corruption during GC
««« CL 9831043 / e84e7204b01b
runtime: fix heap corruption during GC
The 'n' variable is used during rescan initiation in GC_END case,
but it's overwritten with chan capacity in GC_CHAN case.
As the result rescan is done with the wrong object size.
Fixes #5554.
Andrew Gerrand [Wed, 5 Jun 2013 01:07:26 +0000 (11:07 +1000)]
[release-branch.go1.1] test: do not run the test that relies on precise GC on 32-bits
««« CL 9573043 / c0f8999bd970
test: do not run the test that relies on precise GC on 32-bits
Currently most of the 32-bit builder are broken.
Fixes #5516.
Andrew Gerrand [Wed, 5 Jun 2013 00:20:34 +0000 (10:20 +1000)]
[release-branch.go1.1] runtime: fix GC scanning of slices
««« CL 9372044 / 1abed5873071
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.
Andrew Gerrand [Mon, 13 May 2013 16:35:18 +0000 (09:35 -0700)]
[release-branch.go1.1] runtime/race: improve public documentation
««« CL 9144050 / d29da2ced72b
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
»»»
Andrew Gerrand [Wed, 8 May 2013 23:02:59 +0000 (16:02 -0700)]
[release-branch.go1.1] runtime: fix crash in select
««« CL 9311043 / 53bc96b4c0c7
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
»»»
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9304044
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):
David du Colombier [Wed, 1 May 2013 22:48:13 +0000 (15:48 -0700)]
libmach: fix build on Plan 9
Include libc.h before bio.h in 8.c, because bio.h uses
the UTFmax enum, which is declared in libc.h, since
the recent switch to 21-bit runes in Plan 9.
The 5.c and 6.c files already includes libc.h.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9040047
Ian Lance Taylor [Wed, 1 May 2013 21:30:19 +0000 (14:30 -0700)]
cmd/ld: fix syms that are both cgo_import_static & cgo_import_dynamic
This is needed for SWIG when linking in internal mode. In
internal mode if a symbol was cgo_import_static we used to
forget that it was also cgo_import_dynamic.
R=rsc, r
CC=golang-dev
https://golang.org/cl/9080043
This makes the 'go run' command different from every other command.
For example, 'go test' does not mean 'go test *.go'.
If we were going to handle the no arguments case in 'go run', I would hope that
it would scan the current directory to find a package just like 'go build' or
'go test' would, and then it would require that package to be 'package main',
and then it would run that package. This would make it match 'go test' and 'go
build' and 'go install' and so on. It would mean that if you are working on a
command in a directory that is 'go install'able, then 'go run' will run the
binary for you. The current CL does not accomplish that when build constraints
or file name constraints are involved.
For example, if I am working on a program like:
$ ls
main.go
main_386.s
main_arm.s
main_amd64.s
$
Then 'go run' will fail here because the .s files are ignored.
If instead I am working on a program like:
$ ls
main.go
main_386.go
main_arm.go
main_amd64.go
$
then 'go run' will fail because too many files are included.
I would like to see this command implemented so that it is compatible with the
other go subcommands. Since it is too late to do that for Go 1.1, I would like
to see this CL reverted, to preserve the option to do it better later.
R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/8797049
Ian Lance Taylor [Tue, 30 Apr 2013 21:01:05 +0000 (14:01 -0700)]
cmd/ld: emit relocs for DWARF info when doing an external link
I would like opinions on whether this is a good idea for 1.1.
On the one hand it's a moderately important issue. On the
other hand this introduces at least the possibility of
external linker errors due to the additional relocations and
it may be better to wait.
I'm fairly confident that the behaviour is unchanged when not
using an external linker.
Update #5221
This CL is tested lightly on 386 and amd64 and fixes the cases
I tested. I have not tested it on Darwin or Windows.
Rob Pike [Tue, 30 Apr 2013 16:10:10 +0000 (09:10 -0700)]
cmd/ld: fix check for address wrap in relocation
PC-relative needs a signed offset; others need unsigned.
Also fix signedness of 32-bit relocation on Windows.
Rob Pike [Tue, 30 Apr 2013 05:44:40 +0000 (22:44 -0700)]
cmd/gc: fix some overflows in the compiler
Some 64-bit fields were run through 32-bit words, some counts were
not checked for overflow, and relocations must fit in 32 bits.
Tests to follow.
Rob Pike [Tue, 30 Apr 2013 05:44:20 +0000 (22:44 -0700)]
cmd/ld: fix some 64-bit issues
A few places in the linker pushed 64-bit values through 32-bit holes,
including in relocation.
Clean them up, and check for a few other overflows as well.
Tests to follow.
Shenghou Ma [Mon, 29 Apr 2013 20:13:32 +0000 (04:13 +0800)]
runtime: fix stack pointer corruption in runtime.cgocallback_gofunc()
runtime.setmg() calls another function (cgo_save_gm), so it must save
LR onto stack.
Re-enabled TestCthread test in misc/cgo/test.
Fixes #4863.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/9019043
database/sql: fix driver Conn refcounting with prepared statements
The refcounting of driver Conns was completedly busted and
would leak (be held open forever) with any reasonable
load. This was a significant regression from Go 1.0.
The core of this patch is removing one line:
s.db.addDep(dc, s)
A database conn (dc) is a resource that be re-created any time
(but cached for speed) should not be held open forever with a
dependency refcount just because the Stmt (s) is alive (which
typically last for long periods of time, like forever).
The meat of the patch is new tests. In fixing the real issue,
a lot of tests then failed due to the fakedb_test.go's paranoia
about closing a fakeConn while it has open fakeStmts on it. I
could've ignored that, but that's been a problem in the past for
other bugs.
Instead, I now track per-Conn open statements and close them
when the the conn closes. The proper way to do this would've
been making *driverStmt a finalCloser and using the dep mechanism,
but it was much more invasive. Added a TODO instead.
I'd like to give a way for drivers to opt-out of caring about
driver.Stmt closes before a driver.Conn close, but that's a TODO
for the future, and that TODO is added in this CL.
I know this is very late for Go 1.1, but database/sql is
currently nearly useless without this.
I'd like to believe all these database/sql bugs in the past
release cycle are the result of increased usage, number of
drivers, and good feedback from increasingly-capable Go
developers, and not the result of me sucking. It's also hard
with all the real drivers being out-of-tree, so I'm having to
add more and more hooks to fakedb_test.go to simulate things
which real drivers end up doing.
Fixes #5323
R=golang-dev, snaury, gwenn.kahz, google, r
CC=golang-dev
https://golang.org/cl/8836045
Anthony Martin [Tue, 23 Apr 2013 23:02:50 +0000 (16:02 -0700)]
cmd/dist: fix line numbers in goc2c generated files
We have to reset the global lineno variable before
processing each file otherwise line numbers will be
offset by the number of lines in the previous file.
The following examples are from the beginning of the
ztime_linux_amd64.c file which is generated from
time.goc in the runtime package.