1
0
mirror of https://github.com/golang/go synced 2024-10-02 14:38:33 -06:00
Commit Graph

20443 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
f1abe0d06b sync: simplify TestOncePanic
Follow-up to CL 137350043.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/141620043
2014-09-16 14:22:33 -07:00
Rob Pike
b22dc6385d sync/once: panicking functions still marked as complete
This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes #8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043
2014-09-16 14:00:01 -07:00
Keith Randall
15274e5c9b runtime: make it clear that Goexit cannot be recover'd.
LGTM=r
R=r, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/136660044
2014-09-16 12:50:05 -07:00
Russ Cox
c1e332020d os/signal: increase timeout from 10ms to 100ms
Might make test less flaky.
Fixes #8682.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/143160043
2014-09-16 15:26:00 -04:00
Russ Cox
95c899f03c net: make TestSelfConnect less fragile
We believe TestSelfConnect can accidentally connect to
something else listening on or dialing from that port.

Fixes #8680.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rlh
https://golang.org/cl/136700043
2014-09-16 14:02:59 -04:00
Russ Cox
c1c5d479bd cmd/5g, cmd/8g: make 'out of registers' a fatal error
There's no point in continuing. We will only get confused.
6g already makes this fatal.

LGTM=dave, minux, iant
R=iant, dave, minux
CC=golang-codereviews
https://golang.org/cl/140660043
2014-09-16 13:16:43 -04:00
Russ Cox
99e8f40488 runtime: fix 386 build
mark finalizer1 as having no pointers

TBR=iant
CC=golang-codereviews
https://golang.org/cl/141570045
2014-09-16 11:43:35 -04:00
Russ Cox
d208361cde runtime: remove uses of ScanConservatively
Along with CLs 139610043 and 141490043,
this removes all conservative scanning during
garbage collection, except _cgo_allocate,
which is SWIG-only.

LGTM=rlh, khr
R=golang-codereviews, dvyukov, rlh, khr
CC=golang-codereviews, iant
https://golang.org/cl/144860043
2014-09-16 11:09:58 -04:00
Russ Cox
fc46931442 runtime: remove untyped allocation of ParFor
Now it's two allocations. I don't see much downside to that,
since the two pieces were in different cache lines anyway.

Rename 'conservative' to 'cgo_conservative_type' and make
clear that _cgo_allocate is the only allowed user.

This depends on CL 141490043, which removes the other
use of conservative (in defer).

LGTM=dvyukov, iant
R=khr, dvyukov, iant
CC=golang-codereviews, rlh
https://golang.org/cl/139610043
2014-09-16 11:03:11 -04:00
Russ Cox
f95beae61d runtime: use traceback to traverse defer structures
This makes the GC and the stack copying agree about how
to interpret the defer structures. Previously, only the stack
copying treated them precisely.
This removes an untyped memory allocation and fixes
at least three copystack bugs.

To make sure the GC can find the deferred argument
frame until it has been copied, keep a Defer on the defer list
during its execution.

In addition to making it possible to remove the untyped
memory allocation, keeping the Defer on the list fixes
two races between copystack and execution of defers
(in both gopanic and Goexit). The problem is that once
the defer has been taken off the list, a stack copy that
happens before the deferred arguments have been copied
back to the stack will not update the arguments correctly.
The new tests TestDeferPtrsPanic and TestDeferPtrsGoexit
(variations on the existing TestDeferPtrs) pass now but
failed before this CL.

In addition to those fixes, keeping the Defer on the list
helps correct a dangling pointer error during copystack.
The traceback routines walk the Defer chain to provide
information about where a panic may resume execution.
When the executing Defer was not on the Defer chain
but instead linked from the Panic chain, the traceback
had to walk the Panic chain too. But Panic structs are
on the stack and being updated by copystack.
Traceback's use of the Panic chain while copystack is
updating those structs means that it can follow an
updated pointer and find itself reading from the new stack.
The new stack is usually all zeros, so it sees an incorrect
early end to the chain. The new TestPanicUseStack makes
this happen at tip and dies when adjustdefers finds an
unexpected argp. The new StackCopyPoison mode
causes an earlier bad dereference instead.
By keeping the Defer on the list, traceback can avoid
walking the Panic chain at all,  making it okay for copystack
to update the Panics.

We'd have the same problem for any Defers on the stack.
There was only one: gopanic's dabort. Since we are not
taking the executing Defer off the chain, we can use it
to do what dabort was doing, and then there are no
Defers on the stack ever, so it is okay for traceback to use
the Defer chain even while copystack is executing:
copystack cannot modify the Defer chain.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, rlh
https://golang.org/cl/141490043
2014-09-16 10:36:38 -04:00
Russ Cox
d2574e2adb runtime: remove duplicated Go constants
The C header files are the single point of truth:
every C enum constant Foo is available to Go as _Foo.
Remove or redirect duplicate Go declarations so they
cannot be out of sync.

