Keith Randall [Tue, 5 Dec 2017 05:29:38 +0000 (21:29 -0800)]
cmd/cgo: make JNI's jobject type map to uintptr in Go
The jobject type is declared as a pointer, but some JVMs
(Dalvik, ART) store non-pointer values in them. In Go, we must
use uintptr instead of a real pointer for these types.
This is similar to the CoreFoundation types on Darwin which
were "fixed" in CL 66332.
Update #22906
Update #21897
RELNOTE=yes
Change-Id: I0d4c664501d89a696c2fb037c995503caabf8911
Reviewed-on: https://go-review.googlesource.com/81876
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Fri, 8 Dec 2017 13:43:40 +0000 (14:43 +0100)]
doc/go1.10: fix HTML start tag
Change-Id: I33f14ea1d58e18081bae3f16c87d11312249c842
Reviewed-on: https://go-review.googlesource.com/82835 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Fri, 8 Dec 2017 04:30:28 +0000 (20:30 -0800)]
net: avoid race on test hooks with DNS goroutines
The DNS code can start goroutines and not wait for them to complete.
This does no harm, but in tests this can cause a race condition with
the test hooks that are installed and unintalled around the tests.
Add a WaitGroup that tests of DNS can use to avoid the race.
Samuel Tan [Fri, 17 Nov 2017 23:47:33 +0000 (15:47 -0800)]
html/template: reset templates orphaned by (*Template).New
If (*Template).New replaces an existing template, reset the
existing template that is going to be replaced so that any
later attempt to execute this orphaned template will fail.
Fixes #22780
Change-Id: I0e058f42c1542c86d19dc5f6c4e1e859e670a4a2
Reviewed-on: https://go-review.googlesource.com/78542
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Thu, 7 Dec 2017 20:08:21 +0000 (20:08 +0000)]
net/http: document ResponseWriter.WriteHeader more
Change-Id: I65209b90ed7c56d4c751b3e4b3ce1de52dae368c
Reviewed-on: https://go-review.googlesource.com/82635 Reviewed-by: Ian Lance Taylor <iant@golang.org>
I can reproduce with a very short timeout (fractions of a millisecond)
combined with -race.
But given that this is inherently sensitive to actual time, add a
testing mechanism to retry with increasingly large times to compensate
for busy buidlers. This also means the test is usually faster now,
too, since we can start with smaller durations.
Fixes #19608
Change-Id: I3a222464720195849da768e9801eb7b43baa4aeb
Reviewed-on: https://go-review.googlesource.com/82595
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Wed, 6 Dec 2017 18:20:26 +0000 (18:20 +0000)]
syscall: make Seek use SetFilePointerEx on Windows, allowing large seek offsets
Fixes #21681
Updates #21728
Change-Id: I79cf4564c1355ecab891102d4215cbbffd8eb0ce
Reviewed-on: https://go-review.googlesource.com/82535 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Than McIntosh [Thu, 7 Dec 2017 01:10:51 +0000 (20:10 -0500)]
cmd/compile: fix bug in logic for computing var abstract origins
The DWARF inline info generation code was using file/line/column (from
src.Pos) as a means of matching up pre- and post-optimization variable
nodes. This turns out to be problematic since it looks as though
distinct formals on the same line can be assigned the same column
number. Work around this issue by adding variable names to the
disambiguation code. Added a testpoint to the linker DWARF test that
checks to make sure each abstract origin offset of distinct within a
given DWARF DW_AT_inlined_routine body.
Brad Fitzpatrick [Wed, 6 Dec 2017 18:44:13 +0000 (18:44 +0000)]
doc/go1.10: add NetBSD and OpenBSD to Go 1.10 release notes
Fixes #22911
Change-Id: I61de85323e290b64917a09bc512935e835ff7cf0
Reviewed-on: https://go-review.googlesource.com/82276 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Wed, 6 Dec 2017 06:38:36 +0000 (22:38 -0800)]
encoding/json: error when trying to set an embedded pointer to unexported struct types
This CL reverts CL 76851 and takes a different approach to #21357.
The changes in encode.go and encode_test.go are reverts that
rolls back the changed behavior in CL 76851 where
embedded pointers to unexported struct types were
unilaterally ignored in both marshal and unmarshal.
Instead, these fields are handled as before with the exception that
it returns an error when Unmarshal is unable to set an unexported field.
The behavior of Marshal is now unchanged with regards to #21357.
This policy maintains the greatest degree of backwards compatibility
and avoids silently discarding data the user may have expected to be present.
Fixes #21357
Change-Id: I7dc753280c99f786ac51acf7e6c0246618c8b2b1
Reviewed-on: https://go-review.googlesource.com/82135
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Tue, 7 Nov 2017 14:56:11 +0000 (09:56 -0500)]
misc/cgo/testplugin: unskip test
Fixed by CL 76025 yesterday, without realizing it:
the testshared and testplugin builds of separate iface_i
packages were colliding incorrectly in the cache.
Including the build directory fixes that.
Alberto Donizetti [Wed, 6 Dec 2017 09:59:40 +0000 (10:59 +0100)]
doc: fix two spelling mistakes in contribute.html
Change-Id: Ife60468d508f90321733ebdbdb0e6cf443ba1659
Reviewed-on: https://go-review.googlesource.com/82156 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alberto Donizetti [Wed, 6 Dec 2017 10:42:42 +0000 (11:42 +0100)]
doc: fix dead link in go_faq
Change-Id: I8a9e4d00247fe9bda6e19551850bdec0367df2e1
Reviewed-on: https://go-review.googlesource.com/82157 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser [Wed, 6 Dec 2017 15:15:08 +0000 (16:15 +0100)]
doc: fix spelling in editor guide
Change-Id: If16f069f410d043fd11864a4c1a7d54b5b4922d2
Reviewed-on: https://go-review.googlesource.com/82200 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Wed, 6 Dec 2017 07:17:24 +0000 (02:17 -0500)]
hash: add MarshalBinary/UnmarshalBinary round trip + golden test for all implementations
There are some basic tests in the packages implementing the hashes,
but this one is meant to be comprehensive for the standard library
as a whole.
Most importantly, it locks in the current representations and makes
sure that they do not change from release to release (and also, as a
result, that future releases can parse the representations generated
by older releases).
The crypto/* MarshalBinary implementations are being changed
in this CL to write only d.x[:d.nx] to the encoding, with zeros for
the remainder of the slice d.x[d.nx:]. The old encoding wrote the
whole d.x, but that exposed an internal detail: whether d.x is
cleared after a full buffer is accumulated, and also whether d.x was
used at all for previous blocks (consider 1-byte writes vs 1024-byte writes).
The new encoding writes only what the decoder needs to know,
nothing more.
In fact the old encodings were arguably also a security hole,
because they exposed data written even before the most recent
call to the Reset method, data that clearly has no impact on the
current hash and clearly should not be exposed. The leakage
is clearly visible in the old crypto/sha1 golden test tables also
being modified in this CL.
Russ Cox [Wed, 6 Dec 2017 03:12:52 +0000 (22:12 -0500)]
database/sql/driver: explain Driver vs DriverContext vs Connector
The docs make it seem like they are all things a single object
would implement. That's true of Driver and DriverContext,
but Connector is really something else. Attempt to clarify.
Russ Cox [Wed, 6 Dec 2017 02:26:07 +0000 (21:26 -0500)]
crypto/x509: add test for asn1.Marshal of rsa.PublicKey
Go 1.10 is adding new API MarshalPKCS1PublicKey and
ParsePKCS1PublicKey for converting rsa.PublicKeys.
Even though we'd prefer that users did not, check that
if users call asn1.Marshal and asn1.Unmarshal directly instead,
they get the same results. We know that code exists in the
wild that depends on this.
Russ Cox [Tue, 5 Dec 2017 19:38:50 +0000 (14:38 -0500)]
encoding/pem: change Encode, EncodeToMemory not to generate partial PEM blocks
Originally these routines could not fail except by
returning errors from the underlying writer.
Then we realized that header keys containing colons
needed to be rejected, and we started returning an error
from Encode. But that only happens after writing a
partial PEM block to the underlying writer, which is
unfortunate, but at least it was undocumented.
CL 77790 then documented this unfortunate behavior.
Instead of documenting unfortunate behavior, fix it.
Russ Cox [Wed, 6 Dec 2017 01:20:56 +0000 (20:20 -0500)]
net/http: keep testing DetectContentType of empty body
Historically, DetectContentType has returned "text/plain; charset=utf-8"
for an empty body, there was a test for this, and there should continue
to be one.
CL 46631 changed the content-serving handlers to avoid setting any
Content-Type header when serving empty content. Even if that change
in behavior is correct, the CL is explicitly not changing DetectContentType,
so it must also not change DetectContentType's tests.
Joe Tsai [Mon, 4 Dec 2017 19:16:51 +0000 (11:16 -0800)]
net: return io.ErrClosedPipe when possible from net.Pipe
The previous implementation of net.Pipe was just a thin wrapper around
io.Pipe and did not wrap any of the io.Pipe errors as net.Errors.
As a result of Hyrum's law, users have come to depend on the fact that
net.Pipe returns io.ErrClosedPipe when the pipe is closed.
Thus, we preserve this behavior to avoid regressing such use cases.
Change-Id: I06b387877b944c1c08527601f58983872b7557b4
Reviewed-on: https://go-review.googlesource.com/81777
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
christopher-henderson [Fri, 1 Dec 2017 23:17:16 +0000 (16:17 -0700)]
encoding/asn1: allow '&' in PrintableString fields
There are, unfortunately, intermediate CA ceritificates in circulation
that contain the invalid character '&' in some PrintableString fields,
notably Organization Name. This patch allows for ampersand
to be parsed as though it is valid in an ASN.1 PrintableString.
Fixes #22970
Change-Id: Ifab1a10bbff1cdac68e843c6b857ff1a031051aa
Reviewed-on: https://go-review.googlesource.com/81635 Reviewed-by: Adam Langley <agl@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
kirk [Mon, 4 Dec 2017 02:53:53 +0000 (10:53 +0800)]
database/sql: fix transaction leak
When the user context which passed in (*DB)BeginTx is canceled or
timeout, the current implementation could cause db transaction leak
in some extreme scenario.
Goroutine 1:
Call (*DB) BeginTx begins a transaction with a userContext.
In (*DB)BeginTx, a new goroutine (*Tx)awaitDone
which monitor context and rollback tx if needed will be created
Goroutine 2(awaitDone):
block on tx.ctx.Done()
Goroutine 1:
Execute some insert or update sqls on the database
Goroutine 1:
Commit the transaction, (*Tx)Commit set
the atomic variable tx.done to 1
Goroutine 3(maybe global timer):
Cancel userContext which be passed in Tx
Goroutine 1:
(*Tx)Commit checks tx.ctx.Done().
Due to the context has been canceled, it will return
context.Canceled or context.DeadlineExceeded error immediately
and abort the real COMMIT operation of transaction
Goroutine 2:
Release with tx.ctx.Done() signal, execute (*Tx)rollback.
However the atomic variable tx.done is 1 currently,
it will return ErrTxDone error immediately and
abort the real ROLLBACK operation of transaction
Keith Randall [Mon, 4 Dec 2017 22:47:32 +0000 (14:47 -0800)]
cmd/compile: fix map assignment with panicking right-hand side
Make sure that when we're assigning to a map, we evaluate the
right-hand side before we attempt to insert into the map.
We used to evaluate the left-hand side to a pointer-to-slot-in-bucket
(which as a side effect does len(m)++), then evaluate the right-hand side,
then do the assignment. That clearly isn't correct when the right-hand side
might panic.
Fixes #22881
Change-Id: I42a62870ff4bf480568c9bdbf0bb18958962bdf0
Reviewed-on: https://go-review.googlesource.com/81817 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Matthew Dempsky [Mon, 4 Dec 2017 18:59:39 +0000 (10:59 -0800)]
test: disable broken test for 1.10
This test was added recently as a regress test for the spec relaxation
in #9060, but doesn't work correctly yet. Disable for now to fix noopt
builders.
Than McIntosh [Fri, 1 Dec 2017 20:23:30 +0000 (15:23 -0500)]
cmd/compile: fix bug in DWARF inl handling of unused autos
The DWARF inline info generation hooks weren't properly
handling unused auto vars in certain cases, triggering an assert (now
fixed). Also with this change, introduce a new autom "flavor" to
use for autom entries that are added to insure that a specific
auto type makes it into the linker (this is a follow-on to the fix
for 22941).
Fixes #22962.
Change-Id: I7a2d8caf47f6ca897b12acb6a6de0eb25f5cac8f
Reviewed-on: https://go-review.googlesource.com/81557
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Elias Naur [Tue, 7 Nov 2017 12:04:22 +0000 (13:04 +0100)]
misc/ios: dump logs for failing lldb sessions to stdout
The iOS test harness dumps the output of its lldb session to stdout,
but only if the lldb session was successfully started.
Make sure the log is always dumpede, so that lldb startup failures
such as
lldb setup error: exited (lldb start: exit status 253)
can be diagnosed.
For the iOS builders.
Change-Id: Ie0e3341dd8f84a88d26509c34816668d3ebbfaa0
Reviewed-on: https://go-review.googlesource.com/76195
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Russ Cox [Fri, 1 Dec 2017 20:53:06 +0000 (15:53 -0500)]
cmd/go: disable tests when GOOS/GOARCH != GOHOSTARCH/GOHOSTARCH
The whole GOROOT/pkg tree is installed using the GOHOSTOS/GOHOSTARCH
toolchain (installed in GOROOT/pkg/tool/GOHOSTOS_GOHOSTARCH).
The testgo.exe we run during the cmd/go test will be built
for GOOS/GOARCH, which means it will use the GOOS/GOARCH toolchain
(installed in GOROOT/pkg/tool/GOOS_GOARCH).
If these are not the same toolchain, then the entire standard library
will look out of date to testgo.exe (the compilers in those two different
tool directories are built for different architectures and have different
buid IDs), which will cause many tests to do unnecessary rebuilds
and some tests to attempt to overwrite the installed standard library,
which will in turn make it look out of date to whatever runs after the
cmd/go test exits.
Bail out entirely in this case instead of destroying the world.
The changes outside TestMain are checks that might have caught
this a bit earlier and made it much less confusing to debug.
Fixes #22709.
Fixes #22965.
Change-Id: Ibf28fa19e29a1f1b8f17875f446d3474dd04a924
Reviewed-on: https://go-review.googlesource.com/81516
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Russ Cox [Fri, 1 Dec 2017 16:42:48 +0000 (11:42 -0500)]
cmd/go: fix -covermode=atomic use of sync/atomic in -coverpkg matches
If we're using -covermode=atomic with -coverpkg, to add coverage
to more than just the package being tested, then we need to make sure
to make sync/atomic available to the compiler for every package
being recompiled for coverage.
Fixes #22728.
Change-Id: I27f88f6a62e37d4a7455554cd03c8ca2b21f81a4
Reviewed-on: https://go-review.googlesource.com/81497
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Christos Zoulas [Mon, 4 Dec 2017 01:48:45 +0000 (01:48 +0000)]
runtime: make NetBSD lwp_park use monotonic time
This change updates runtime.semasleep to no longer call
runtime.nanotime and instead calls lwp_park with a duration to sleep
relative to the monotonic clock, so the nanotime is never called.
(This requires updating to a newer version of the lwp_park system
call, which is safe, because Go 1.10 will require the unreleased
NetBSD 8+ anyway)
Additionally, this change makes the nanotime function use the
monotonic clock for netbsd/arm, which was forgotten from
https://golang.org/cl/81135 which updated netbsd/amd64 and netbsd/386.
Because semasleep previously depended on nanotime, the past few days
of netbsd have likely been unstable because lwp_park was then mixing
the monotonic and wall clocks. After this CL, lwp_park no longer
depends on nanotime.
Original patch submitted at:
https://www.netbsd.org/~christos/go-lwp-park-clock-monotonic.diff
This commit message (any any mistakes therein) were written by Brad
Fitzpatrick. (Brad migrated the patch to Gerrit and checked CLAs)
Brad Fitzpatrick [Thu, 30 Nov 2017 16:36:34 +0000 (16:36 +0000)]
os: clarify docs on Interrupt and Kill
Note that Interrupt will compile but not work on Windows.
Fixes #22454
Change-Id: If011c32211f4bb45d458317e113b9794d5b4a4b1
Reviewed-on: https://go-review.googlesource.com/81035 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Sat, 2 Dec 2017 00:55:46 +0000 (16:55 -0800)]
os: calling Fd disables the SetDeadline methods
The full truth seems too complicated to write in this method's doc, so
I'm going with a simple half truth.
The full truth is that Fd returns the descriptor in blocking mode,
because that is historically how it worked, and existing programs
would be surprised if the descriptor is suddenly non-blocking. On Unix
systems whether a file is non-blocking or not is a property of the
underlying file description, not of a particular file descriptor, so
changing the returned descriptor to blocking mode also changes the
existing File to blocking mode. Blocking mode works fine, althoug I/O
operations now take up a thread. SetDeadline and friends rely on the
runtime poller, and the runtime poller only works if the descriptor is
non-blocking. So it's correct that calling Fd disables SetDeadline.
The other half of the truth is that if the program is willing to work
with a non-blocking descriptor, it could call
syscall.SetNonblock(descriptor, true) to change the descriptor, and
the original File, to non-blocking mode. At that point SetDeadline
would start working again. I tried to write that in a way that is
short and comprehensible but failed. Since deadlines mostly work on
pipes, and there isn't much reason to call Fd on a pipe, and few
people use SetDeadline, I decided to punt.
Brad Fitzpatrick [Fri, 1 Dec 2017 17:00:58 +0000 (17:00 +0000)]
net/url: document Parse more
That Parse doesn't parse ("foo.com/path" or "foo.com:443/path") has
become something of a FAQ.
Updates #19779
Updates #21415
Updates #22955
Change-Id: Ib68efddb67f59b1374e8ed94effd4a326988dee7
Reviewed-on: https://go-review.googlesource.com/81436 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Fri, 1 Dec 2017 16:57:57 +0000 (11:57 -0500)]
cmd/go: honor -timeout=0 to mean no timeout
The test binaries accept -timeout=0 to mean no timeout,
but then the backup timer in cmd/go kills the test after 1 minute.
Make cmd/go understand this special case and change
behavior accordingly.
Russ Cox [Fri, 1 Dec 2017 18:42:53 +0000 (13:42 -0500)]
cmd/go: fix missing conversions in -json output
1. Apply JSON conversion when -bench is in use.
2. Apply JSON conversion to "no test files" result.
3. Apply JSON conversion to test case-ending SKIP status.
Fixes #22769.
Fixes #22790.
Change-Id: I67ad656fc58bacae8c51d23b1e6d543cad190f08
Reviewed-on: https://go-review.googlesource.com/81535
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Fri, 1 Dec 2017 18:19:39 +0000 (13:19 -0500)]
cmd/go: fix reuse of cached objects during cover
The cover variable indices could vary from build to build,
but they were not included in the build ID hash, so that
reusing the previously built package was not safe.
Make the indices no longer vary from build to build,
so that caching is safe.
Fixes #22652.
Change-Id: Ie26d73c648aadd285f97e0bf39619cabc3da54f2
Reviewed-on: https://go-review.googlesource.com/81515
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Fri, 1 Dec 2017 17:17:37 +0000 (12:17 -0500)]
cmd/go: ignore vet typecheck failure during go test
For Go 1.10, works around a go/types bug that can't typecheck
a corner-case type cycle. Once we are confident that bugs like
this are gone from go/types then we can stop ignoring these
failures.
For #22890.
Change-Id: I38da57e01a0636323e1af4484c30871786125df3
Reviewed-on: https://go-review.googlesource.com/81500
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Wed, 29 Nov 2017 20:22:13 +0000 (15:22 -0500)]
reflect: audit and explain safety of all unsafe.Pointer additions
It's not safe to do p+x with unsafe if that would point past the
end of the object. (Valid in C, not safe in Go.)
Pass a "whySafe" reason (compiled away) to explain at each
call site why it's safe.
Hana Kim [Thu, 30 Nov 2017 23:51:04 +0000 (18:51 -0500)]
cmd/trace: exclude threads in syscall on behalf of runtime
The number of threads in syscall presented by execution tracer's
trace view includes not only the threads calling system calls on behalf
of user created goroutines, but also those running on behalf of system
goroutines.
When the number of such system goroutines was small, the graph was
useful when examining where a program was saturating the CPU.
But as more and more system goroutines are invloved the graph became
less useful for the purpose - for example, after golang.org/cl/34784,
the timer goroutines dominate in the graph with large P
because the runtime creates per-P timer goroutines.
This change excludes the threads in syscall on behalf of runtime (system
goroutines) from the visualization. Alternatively, I could visualize the
count of such threads in a separate counter but in the same graph.
Given that many other debug endpoints (e.g. /debug/pprof/goroutine) hide
the system goroutines, including them in the same graph can confuse users.
Update #22574
Change-Id: If758cd6b9ed0596fde9a471e846b93246580b9d5
Reviewed-on: https://go-review.googlesource.com/81315 Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brad Fitzpatrick [Fri, 1 Dec 2017 19:26:33 +0000 (19:26 +0000)]
runtime: skip gdb tests earlier before blocking goroutines in a t.Parallel
Minor.
Makes reading failing runtime test stacktraces easier (by having fewer
goroutines to read) on machines where these gdb tests wouldn't have
ever run anyway.
Change-Id: I3fab0667e017f20ef3bf96a8cc4cfcc614d25b5c
Reviewed-on: https://go-review.googlesource.com/81575 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Austin Clements [Thu, 30 Nov 2017 20:47:04 +0000 (15:47 -0500)]
runtime: improve sigsend documentation
I think of "sending" a signal as calling kill, but sigsend is involved
in handling a signal and, specifically delivering it to the internal
signal queue. The term "delivery" is already used in
signalWaitUntilIdle, so this CL also uses it in the documentation for
sigsend.
Change-Id: I86e171f247f525ece884a680bace616fa9a3c7bd
Reviewed-on: https://go-review.googlesource.com/81235 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Austin Clements [Fri, 1 Dec 2017 03:09:35 +0000 (22:09 -0500)]
runtime: restore the Go-allocated signal stack in unminit
Currently, when we minit on a thread that already has an alternate
signal stack (e.g., because the M was an extram being used for a cgo
callback, or to handle a signal on a C thread, or because the
platform's libc always allocates a signal stack like on Android), we
simply drop the Go-allocated gsignal stack on the floor.
This is a problem for Ms on the extram list because those Ms may later
be reused for a different thread that may not have its own alternate
signal stack. On tip, this manifests as a crash in sigaltstack because
we clear the gsignal stack bounds in unminit and later try to use
those cleared bounds when we re-minit that M. On 1.9 and earlier, we
didn't clear the bounds, so this manifests as running more than one
signal handler on the same signal stack, which could lead to arbitrary
memory corruption.
This CL fixes this problem by saving the Go-allocated gsignal stack in
a new field in the m struct when overwriting it with a system-provided
signal stack, and then restoring the original gsignal stack in
unminit.
This CL is designed to be easy to back-port to 1.9. It won't quite
cherry-pick cleanly, but it should be sufficient to simply ignore the
change in mexit (which didn't exist in 1.9).
Now that we always have a place to stash the original signal stack in
the m struct, there are some simplifications we can make to the signal
stack handling. We'll do those in a later CL.
Fixes #22930.
Change-Id: I55c5a6dd9d97532f131146afdef0b216e1433054
Reviewed-on: https://go-review.googlesource.com/81476
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Fri, 1 Dec 2017 16:26:09 +0000 (11:26 -0500)]
cmd/go: apply same per-package flags to test and xtest builds
If package strings has a particular set of gcflags, then the strings_test
pseudo-package built as part of the test binary should inherit the same flags.
Fixes #22831.
Change-Id: I0e896b6c0f1063454300b7323f577feffbd6650b
Reviewed-on: https://go-review.googlesource.com/81496
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Russ Cox [Fri, 1 Dec 2017 15:29:10 +0000 (10:29 -0500)]
cmd/go: fix -outputdir -coverprofile interaction
The CL introducing merged handling of cover profiles
did not correctly account for the fact that the file name argument
to -coverprofile is required to be interpreted relative to
the -outputdir argument.
Fixes #22804.
Change-Id: I804774013c12187313b8fd2044302978bdbb6697
Reviewed-on: https://go-review.googlesource.com/81455
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Than McIntosh [Fri, 1 Dec 2017 14:39:59 +0000 (09:39 -0500)]
cmd/compile: fix DWARF type symbol buglet
The code that generates the list of DWARF variables for a function
(params and autos) will emit a "no-location" entry in the DWARF for a
user var that appears in the original pre-optimization version of the
function but is no longer around when optimization is complete. The
intent is that if a GDB user types "print foo" (where foo has been
optimized out), the response will be "<optimized out>" as opposed to
"there is no such variable 'foo'). This change fixes said code to
include vars on the autom list for the function, to insure that the
type symbol for the variable makes it to the linker.
Fixes #22941.
Change-Id: Id29f1f39d68fbb798602dfd6728603040624fc41
Reviewed-on: https://go-review.googlesource.com/81415
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Russ Cox [Wed, 29 Nov 2017 19:44:43 +0000 (14:44 -0500)]
reflect: fix interface to interface conversion in Call
Call is meant to mirror the language semantics, which allow:
var r io.ReadWriter
f := func(io.Reader){}
f(r)
even though the conversion from io.ReadWriter to io.Reader is
being applied to a nil interface. This is different from an explicit
conversion:
_ = r.(io.Reader)
f(r.(io.Reader))
Both of those lines panic, but the implicit conversion does not.
By using E2I, which is the implementation of the explicit conversion,
the reflect.Call equivalent of f(r) was inadvertently panicking.
Avoid the panic.
Fixes #22143.
Change-Id: I6b2f5b808e0cd3b89ae8bc75881e307bf1c25558
Reviewed-on: https://go-review.googlesource.com/80736
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
David Chase [Thu, 30 Nov 2017 20:11:34 +0000 (15:11 -0500)]
cmd/compile: use src.NoXPos for entry-block constants
The ssa backend is aggressive about placing constants and
certain other values in the Entry block. It's implausible
that the original line numbers for these constants makes
any sort of sense when it appears to a user stepping in a
debugger, and they're also not that useful in dumps since
entry-block instructions tend to be constants (i.e.,
unlikely to be the cause of a crash).
Therefore, use src.NoXPos for any values that are explicitly
inserted into a function's entry block.
Passes all tests, including ssa/debug_test.go with both
gdb and a fairly recent dlv. Hand-verified that it solves
the reported problem; constructed a test that reproduced
a problem, and fixed it.
Modified test harness to allow injection of slightly more
interesting inputs.
Fixes #22558.
Change-Id: I4476927067846bc4366da7793d2375c111694c55
Reviewed-on: https://go-review.googlesource.com/81215
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Brad Fitzpatrick [Fri, 1 Dec 2017 03:25:02 +0000 (03:25 +0000)]
os: ignore Chtimes test failure on NetBSD if fs mounted noatime
Fixes #19293
Change-Id: I35f2f786e2e3972eda21ba5a948433bfcd621269
Reviewed-on: https://go-review.googlesource.com/81355 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Matthew Dempsky [Wed, 29 Nov 2017 20:26:59 +0000 (12:26 -0800)]
cmd/compile: fix GOEXPERIMENT checks
GOEXPERIMENT is only set during make.bash, so checking the environment
variable isn't effectual. Instead, check the values exposed by objabi.
These experiments look potentially safe, but it seems too late in the
release cycle to try to assuage that. The one exception is frame
pointer experiment, which is trivially safe: it just amounts to
incrementing some stack offsets by PtrSize.
Russ Cox [Wed, 29 Nov 2017 21:31:47 +0000 (16:31 -0500)]
testing: remove claim that b.Run is safe for concurrent use
It's not safe (it crashes), and it's also useless: if you run
multiple benchmarks in parallel you will not get reliable
timing results from any of them.
Fixes #18603.
Change-Id: I00e5a72f7c98151543cf7d5573c38383276e391a
Reviewed-on: https://go-review.googlesource.com/80841 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Thu, 23 Nov 2017 03:12:12 +0000 (19:12 -0800)]
runtime: don't block signals that will kill the program
Otherwise we may delay the delivery of these signals for an arbitrary
length of time. We are already careful to not block signals that the
program has asked to see.
Also make sure that we don't miss a signal delivery if a thread
decides to stop for a while while executing the signal handler.
Also clean up the TestAtomicStop output a little bit.
Fixes #21433
Change-Id: Ic0c1a4eaf7eba80d1abc1e9537570bf4687c2434
Reviewed-on: https://go-review.googlesource.com/79581
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Hiroshi Ioka [Thu, 23 Nov 2017 01:37:05 +0000 (10:37 +0900)]
debug/gosym: update docs for changes in Go 1.3
Change-Id: I850d961e0444f8d34284e994aee183afba35eaa7
Reviewed-on: https://go-review.googlesource.com/79597 Reviewed-by: Ian Lance Taylor <iant@golang.org>