Daniel Martí [Tue, 17 Jul 2018 13:38:52 +0000 (14:38 +0100)]
cmd/compile: fix crash on invalid struct literal
If one tries to use promoted fields in a struct literal, the compiler
errors correctly. However, if the embedded fields are of struct pointer
type, the field.Type.Sym.Name expression below panics.
This is because field.Type.Sym is nil in that case. We can simply use
field.Sym.Name in this piece of code though, as it only concerns
embedded fields, in which case what we are after is the field name.
Added a test mirroring fixedbugs/issue23609.go, but with pointer types.
Fixes #26416.
Change-Id: Ia46ce62995c9e1653f315accb99d592aff2f285e
Reviewed-on: https://go-review.googlesource.com/124395
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Ian Lance Taylor [Wed, 18 Jul 2018 20:19:04 +0000 (13:19 -0700)]
doc: update go1.11 release notes
Change-Id: I806d411c075cdc66322112b6ee5e50f58462bc6b
Reviewed-on: https://go-review.googlesource.com/124776 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Jack [Wed, 18 Jul 2018 19:12:14 +0000 (19:12 +0000)]
filepath: updates doc to give case where WalkFunc info arg may be nil
If a filepath.WalkFunc is called with an non-nil err argument, it's possible
that the info argument will be nil. The comment above filepath.WalkFunc now
reflects this.
Fixes #26425
Change-Id: Ib9963b3344587d2993f1698c5a801f2d1286856b
GitHub-Last-Rev: 553fc266b570d0c47efe12b3b670f88112e3b334
GitHub-Pull-Request: golang/go#26435
Reviewed-on: https://go-review.googlesource.com/124635 Reviewed-by: Ian Lance Taylor <iant@golang.org>
doc: fix a link in go1.11.html and flesh out a few sections
Change-Id: Ic5b9ccb2772534cee77ffcaeee617c7d5edfb6fd
Reviewed-on: https://go-review.googlesource.com/124715 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Hana (Hyang-Ah) Kim [Wed, 18 Jul 2018 07:06:21 +0000 (03:06 -0400)]
doc/go1.11: update runtime/pprof change note
Mention the change in the behavior of go test -memprofile.
Change-Id: I0384f058298bd8fcfd2d97996464d46b4e419938
Reviewed-on: https://go-review.googlesource.com/124656 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Alberto Donizetti [Wed, 18 Jul 2018 08:53:44 +0000 (10:53 +0200)]
doc/go1.11: add space in Go version name
Missed in CL 124516.
Change-Id: I6488196c8392987d69eca832ab4969aaafe1a26c
Reviewed-on: https://go-review.googlesource.com/124658 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Elias Naur [Wed, 18 Jul 2018 07:17:19 +0000 (09:17 +0200)]
doc/go1.11: mention the libSystem.so change for iOS
The change to make the runtime use libSystem.so macOS instead of
direct kernel calls applies to iOS as well.
Change-Id: I97ea86452ac5f7433aea58bbd3ff53a2eb2835e0
Reviewed-on: https://go-review.googlesource.com/124657 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Wed, 18 Jul 2018 00:36:15 +0000 (17:36 -0700)]
cmd/cgo: don't report inconsistency error for incomplete typedef
In CLs 122575 and 123177 the cgo tool started explicitly looking up
typedefs. When there are two Go files using import "C", and the first
one has an incomplete typedef and the second one has a complete
version of the same typedef, then we will now record a version of the
first typedef which will not match the recorded version of the second
typedef, producing an "inconsistent definitions" error. Fix this by
silently merging incomplete typedefs with complete ones.
Fixes #26430
Change-Id: I9e629228783b866dd29b5c3a31acd48f6e410a2d
Reviewed-on: https://go-review.googlesource.com/124575
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
cmd/go/internal/modfetch: restrict file names in zip files, avoid case-insensitive collisions
Within the zip file for a given module, disallow names that are invalid
on various operating systems (mostly Windows), and disallow
having two different paths that are case-fold-equivalent.
Disallowing different case-fold-equivalent paths means the
zip file content is safe for case-insensitive file systems.
There is more we could do to relax the rules later, but I think
this should be enough to avoid digging a hole in the early days
of modules that's hard to climb out of later.
In tests on my repo test corpus, the repos now rejected are:
The : and ? are reserved on Windows,
and the : is half-reserved (and quite confusing) on macOS.
The ☺ is perhaps an overreach, but I am not convinced
that allowing all of category So is safe; certainly Sk is not.
cmd/go/internal/modfetch: do not rely on file system for case sensitivity
Over time there may exist two modules with names that differ only in case.
On systems with case-insensitive file systems, we need to make sure those
modules do not collide in the download cache.
Do this by using the new "safe encoding" for file system paths as well as
proxy paths.
Module paths, like import paths, are case-sensitive, for better or worse.
But not all file systems distinguish file paths with different cases.
If we are going to use module paths to construct file system paths,
we must apply an encoding that distinguishes case without relying
upon the file system to do it.
This CL defines that encoding, the "safe module path encoding".
Module paths today are ASCII-only with limited punctuation,
so the safe module path encoding is to convert the whole path
to lower case and insert an ! before every formerly upper-case letter:
github.com/Sirupsen/logrus is stored as github.com/!sirupsen/logrus.
Although this CL defines the encoding, it does not change the rest
of the go command to use the encoding. That will be done in
follow-up CLs.
path/filepath: make Walk example runnable in the playground
Relates to #9679
Change-Id: I68951f664d2a03812dae309c580c181869d8af21
Reviewed-on: https://go-review.googlesource.com/122237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
cmd/cgo: update JNI's jobject to uintptr check for newer Android NDKs
In Android's NDK16, jobject is now declared as:
#ifdef __cplusplus
class _jobject {};
typedef _jobject* jobject;
#else /* not __cplusplus */
typedef void* jobject;
#endif
This makes the jobject to uintptr check fail because it expects the
following definition:
struct _jobject;
typedef struct _jobject *jobject;
Update the type check to handle that new type definition in both C and
C++ modes.
Fixes #26213
Change-Id: Ic36d4a5176526998d2d5e4e404f8943961141f7a
GitHub-Last-Rev: 42037c3c584579c2b3281c25372b830e864e7aec
GitHub-Pull-Request: golang/go#26221
Reviewed-on: https://go-review.googlesource.com/122217
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Alberto Donizetti [Thu, 28 Jun 2018 18:22:13 +0000 (20:22 +0200)]
doc/go1.11: explain new vet typechecking behaviour in release notes
Since Go1.10, go test runs vet on the tests before executing them.
Moreover, the vet tool typechecks the package under analysis with
go/types before running. In Go1.10, a typechecking failure just caused
a warning to be printed. In Go1.11, a typechecking failure will cause
vet to exit with a fatal error (see Issue #21287).
This means that starting with Go1.11, tests that don't typecheck will
fail immediately. This would not normally be an issue, since a test
that doesn't typecheck shouldn't even compile, and it should already
be broken.
Unfortunately, there's a bug in gc that makes it accept programs with
unused variables inside a closure (Issue #3059). This means that a
test with an unused variable inside a closure, that compiled and
passed in Go1.10, will fail in the typechecking step of vet starting
with Go1.11.
Explain this in the 1.11 release notes.
Fixes #26109
Change-Id: I970c1033ab6bc985d8c64bd24f56e854af155f96
Reviewed-on: https://go-review.googlesource.com/121455 Reviewed-by: Ian Lance Taylor <iant@golang.org>
The original CL skipped the lldb test if it couldn't read compressed
DWARF, but lldb can never read compressed DWARF, so this effectively
disabled this test unconditionally.
The previous commit disabled DWARF compression for this test, so the
test now works on its own merits again. This CL reverts the change to
skip the test so we don't simply mask lldb failures.
lldb doesn't support compressed DWARF, so right now we're just always
skipping the lldb test. This CL makes the test run again by disabling
compressed DWARF just for this test.
Michael Munday [Tue, 17 Jul 2018 07:39:30 +0000 (08:39 +0100)]
cmd/compile: keep autos if their address reaches a control value
Autos must be kept if their address reaches the control value of a
block. We didn't see this before because it is rare for an auto's
address to reach a control value without also reaching a phi or
being written to memory. We can probably optimize away the
comparisons that lead to this scenario since autos cannot alias
with pointers from elsewhere, however for now we take the
conservative approach and just ensure the auto is properly
initialised if its address reaches a control value.
Fixes #26407.
Change-Id: I02265793f010a9e001c3e1a5397c290c6769d4de
Reviewed-on: https://go-review.googlesource.com/124335 Reviewed-by: David Chase <drchase@google.com>
The original cmd/go tests were tiny shell scripts
written against a library of shell functions.
They were okay to write but difficult to run:
you couldn't select individual tests (with -run)
they didn't run on Windows, they were slow, and so on.
CL 10464 introduced go_test.go's testgo framework
and later CLs translated the test shell script over to
individual go tests. This let us run tests selectively,
run tests on Windows, run tests in parallel, isolate
different tests, and so on. It was a big advance.
The tests had always been awkward to write.
Here was the first test in test.bash:
TEST 'file:line in error messages'
# Test that error messages have file:line information at beginning of
# the line. Also test issue 4917: that the error is on stderr.
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
fn=$d/err.go
echo "package main" > $fn
echo 'import "bar"' >> $fn
./testgo run $fn 2>$d/err.out || true
if ! grep -q "^$fn:" $d/err.out; then
echo "missing file:line in error message"
cat $d/err.out
ok=false
fi
rm -r $d
This CL introduces a new facility meant as a successor to the testgo
approach that brings back the style of writing tests as little scripts,
but they are now scripts in a built-for-purpose shell-like language,
not bash itself. In this new form, the test above is a single file,
testdata/script/fileline.txt:
# look for short, relative file:line in error message
! go run ../../gopath/x/y/z/err.go
stderr ^..[\\/]x[\\/]y[\\/]z[\\/]err.go:
-- ../x/y/z/err.go --
package main; import "bar"
The file is a txtar text archive (see CL 123359) in which the leading comment
is the test script and the files are the initial state of the temporary file
system where the script runs.
Each script runs as a subtest, so that they can still be selected individually.
The scripts are kept isolated from each other by default,
so all script subtests are treated as parallel tests, for the
testing package to run in parallel. Even for the 15 tests in
this CL, that cuts the time for TestScript from 5.5s to 2.5s.
The scripts do not have access to the cmd/go source directory,
nor to cmd/go/testdata, so they are prevented from creating temporary
files in those places or modifying existing ones. (Many existing tests
scribble in testdata, unfortunately, especially testdata/pkg when
they run builds with GOPATH=testdata.)
This CL introduces the script facility and converts 15 tests.
The txtar archive form will allow us to delete the large trees of trivial
files in testdata; a few are deleted in this CL.
See testdata/script/README for details and a larger conversion example.
As part of converting testdata/script/test_badtest.txt,
I discovered that 'go test' was incorrectly printing a FAIL line
to stderr (not stdout) in one corner case. This CL fixes that
to keep the test passing.
Future CLs will convert more tests.
Change-Id: I11aa9e18dd2d4c7dcd8e310dbdc6a1ea5f7e54c1
Reviewed-on: https://go-review.googlesource.com/123577
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Mon, 16 Jul 2018 10:32:05 +0000 (20:32 +1000)]
doc: update Usage section of the FAQ
This is close to a complete rewrite, as the content was pretty old.
The CL includes links to the Wiki for information about companies
using Go, a new section about IDEs and editors¹, and a restatement
of the foreign function interface story. It also modernizes and
expands a little on the use of Go inside Google.
¹ Ed is the standard editor.
Change-Id: I5e54aafa53d00d86297b2691960a376b40f6225b
Reviewed-on: https://go-review.googlesource.com/123922 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Mon, 16 Jul 2018 21:22:41 +0000 (07:22 +1000)]
doc: rewrite run-on sentence in garbage collection discussion
Change-Id: I60cb7010448757ca4c7a2973bee2277b3d5fc439
Reviewed-on: https://go-review.googlesource.com/124175 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Ian Lance Taylor [Tue, 17 Jul 2018 02:09:24 +0000 (19:09 -0700)]
cmd/go: fix handling of vet.cfg with buggyInstall
The vet action assumes that a.Deps[0] is the compilation action for
which vet information should be generated. However, when using
-linkshared, the action graph is built with a ModeBuggyInstall action
to install the shared library built from the compilation action.
Adjust the set up of the vet action accordingly. Also don't clean up
the working directory after completing the buggy install.
Updates #26400
Change-Id: Ia51f9f6b8cde5614a6f2e41b6207478951547770
Reviewed-on: https://go-review.googlesource.com/124275
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
cmd/go/internal/cache: squelch cache init warnings when $HOME is /
Docker sets $HOME to / when running with a UID that doesn't exist within
the container. This not uncommon on CI servers.
Fixes #26280
Change-Id: Ic7ff62b41403fe6e7c0cef12814667ef73f6c954
Reviewed-on: https://go-review.googlesource.com/122487
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Joe Tsai [Mon, 16 Jul 2018 20:05:25 +0000 (13:05 -0700)]
archive/zip: fix regression when writing directories
Several adjustments:
1) When encoding the FileHeader for a directory, explicitly set all of the sizes
to zero regardless of their prior values. These values are currently populated
by FileInfoHeader as it calls os.FileInfo.Size regardless of whether the file is
a directory or not. We avoid fixing FileInfoHeader now as it is too late in the
release cycle (see #24082).
We silently adjust slightly wrong FileHeader fields as opposed to returning
an error because the CreateHeader method already does such mutations
(e.g., for UTF-8 detection, data descriptor, etc).
2) Have dirWriter.Write only return an error if some number of bytes are written.
Some code still call Write for both normal files and directories, but just pass
an empty []byte to Write for directories.
When x509ignoreCN=1 is present in GODEBUG, ignore the deprecated Common
Name field. This will let people test a behavior we might make the
default in the future, and lets a final class of certificates avoid the
NameConstraintsWithoutSANs error.
crypto/x509: ignore Common Name when it does not parse as a hostname
The Common Name is used as a hostname when there are no Subject
Alternative Names, but it is not restricted by name constraints. To
protect against a name constraints bypass, we used to require SANs for
constrained chains. See the NameConstraintsWithoutSANs error.
This change ignores the CN when it does not look like a hostname, so we
can avoid returning NameConstraintsWithoutSANs.
This makes it possible to validate certificates with non-hostname CN
against chains that use name constraints to disallow all names, like the
Estonian IDs.
Updates #24151
Change-Id: I798d797990720a01ad9b5a13336756cc472ebf44
Reviewed-on: https://go-review.googlesource.com/123355 Reviewed-by: Adam Langley <agl@golang.org>
Keith Randall [Mon, 16 Jul 2018 17:45:25 +0000 (10:45 -0700)]
misc/cgo: fix darwin test, again
TARGET_OS_OSX is the right macro, but it also was only introduced
in 1.12. For 1.11 and earlier a reasonable substitution is
TARGET_OS_IPHONE == 0.
Update #24161
Update #26355
Change-Id: I5f43c463d14fada9ed1d83cc684c7ea05d94c5f3
Reviewed-on: https://go-review.googlesource.com/124075
Run-TryBot: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ian Lance Taylor [Fri, 13 Jul 2018 16:57:17 +0000 (09:57 -0700)]
cmd/go: make TestNewReleaseRebuildsStalePackagesInGOPATH pass again
The test TestNewReleaseRebuildsStalePackagesInGOPATH is not run in
short mode, so people tend to not notice when it fails. It was failing
due to the build cache. Make it pass again by 1) changing it to modify
the package in a way visible to the compiler, so that the change is
not hidden by caching; 2) accepting "not installed but available in
build cache" as always being a valid reason for a stale package, as go
list does not try to figure out an underlying reason for why a package
is stale when it finds it in the build cache but not installed.
Updates #24436
Change-Id: Iaeaa298f153451ec913a653dd4e6da79a33055bb
Reviewed-on: https://go-review.googlesource.com/123815 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Hana (Hyang-Ah) Kim [Fri, 13 Jul 2018 20:11:24 +0000 (16:11 -0400)]
runtime/pprof: add a fake mapping when /proc/self/maps is unavailable
Profile's Mapping field is currently populated by reading /proc/self/maps.
On systems where /proc/self/maps is not available, the profile generated
by Go's runtime will not have any Mapping entry. Pprof command then adds
a fake entry and links all Location entries in the profile with the fake
entry to be used during symbolization.
https://github.com/google/pprof/blob/a8644067d5a3c9a6386e7c88fa4a3d9d37877ca3/internal/driver/fetch.go#L437
The fake entry is not enough to suppress the error or warning messages
pprof command produces. We need to tell pprof that Location entries are
symbolized already by Go runtime and pprof does not have to attempt to
perform further symbolization.
In #25743, we made Go runtime mark Mapping entries with HasFunctions=true
when all Location entries from the Mapping entries are successfully
symbolized. This change makes the Go runtime add a fake mapping entry,
otherwise the pprof command tool would add, and set the HasFunctions=true
following the same logic taken when the real mapping information is
available.
Updates #19790.
Fixes #26255. Tested pprof doesn't report the error message any more
for pure Go program.
Change-Id: Ib12b62e15073f5d6c80967e44b3e8709277c11bd
Reviewed-on: https://go-review.googlesource.com/123779
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Rob Pike [Sat, 14 Jul 2018 06:46:57 +0000 (16:46 +1000)]
doc: update Design and Types sections of the FAQ
Update #26107.
Change-Id: I8bfa5b01ce953c53f7fd7a866d0ece61ba04c618
Reviewed-on: https://go-review.googlesource.com/123919 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Sat, 14 Jul 2018 04:52:31 +0000 (14:52 +1000)]
doc: update Values, Writing Code, and Pointers and Allocation sections of the FAQ
Significant surgery done to the Versioning section, bringing it closer to
modern thinking.
Also add a question about constants.
Update #26107.
Change-Id: Icf70b7228503c6baaeab0b95ee3e6bee921575aa
Reviewed-on: https://go-review.googlesource.com/123918 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Sat, 14 Jul 2018 04:06:28 +0000 (14:06 +1000)]
doc: update Implementation and Performance sections of the FAQ
Changes are mostly about making more about now than about the past,
changing some verb tenses, and mentioning gollvm (which should
be pronounced "gollum" if you ask me).
Update #26107
Change-Id: I6c14f42b9fc2684259d4ba8bc149d7ec9bb83d15
Reviewed-on: https://go-review.googlesource.com/123917 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Thu, 12 Jul 2018 23:08:13 +0000 (09:08 +1000)]
doc: rearrange the description of GOMAXPROCS
The old text was written when it was only 1 by default, which
changed a long time ago.
Also add a note that GOMAXPROCS does not limit the total
number of threads.
Change-Id: I104ccd7266d11335320a4d7f5671fb09ed641f88
Reviewed-on: https://go-review.googlesource.com/123916 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Sun, 15 Jul 2018 00:18:45 +0000 (17:18 -0700)]
misc/cgo: fix test on iOS
The test in CL 123715 doesn't work on iOS, it needs to use a different
version scheme to determine whether SecKeyAlgorithm and friends exist.
Restrict the old version test to OSX only.
The same problem occurs on iOS: the functions tested don't exist before
iOS 10. But we don't have builders below iOS 10, so it isn't a big issue.
If we ever get older builders, or someone wants to run all.bash on an
old iOS, they'll need to figure out the right incantation.
Adam Shannon [Fri, 13 Jul 2018 18:44:51 +0000 (13:44 -0500)]
os/exec: document ExtraFiles is not supported on windows
Fixes #26182
Change-Id: I1181e191f4742f166c9b67a6f41332a237cf0ede
Reviewed-on: https://go-review.googlesource.com/123855 Reviewed-by: Ian Lance Taylor <iant@golang.org>
regexp: reword Match documentation to be more like Find
Before:
// Find returns a slice holding the text of the leftmost match in b of the regular expression.
// Match checks whether a textual regular expression matches a byte slice.
After:
// Match reports whether the byte slice b contains any match of the regular expression re.
The use of different wording for Find and Match always makes me think
that Match required the entire string to match while Find clearly allows
a substring to match.
This CL makes the Match wording correspond more closely to Find,
to try to avoid that confusion.
Change-Id: I97fb82d5080d3246ee5cf52abf28d2a2296a5039
Reviewed-on: https://go-review.googlesource.com/123736
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Than McIntosh [Wed, 11 Jul 2018 16:30:05 +0000 (12:30 -0400)]
cmd/link: eliminate a couple of unused DWARF attrs
The linker's DWARF generation occasionally computes and attaches an
attribute X to a type even though the type's abbrev doesn't have the
specified attr. For example, the DW_TAG_subroutine_type abbrev entry
has no type attribute, but a type attr is given to it (wasting
memory). Similarly there are some places where a byte size attr is
added to a DIE whose abbrev lacks that attr. This patch trims away a
few of these not-needed attrs, saving some very tiny amount of memory.
Jakub Čajka [Fri, 13 Jul 2018 13:23:12 +0000 (15:23 +0200)]
cmd/go: call flag.Parse to properly initialize test environment variables
Executing tests in src/cmd/go/internal/modfetch/codehost/git_test.go in enviroment
witout outside connectivity in to the internet results in tests failure:
2018/07/13 14:31:14 git clone --mirror https://vcs-test.golang.org/git/gitrepo1 /tmp/gitrepo-test-996701800/gitrepo2 in : exit status 128:
Cloning into bare repository '/tmp/gitrepo-test-996701800/gitrepo2'...
fatal: unable to access 'https://vcs-test.golang.org/git/gitrepo1/': Could not resolve host: vcs-test.golang.org
FAIL cmd/go/internal/modfetch/codehost 0.307s
Fixes #26007
Change-Id: Ia39d8b3215c920dad6c0c58ffabb0b2ab39bb55c
Reviewed-on: https://go-review.googlesource.com/123735
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Johan Brandhorst [Thu, 12 Jul 2018 16:32:02 +0000 (16:32 +0000)]
net/http: correct use of byte slice in js syscall
syscall/js does not allow []byte to be used in direct inputs to
its JavaScript manipulation methods since
https://github.com/golang/go/commit/bafe466a9537d8ea5ac5767504628803302ebb12.
Unfortunately, this use of a byte slice was missed, so any
uses of the WASM Roundtripper with a body will panic.
This ensures the byte slice is appropriately converted
before being passed to syscall.
Keith Randall [Thu, 12 Jul 2018 23:51:27 +0000 (16:51 -0700)]
misc/cgo/test: fix issue 24161 test for 1.11 and earlier
The test uses functions from C that were introduced in OSX 1.12.
Include stubs for those functions when compiling for 1.11 and earlier.
This test really a compile-time test, it doesn't matter much what the
executed code actually does.
Use a nasty #define hack to work around the fact that cgo doesn't
support static global variables.
Update #24161
Fixes #26355
Change-Id: Icf6f7bc9b6b36cacc81d5d0e033a2ebaff7e0298
Reviewed-on: https://go-review.googlesource.com/123715
Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Rob Pike [Thu, 12 Jul 2018 05:57:56 +0000 (15:57 +1000)]
doc: update Concurrency, Functions and Methods, and Control Flow sections
Many parts of the FAQ are dusty and need cleaning up.
This is the first of a series of changes to bring it up to date.
Since it was first written at the time of release, some of the
ideas and background have changed, and some historical
remarks are largely irrelevant now.
Update #26107.
Change-Id: I1f36df7d8ecc8a1a033d5ac4fa1edeece25ed6b4
Reviewed-on: https://go-review.googlesource.com/123496 Reviewed-by: Ian Lance Taylor <iant@golang.org>
go/types: record type information after detecting error
The existing implementation stops recording type information once it
encounters an error. This results in missing type information that is
needed by various tools. This change handles a few commonly encountered
cases by continuing to check subtrees after errors. Also, add tests for
cases where the package fails to type-check.
net/http: make Transport.CloseIdleConnections close non-bundled http2.Transport
Previously Transport.CloseIdleConnections only closed the HTTP/2
Transport's idle connections if the HTTP/2 transport was configured
automatically via the bundled copy (in h2_bundle.go).
This makes it also work if the user called http2.ConfigureTransport
themselves using golang.org/x/net/http2 instead of the bundled copy.
No tests because we have no current way to run such cross-repo tests,
at least in any efficient or non-flaky way.
Keith Randall [Tue, 10 Jul 2018 20:47:15 +0000 (13:47 -0700)]
cmd/cgo: fix cgo bad typedefs
Two fixes:
1) Typedefs of the bad typedefs should also not be rewritten to the
underlying type. They shouldn't just be uintptr, though, they should
retain the C naming structure. For example, in C:
we know that we need to investigate the type SecKeyAlgorithm.
Might as well just find every typedef and check the badness of all of them.
This requires looping until a fixed point of known types is reached.
Usually it takes just 2 iterations, sometimes 3.
Fixes #24161
Change-Id: I32ca7e48eb4d4133c6242e91d1879636f5224ea9
Reviewed-on: https://go-review.googlesource.com/123177
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Thu, 12 Jul 2018 18:44:05 +0000 (11:44 -0700)]
cmd/compile: handle degenerate write barrier case
If both branches of a write barrier test go to the same block,
then there's no unsafe points.
This can only happen if the resulting memory state is somehow dead,
which can only occur in degenerate cases, like infinite loops. No
point in cleaning up the useless branch in these situations.
Fixes #26024.
Change-Id: I93a7df9fdf2fc94c6c4b1fe61180dc4fd4a0871f
Reviewed-on: https://go-review.googlesource.com/123655 Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
David Chase [Tue, 3 Jul 2018 15:34:38 +0000 (11:34 -0400)]
cmd/compile: add LocalAddr that takes SP,mem operands
Lack of a well-defined order between VarDef and related
address operations sometimes causes problems with store order
and write barrier transformations; glitches in the order are
made irreparable (by later optimizations) if the two parts of
the glitch straddle a split in the original block caused by
insertion of a write barrier diamond.
Fix this by creating a LocalAddr for addresses of locals
(what VarDef matters for) that takes a memory input to
help make the order explicit. Addr is modified to only
be legal for SB operand, so there is no overlap between
Addr and LocalAddr uses (there may be some downstream
cleanup from this).
Changes to generic.rules and rewrite.go ensure that codegen
tests continue to pass; CSE of LocalAddr is impaired, not
quite sure of the cost.
Fixes #26105.
Change-Id: Id4192b4440aa4e9d7ba54a465c456df9b530b515
Reviewed-on: https://go-review.googlesource.com/122483
Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@golang.org>
The behavior of -a no longer changes depending on which kind
of branch of Go you are using (the new build cache fixed all that).
These tests are not doing anything useful (and failing).
net/http: add tests to validate that Client.Timeout closes connections
For #23399
Change-Id: I9bc7c21fda6bfa89af2e7656e5c85aa9edd4f29e
Reviewed-on: https://go-review.googlesource.com/123435 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Rob Pike [Thu, 12 Jul 2018 01:37:17 +0000 (11:37 +1000)]
doc: clarify a sentence about *_js.go
Change "have to" to "need to" for clarity and to avoid a
peculiar English idiom.
Change-Id: Iec2b1f841d0353dd7925f8f934fe82d4ed059d7d
Reviewed-on: https://go-review.googlesource.com/123495 Reviewed-by: Ian Lance Taylor <iant@golang.org>