Eventually we will need to put constants in Go, but for now having
them be out of sync with C is too risky. These predate the build
support for auto-generating Go constants from the C definitions.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/141510043
2014-09-16 10:22:15 -04:00
Russ Cox
8d61334dd5 cmd/gc: say 'non-constant array bound' instead of 'invalid array bound'
Fixes #8196.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/141510044
2014-09-16 10:21:54 -04:00
Russ Cox
3d2321f639 io: clarify Reader returning 0, nil
Fixes #8317.

LGTM=bradfitz
R=bradfitz, iant, r
CC=golang-codereviews
https://golang.org/cl/143100043
2014-09-16 10:01:28 -04:00
Russ Cox
337fe4134f cmd/gc: make runtime escape an error, not a fatal error
It is more useful to report all the errors instead of just the first.

LGTM=dave, khr
R=khr, dave
CC=golang-codereviews
https://golang.org/cl/143940043
2014-09-16 09:58:17 -04:00
Josh Bleecher Snyder
c3dbf56a14 cmd/ld: document that -X overwrites initialized variables
Fixes #7626.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144870045
2014-09-15 18:16:45 -07:00
Robert Griesemer
2bb0a5e085 cmd/api: internal debugging supprt
Document that the package cache has
an issue (8425) to speed up future
debugging.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/143980043
2014-09-15 16:40:43 -07:00
Keith Randall
7e62316b84 runtime: test Goexit/defer iteraction.
Make sure Goexit runs defers.
Make sure recover() during a Goexit defer returns nil.

LGTM=dvyukov, bradfitz
R=golang-codereviews, dvyukov, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/140650043
2014-09-15 15:09:17 -07:00
Keith Randall
1e4f86e485 runtime: try harder to get different iteration orders.
Fixes #8736.

LGTM=iant, josharian
R=golang-codereviews, iant, josharian
CC=golang-codereviews
https://golang.org/cl/144910044
2014-09-15 12:30:57 -07:00
Josh Bleecher Snyder
f197988ca5 test: make maplinear iterdelete test less flaky
iterdelete's run time varies; occasionally we get unlucky. To reduce spurious failures, average away some of the variation.

On my machine, 8 of 5000 runs (0.15%) failed before this CL. After this CL, there were no failures after 35,000 runs.

I confirmed that this adjusted test still fails before CL 141270043.

LGTM=khr
R=khr
CC=bradfitz, golang-codereviews
https://golang.org/cl/140610043
2014-09-15 10:56:37 -07:00
Rémy Oudompheng
e024ed5ca4 cmd/gc: don't walk static nodes generated by anylit.
During anylit run, nodes such as SLICEARR(statictmp, [:])
may be generated and are expected to be found unchanged by
gen_as_init.

In some walks (in particular walkselect), the statement
may be walked again and lowered to its usual form, leading to a
crash.

Fixes #8017.
Fixes #8024.
Fixes #8058.

LGTM=rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/112080043
2014-09-15 18:31:47 +02:00
Rémy Oudompheng
8d47b08255 cmd/gc: generate type alg after calling dowidth.
Previously it might happen before calling dowidth and
result in a compiler crash.

Fixes #8060.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/110980044
2014-09-15 18:24:16 +02:00
Brad Fitzpatrick
bb431245cc net/http: don't call FileSystem.Open with unclean index.html path
Fixes #8722

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142090043
2014-09-15 07:14:33 -04:00
Alex Brainman
5d5312c5dd runtime: fix parameter checking in syscall.NewCallback
I have made mistake while converting it to Go (CL 132820043).
Added test as penance for my sin.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/136560043
2014-09-15 12:58:28 +10:00
Russ Cox
3b4bccc820 syscall: add GO_ARGS to Go-called assembly
Fixes sporadic linux/386 build failure (untyped args)
and probably some others we haven't observed yet.

Fixes #8727.

TBR=iant
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, khr, r
https://golang.org/cl/143930043
2014-09-14 22:27:03 -04:00
Russ Cox
e8a74dcad9 runtime: fix solaris build, part 2
This file was already assigned to another CL
so it didn't make it into the build fix CL. Sigh.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/144850043
2014-09-14 22:24:29 -04:00
Russ Cox
6c59cdcf34 runtime: fix solaris build
CL 144830043 changed LibCall for Windows.
I didn't realize Solaris used it too.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142100043
2014-09-14 22:20:01 -04:00
Russ Cox
2eccf0d18f runtime: convert syscall_windows.c to Go
This is necessary because syscall.Syscall blocks, and the
garbage collector needs to be able to scan that frame while
it is blocked, and C frames have no garbage collection
information.

Windows builders are broken now due to this problem:
http://build.golang.org/log/152ca9a4be6783d3a8bf6e2f5b9fc265089728b6

LGTM=alex.brainman
R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/144830043
2014-09-14 21:25:44 -04:00
Nigel Tao
8e77a7ef6b image/jpeg: reject invalid Ta and Td values.
Fixes #8693.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/141470043
2014-09-15 08:41:59 +10:00
Russ Cox
d889f5f01e runtime: fix traceback of trap on ARM
The merged traceback was wrong for LR machines,
because traceback didn't pass lr to gentraceback.
Now that we have a test looking at traceback output
for a trap (the test of runtime.Breakpoint),
we caught this.

While we're here, fix a 'set and not used' warning.

Fixes arm build.

TBR=r
R=r
CC=golang-codereviews
https://golang.org/cl/143040043
2014-09-14 20:39:08 +00:00
Russ Cox
40dd6bf38e runtime: mark asmcgocall<>(SB) as having no arguments
It doesn't.
Fixes 386 build.

While we're here, mark runtime.asmcgocall as GO_ARGS,
so that it will work with stack copying. I don't think anything
that uses it can lead to a stack copy, but better safe than sorry.
Certainly the runtime.asmcgocall_errno variant needs
(and already has) GO_ARGS.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/138400043
2014-09-14 13:57:28 -04:00
Robert Griesemer
e3d2e5550e cmd/8g: remove unused variable (fix build)
http://build.golang.org/log/0434a945e3351eedaf56aa824d2bfe9c0d5e6735

LGTM=dave
R=bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/144800043
2014-09-12 16:35:40 -07:00
Josh Bleecher Snyder
d6cd230c98 runtime: test iteration order of sparse maps
The behavior was fixed in CL 141270043. Add a test.

Fixes #8410.

LGTM=khr
R=khr, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/137560044
2014-09-12 16:16:09 -07:00
Dmitriy Vyukov
d78823168f cmd/gc: fix racewalk after writebarrier change
Instrument dst argument of writebarrier calls.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/139560045
2014-09-12 15:05:41 -07:00
Russ Cox
44753479c6 runtime: remove a few untyped allocations
LGTM=iant, khr, rlh
R=khr, iant, bradfitz, rlh
CC=dvyukov, golang-codereviews
https://golang.org/cl/142030044
2014-09-12 16:12:39 -04:00
Robert Griesemer
a14c1c986e go/printer: don't reduce nesting depth twice if parentheses are present around an expr
No impact on formatting on our repos.

Fixes #8021.

LGTM=adonovan
R=adonovan, dvyukov
CC=golang-codereviews
https://golang.org/cl/142020043
2014-09-12 11:18:12 -07:00
Ian Lance Taylor
fbd1b5f98f runtime: fix typo in comment
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/140590043
2014-09-12 07:52:56 -07:00
Russ Cox
68c1c6afa0 cmd/cc, cmd/gc: stop generating 'argsize' PCDATA
The argsize PCDATA was specifying the number of
bytes passed to a function call, so that if the function
did not specify its argument count, the garbage collector
could use the call site information to scan those bytes
conservatively. We don't do that anymore, so stop
generating the information.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/139530043
2014-09-12 07:51:00 -04:00
Russ Cox
e844f53a01 runtime: stop scanning stack frames/args conservatively
The goal here is to commit fully to having precise information
about stack frames. If we need information we don't have,
crash instead of assuming we should scan conservatively.

Since the stack copying assumes fully precise information,
any crashes during garbage collection that are introduced by
this CL are crashes that could have happened during stack
copying instead. Those are harder to find because stacks are
copied much less often than the garbage collector is invoked.

In service of that goal, remove ARGSIZE macros from
asm_*.s, change switchtoM to have no arguments
(it doesn't have any live arguments), and add
args and locals information to some frames that
can call back into Go.

LGTM=khr
R=khr, rlh
CC=golang-codereviews
https://golang.org/cl/137540043
2014-09-12 07:46:11 -04:00
Russ Cox
a7c6d89166 runtime: tell the truth about BitVector type
Dmitriy changed all the execution to interpret the BitVector
as an array of bytes. Update the declaration and generation
of the bitmaps to match, to avoid problems on big-endian
machines.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews
https://golang.org/cl/140570044
2014-09-12 07:36:23 -04:00
Russ Cox
f0d44dbeaf runtime: look up arg stackmap for makeFuncStub/methodValueStub during traceback
makeFuncStub and methodValueStub are used by reflect as
generic function implementations. Each call might have
different arguments. Extract those arguments from the
closure data instead of assuming it is the same each time.

Because the argument map is now being extracted from the
function itself, we don't need the special cases in reflect.Call
anymore, so delete those.

Fixes an occasional crash seen when stack copying does
not update makeFuncStub's arguments correctly.

Will also help make it safe to require stack maps in the
garbage collector.

Derived from CL 142000044 by khr.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143890044
2014-09-12 07:29:19 -04:00
Anthony Martin
70f928698b runtime: save correct pid for new m's on plan9/amd64
The pid field in the Tos structure is a 32-bit value.
Loading a 64-bit word also brings in the next field
which is used for the profiling clock.

LGTM=0intro, aram
R=rsc, 0intro, aram
CC=golang-codereviews, mischief
https://golang.org/cl/139560044
2014-09-12 01:21:51 -07:00
Russ Cox
860a645927 syscall: add #include "funcdata.h" to files modified in last CL
That's what defines GO_ARGS.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/141460043
2014-09-12 00:55:24 -04:00
Russ Cox
4179439de8 syscall: make func Syscall use pointer maps from Go prototypes
Before, Syscall and friends were having their arguments
treated conservatively. Now they will use the Go prototype,
which will mean the arguments are not considered pointers
at all.

This is safe because of CL 139360044.

The fact that all these non-Solaris systems were using
conservative scanning of the Syscall arguments is why
the failure that prompted CL 139360044 was only
observed on Solaris, which does something completely different.
If we'd done this earlier, we'd have seen the Solaris
failure in more places.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144730043
2014-09-12 00:23:03 -04:00
Russ Cox
99f7df0598 cmd/gc: turn Go prototypes into ptr liveness maps for assembly functions
The goal here is to allow assembly functions to appear in the middle
of a Go stack (having called other code) and still record enough information
about their pointers so that stack copying and garbage collection can handle
them precisely. Today, these frames are handled only conservatively.

If you write

        func myfunc(x *float64) (y *int)

(with no body, an 'extern' declaration), then the Go compiler now emits
a liveness bitmap for use from the assembly definition of myfunc.
The bitmap symbol is myfunc.args_stackmap and it contains two bitmaps.
The first bitmap, in effect at function entry, marks all inputs as live.
The second bitmap, not in effect at function entry, marks the outputs
live as well.

In funcdata.h, define new assembly macros:

GO_ARGS opts in to using the Go compiler-generated liveness bitmap
for the current function.

GO_RESULTS_INITIALIZED indicates that the results have been initialized
and need to be kept live for the remainder of the function; it causes a
switch to the second generated bitmap for the assembly code that follows.

NO_LOCAL_POINTERS indicates that there are no pointers in the
local variables being stored in the function's stack frame.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/137520043
2014-09-12 00:18:20 -04:00
Keith Randall
47f251c1ce runtime: fix cgo to handle the case where the G stack is copied.
Tests will come in a separate CL after the funcdata stuff is resolved.

Update #8696

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/138330045
2014-09-11 20:36:23 -07:00
Michael MacInnis
aa168ed2cd syscall: SysProcAttr job control changes
Making the child's process group the foreground process group and
placing the child in a specific process group involves co-ordination
between the parent and child that must be done post-fork but pre-exec.

LGTM=iant
R=golang-codereviews, gobot, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/131750044
2014-09-11 18:39:51 -07:00
Ian Lance Taylor
df1c2310f3 A+C: Michael MacInnis (individual CLA)
Generated by a+c.

R=gobot
CC=golang-codereviews
https://golang.org/cl/140570043
2014-09-11 18:35:25 -07:00
Keith Randall
bcd36e8857 runtime: make gostringnocopy update maxstring
Fixes #8706

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/143880043
2014-09-11 16:53:34 -07:00
Matthew Dempsky
6e55f7a87b doc: link directly to https://golang.org/dl/
Fixes #8705.

LGTM=adg
R=golang-codereviews, bradfitz, adg
CC=golang-codereviews
https://golang.org/cl/142890044
2014-09-12 09:15:58 +10:00
Keith Randall
00365b13b4 runtime: get rid of copyable check - all G frames are copyable.
Just go ahead and do it, if something is wrong we'll throw.

Also rip out cc-generated arg ptr maps, they are useless now.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/133690045
2014-09-11 13:46:58 -07:00