cmd/link, cmd/internal/obj: use encoding/binary for varint
This code was written before the c2go toolchain conversion.
Replace the handwritten varint encoding routines
and the handwritten unsigned-to-signed conversions
with calls to encoding/binary.
cmd/internal/obj: stop plist flushing early on error
If preprocessing or assembling has failed, we should not proceed.
First, there's no point.
Second, I will shortly add some sanity checks to linkpcln
that will fail on malformed input.
runtime: add //go:cgo_unsafe_args to AIX syscallX functions
On AIX, syscallX functions are using the first argument to retrieve the
next arguments when calling asmcgocall. Therefore,//go:cgo_unsafe_args
is needed.
Change-Id: I7fe0fbf0c961250a6573c66a8b0eb897dff94bfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/171723
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This file was forgotten during the port of aix/ppc64. In order to make
its tests passed, a few things were added:
- Add termios.h to zerrors
- Add AF_LOCAL = AF_UNIX as this constant doesn't exits natively on AIX
- Fix the alignment in cmsghdr structure.
TestPassFD doesn't work on AIX TL<2 because getsockname isn't working as
expected with unix socket.
net: retrieve if unix network is available only once for AIX
The previous version was executing "oslevel -s" everytime testableNetwork
was called with unix/unixgram network. The current version retrieves if
the network is possible only once at the beginning of the tests.
This is clearly faster:
ok net 74.045s
ok net 5.098s
bootstrap.bash: fix build if no exec wrapper exists
Since CL 170941 bootstrap.bash fails if no exec wrapper exists for a
given GOOS/GOARCH yet:
#### Building ../../go-linux-arm-bootstrap
Building Go cmd/dist using /usr/local/go.
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for host, linux/amd64.
Building packages and commands for target, linux/arm.
rm: cannot remove 'bin/go_linux_arm_exec': No such file or directory
Fix it by using 'rm -f' to ignore nonexisting files.
ftabaddstring adds a string to the pclntab.
The pclntab uses C strings, so the code added 1 to the length.
However, it also added an extraneous 1 in the Grow call. Remove that.
While we're here, simplify, document, remove an unnecessary parameter,
and remove some unnecessary conversions.
Shaves off a few bytes here and there, and thus updates #6853.
runtime: move libcall to stack for syscall package on aix/ppc64
Inside syscall_syscall6 function, libcall can directly be on the stack.
This is first function called with //go:nosplit, unlike runtime syscalls
which can be called during the sigtramp or by others //go:nosplit
functions.
Change-Id: Icc28def1a63e525850ec3bfb8184b995dfeaa736
Reviewed-on: https://go-review.googlesource.com/c/go/+/171338
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Failures here don't otherwise affect the build, but they do cause a
slow file leak in the user's temp directory. The user deserves at
least a cursory warning that something may be amiss.
Updates #30789
Change-Id: Id0e72b1967e7f7c88cdc94d532554496653f264b
Reviewed-on: https://go-review.googlesource.com/c/go/+/171764
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
runtime: abstract initializing and destroying Ps out of procresize
procresize is rather ungainly because it includes all of the code to
initialize new Ps and tear down unused Ps. Pull these out into their
own methods on the p type. This also tweaks the initialization loop in
procresize so we only initialize new Ps (and Ps we previously
destroyed) rather than asking each P "have you been initialized?"
This is for #10958 and #24543, but it's also just a nice cleanup.
Change-Id: Ic1242066f572c94a23cea8ea4dc47c918e31d559
Reviewed-on: https://go-review.googlesource.com/c/go/+/171762 Reviewed-by: Michael Knyszek <mknyszek@google.com>
os: fix aliasing bug in RemoveAllTestHook restoration
The code to swap RemoveAllTestHook in and out in
TestRemoveAllWithMoreErrorThanReqSize was making a copy of the
RemoveAllTestHook pointer, then attempting to restore by loading from
the copy of that pointer. Since the two copies of the pointer aliased
the same address, the restore operation had no effect, and any
RemoveAll tests that happened to run after
TestRemoveAllWithMoreErrorThanReqSize would fail.
runtime: set itab.fun[0] only on successful conversion
For a failed interface conversion not in ",ok" form, getitab
calls itab.init to get the name of the missing method for the
panic message. itab.init will try to find the methods, populate
the method table as it goes. When some method is missing, it sets
itab.fun[0] to 0 before return. There is a small window that
itab.fun[0] could be non-zero.
If concurrently, another goroutine tries to do the same interface
conversion, it will read the same itab's fun[0]. If this happens
in the small window, it sees a non-zero fun[0] and thinks the
conversion succeeded, which is bad.
Fix the race by setting fun[0] to non-zero only when we know the
conversion succeeds. While here, also simplify the syntax
slightly.
These workarounds predate proper DWARF support
and are no longer necessary.
Before this patch, running `/usr/bin/symbols go.o`
using the object in the c-archive would fail, causing
App Store rejections.
Fixes #31022 #28997
Change-Id: I6a210b6369c13038777c6e21e874e81afcb50c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/170377
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Michael Anthony Knyszek [Fri, 29 Mar 2019 16:02:05 +0000 (16:02 +0000)]
runtime: introduce treapForSpan to reduce code duplication
Currently which treap a span should be inserted into/removed from is
checked by looking at the span's properties. This logic is repeated in
four places. As this logic gets more complex, it makes sense to
de-duplicate this, so introduce treapForSpan instead which captures this
logic by returning the appropriate treap for the span.
Michael Anthony Knyszek [Sat, 9 Feb 2019 00:13:37 +0000 (00:13 +0000)]
runtime: add tests for runtime mTreap
This change exports the runtime mTreap in export_test.go and then adds a
series of tests which check that the invariants of the treap are
maintained under different operations. These tests also include tests
for the treap iterator type.
Also, we note that the find() operation on the treap never actually was
best-fit, so the tests just ensure that it returns an appropriately
sized span.
Michael Anthony Knyszek [Thu, 17 Jan 2019 20:05:20 +0000 (20:05 +0000)]
runtime: throw if scavenge necessary during coalescing
Currently when coalescing if two adjacent spans are scavenged, we
subtract their sizes from memstats and re-scavenge the new combined
span. This is wasteful however, since the realignment semantics make
this case of having to re-scavenge impossible.
In realign() inside of coalesce(), there was also a bug: on systems
where physPageSize > pageSize, we wouldn't realign because a condition
had the wrong sign. This wasteful re-scavenging has been masking this
bug this whole time. So, this change fixes that first.
Then this change gets rid of the needsScavenge logic and instead checks
explicitly for the possibility of unscavenged pages near the physical
page boundary. If the possibility exists, it throws. The intent of
throwing here is to catch changes to the runtime which cause this
invariant to no longer hold, at which point it would likely be
appropriate to scavenge the additional pages (and only the additional
pages) at that point.
golang.org/cl/121255 added close and re-open the directory when looping, prevent
us from missing some if previous iteration deleted files.
The CL introdued a bug. If we can not delete all entries in one request,
the looping never exits, causing RemoveAll hangs.
To fix that, simply discard the entries if we can not delete all of them
in one iteration, then continue reading entries and delete them.
Also make sure removeall_at return first error it encounters.
Fixes #29921
Change-Id: I8ec3a4c822d8d2d95d9f1ab71547879da395bc4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/171099
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Wed, 10 Apr 2019 18:06:58 +0000 (11:06 -0700)]
syscall: store skip count in file descriptor offset
Multiple calls to ReadDirent expect to return subsequent
portions of the directory listing. There's no place to store
our progress other than the file descriptor offset.
Fortunately, the file descriptor offset doesn't need to be
a real offset. We can store any int64 we want there.
Fixes #31368
Change-Id: I49e4e0e7ff707d3e96aa5d43e3b0199531013cde
Reviewed-on: https://go-review.googlesource.com/c/go/+/171477
Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Elias Naur [Mon, 8 Apr 2019 21:12:52 +0000 (23:12 +0200)]
runtime: correct the TLS base offset on Android
CL 170955 set tlsg to the Android Q free TLS slot offset in the linker
data (16 on amd64, 8 on 386), offsetting all TLS relative access.
We need the 0'th slot (TLS_SLOT_SELF) at initialization, so
compensate with a corresponding negative offset.
Fixes the android/386 and android/amd64 builders broken by CL 170955.
bytes: optimize ToLower and ToUpper for ASCII-only case
Follow what CL 68370 and CL 76470 did for the respective functions in
package strings.
Also adjust godoc strings to match the respective strings functions and
mention the special case for ASCII-only byte slices which don't need
conversion.
cmd/cover: rename temporary directory prefix for consistency
This change renames the temporary directory prefix for testing to
go-testcover from gotestcover. It looks like other packages have the
"go-" prefix for temporary directories, such as go-build, go-tool-dist
and go-nettest.
OINDREGSP was used only for reading the results of a function call.
In recognition of that fact, rename it to ORESULT.
Along the way, trim down our handling of it to the bare minimum,
and rely on the increased clarity of ORESULT to inline nodarg.
Elias Naur [Sun, 7 Apr 2019 13:02:31 +0000 (15:02 +0200)]
cmd/go/internal/work: make toolchain builds reproducible when buildmode=pie
When buildmode=pie, external linking is forced, and our toolchain build id
will be included in the external build id, resulting in the building of
a toolchain tool will never reach a fixed point id.
More importantly, this change will make make.bash converge on self-hosted
Android builds (Android refuses to run non-PIE executables).
Fixes #31320
Updates #18968
Change-Id: Icb5db9f4b1b688afe37f4dafe261ffda580fa4e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/170942
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Elias Naur [Sun, 7 Apr 2019 14:58:13 +0000 (16:58 +0200)]
cmd/dist: set buildmode=pie on Android
Android refuses to run non-PIE binaries, a restriction already
encoded in the cmd/go tool's buildModeInit function. This CL adds
the necessary flags to cmd/dist to make ./make.bash run on an
Android device.
Change-Id: I162084f573befaa41dcb47a2b78448bce5b83d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/170943
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Keith Randall [Tue, 2 Apr 2019 22:00:54 +0000 (15:00 -0700)]
cmd/compile: get rid of unnecessary inline marks
If no other instruction mentions an inline mark, we can get rid of it.
This normally happens when the inlined function is empty, or when all
of its code is folded into other instructions.
Also use consistent statement-ness for inline mark positions, so that
more of them can be removed in favor of existing instructions.
Michael Anthony Knyszek [Mon, 11 Feb 2019 17:20:59 +0000 (17:20 +0000)]
runtime: use iterator instead of raw node for treap find
Right now the mTreap structure exposes the treapNode structure through
only one interface: find. There's no reason (performance or otherwise)
for exposing this, and we get a cleaner abstraction through the
iterators this way. This change also makes it easier to make changes to
the mTreap implementation without violating its interface.
Michael Anthony Knyszek [Thu, 31 Jan 2019 16:57:29 +0000 (16:57 +0000)]
runtime: merge codepaths in scavengeLargest
This change just makes the code in scavengeLargest easier to reason
about by reducing the number of exit points to the method. It should
still be correct either way because the condition checked at the end
(released > nbytes) will always be false if we return, but this just
makes the code a little easier to maintain.
The Modified field allows representation of extended timestamps, which provide more accuracy than the legacy MS-DOS timestamps.
The FileInfo method provides an implementation of the os.FileInfo interface for files inside archives.
With this change, we make FileInfo use the Modified field, if present, to return more detailed timestamps from its ModTime method.
Fixes #28350
Change-Id: Ia31b5b871a3e61df38a3a1325787ae23ea0b8088
GitHub-Last-Rev: 13e94be3f8ba58717911354146670fc2bc594692
GitHub-Pull-Request: golang/go#28352
Reviewed-on: https://go-review.googlesource.com/c/go/+/144382
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Nigel Tao [Sat, 6 Apr 2019 23:33:36 +0000 (09:33 +1000)]
image: deprecate ZP and ZR
They were added a very long time ago, as a convenience before Go had
struct literals. Today, it is better to use the zero-valued literal. For
example, the compiler cannot prove that ZP or ZR have not been modified.
Change-Id: I7469f1c751e91bf76fe1eab07b5772eccb5d6405
Reviewed-on: https://go-review.googlesource.com/c/go/+/171097 Reviewed-by: Nigel Tao <nigeltao@golang.org>
Keith Randall [Sat, 6 Apr 2019 19:42:51 +0000 (12:42 -0700)]
cmd/compile: remove AUNDEF opcode
This opcode was only used to mark unreachable code for plive to use.
plive now uses the SSA representation, so it knows locations are
unreachable because they are ends of Exit blocks. It doesn't need
these opcodes any more.
These opcodes actually used space in the binary, 2 bytes per undef
on x86 and more for other archs.
runtime: separate stack freeing from stack shrinking
Currently, shrinkstack will free the stack if the goroutine is dead.
There are only two places that call shrinkstack: scanstack, which will
never call it if the goroutine is dead; and markrootFreeGStacks, which
only calls it on dead goroutines.
Clean this up by separating stack freeing out of shrinkstack.
Austin Clements [Tue, 26 Mar 2019 01:16:33 +0000 (21:16 -0400)]
runtime: use acquirem/releasem more widely
We've copy-pasted the pattern of releasem in many places. This CL
replaces almost everywhere that manipulates g.m.locks and g.preempt
with calls to acquirem/releasem. There are a few where we do something
more complicated, like where exitsyscall has to restore the stack
bound differently depending on the preempt flag, which this CL leaves
alone.
Austin Clements [Tue, 26 Mar 2019 02:24:03 +0000 (22:24 -0400)]
runtime: fix sanity check in notetsleep
CL 3660 replaced m.gcing with m.preemptoff, but unintentionally
reversed the sense of part of a sanity check in notetsleep.
Originally, notetsleep required that it be called from g0 or with
preemption disabled (specifically from within the garbage collector).
CL 3660 made it require that it be called from g0 or that preemption
be *enabled*.
I'm not sure why it had the original exception for being called from a
user g within the garbage collector, but the current garbage collector
certainly doesn't need that, and the new condition is completely wrong.
Make the sanity check just require that it's called on g0.
Austin Clements [Sat, 2 Mar 2019 20:16:29 +0000 (15:16 -0500)]
sync: smooth out Pool behavior over GC with a victim cache
Currently, every Pool is cleared completely at the start of each GC.
This is a problem for heavy users of Pool because it causes an
allocation spike immediately after Pools are clear, which impacts both
throughput and latency.
This CL fixes this by introducing a victim cache mechanism. Instead of
clearing Pools, the victim cache is dropped and the primary cache is
moved to the victim cache. As a result, in steady-state, there are
(roughly) no new allocations, but if Pool usage drops, objects will
still be collected within two GCs (as opposed to one).
This victim cache approach also improves Pool's impact on GC dynamics.
The current approach causes all objects in Pools to be short lived.
However, if an application is in steady state and is just going to
repopulate its Pools, then these objects impact the live heap size *as
if* they were long lived. Since Pooled objects count as short lived
when computing the GC trigger and goal, but act as long lived objects
in the live heap, this causes GC to trigger too frequently. If Pooled
objects are a non-trivial portion of an application's heap, this
increases the CPU overhead of GC. The victim cache lets Pooled objects
affect the GC trigger and goal as long-lived objects.
This has no impact on Get/Put performance, but substantially reduces
the impact to the Pool user when a GC happens. PoolExpensiveNew
demonstrates this in the substantially reduction in the rate at which
the "New" function is called.
Austin Clements [Fri, 1 Mar 2019 20:33:33 +0000 (15:33 -0500)]
sync: use lock-free structure for Pool stealing
Currently, Pool stores each per-P shard's overflow in a slice
protected by a Mutex. In order to store to the overflow or steal from
another shard, a P must lock that shard's Mutex. This allows for
simple synchronization between Put and Get, but has unfortunate
consequences for clearing pools.
Pools are cleared during STW sweep termination, and hence rely on
pinning a goroutine to its P to synchronize between Get/Put and
clearing. This makes the Get/Put fast path extremely fast because it
can rely on quiescence-style coordination, which doesn't even require
atomic writes, much less locking.
The catch is that a goroutine cannot acquire a Mutex while pinned to
its P (as this could deadlock). Hence, it must drop the pin on the
slow path. But this means the slow path is not synchronized with
clearing. As a result,
1) It's difficult to reason about races between clearing and the slow
path. Furthermore, this reasoning often depends on unspecified nuances
of where preemption points can occur.
2) Clearing must zero out the pointer to every object in every Pool to
prevent a concurrent slow path from causing all objects to be
retained. Since this happens during STW, this has an O(# objects in
Pools) effect on STW time.
3) We can't implement a victim cache without making clearing even
slower.
This CL solves these problems by replacing the locked overflow slice
with a lock-free structure. This allows Gets and Puts to be pinned the
whole time they're manipulating the shards slice (Pool.local), which
eliminates the races between Get/Put and clearing. This, in turn,
eliminates the need to zero all object pointers, reducing clearing to
O(# of Pools) during STW.
In addition to significantly reducing STW impact, this also happens to
speed up the Get/Put fast-path and the slow path. It somewhat
increases the cost of PoolExpensiveNew, but we'll fix that in the next
CL.
Austin Clements [Fri, 8 Mar 2019 20:01:34 +0000 (15:01 -0500)]
sync: add Pool benchmarks to stress STW and reuse
This adds two benchmarks that will highlight two problems in Pool that
we're about to address.
The first benchmark measures the impact of large Pools on GC STW time.
Currently, STW time is O(# of items in Pools), and this benchmark
demonstrates 70µs STW times.
The second benchmark measures the impact of fully clearing all Pools
on each GC. Typically this is a problem in heavily-loaded systems
because it causes a spike in allocation. This benchmark stresses this
by simulating an expensive "New" function, so the cost of creating new
objects is reflected in the ns/op of the benchmark.
Austin Clements [Fri, 1 Mar 2019 19:54:00 +0000 (14:54 -0500)]
sync: internal dynamically sized lock-free queue for sync.Pool
This adds a dynamically sized, lock-free, single-producer,
multi-consumer queue that will be used in the new Pool stealing
implementation. It's built on top of the fixed-size queue added in the
previous CL.
Austin Clements [Fri, 1 Mar 2019 18:16:37 +0000 (13:16 -0500)]
sync: internal fixed size lock-free queue for sync.Pool
This is the first step toward fixing multiple issues with sync.Pool.
This adds a fixed size, lock-free, single-producer, multi-consumer
queue that will be used in the new Pool stealing implementation.
Jay Conrod [Wed, 9 Jan 2019 21:40:01 +0000 (16:40 -0500)]
cmd/go: parallelize package loading
load.PackageAndErrors now preloads data used to build load.Package
structures. Multiple packages may be preloaded in parallel, so this
parallelizes most of the package loading work.
The actual package construction and error-checking process is still
sequential, since this process needs to detect and report cycles.
Fixes #29758
Change-Id: Icf37e6669836ce8aad076e34fd895f97f4f3f9e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/161397
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Austin Clements [Mon, 31 Dec 2018 00:47:27 +0000 (19:47 -0500)]
runtime: ring buffer for binary debug logging
This adds an internal runtime debug log. It uses per-M time-stamped
ring buffers of binary log records. On panic, these buffers are
collected, interleaved, and printed.
The entry-point to the debug log is a new "dlog" function. dlog is
designed so it can be used even from very constrained corners of the
runtime such as signal handlers or inside the write barrier.
The facility is only enabled if the debuglog build tag is set.
Otherwise, it compiles away to a no-op implementation.
The debug log format is also designed so it would be reasonable to
decode from a core dump, though this hasn't been implemented.
grant [Wed, 3 Apr 2019 14:21:21 +0000 (14:21 +0000)]
net: use libSystem bindings for DNS resolution on macos if cgo is unavailable
This change adds directives to link the res_search function in libSystem.
The corresponding Go function is then used in `lookup_darwin.go` for
resolution when cgo is disabled. This makes DNS resolution logic more
reliable as macOS has some unique quirks such as the `/etc/resolver/`
directory for specifying nameservers.
Than McIntosh [Thu, 4 Apr 2019 15:01:22 +0000 (11:01 -0400)]
math/bits: add gccgo-friendly code for compiler bootstrap
When building as part of the bootstrap process, avoid
use of "go:linkname" applied to variables, since this
feature is ill-defined/unsupported for gccgo.
Updates #30771.
Change-Id: Id44d01b5c98d292702e5075674117518cb59e2d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/170737 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Richard Musiol [Sun, 24 Mar 2019 11:14:27 +0000 (12:14 +0100)]
cmd/compile: add saturating conversions on wasm
This change adds the GOWASM option "satconv" to enable the generation
of experimental saturating (non-trapping) float-to-int conversions.
It improves the performance of the conversion by 42%.
Previously the conversions had already been augmented with helper
functions to have saturating behavior. Now Wasm.rules is always using
the new operation names and wasm/ssa.go is falling back to the helpers
if the feature is not enabled.
The feature is in phase 4 of the WebAssembly proposal process:
https://github.com/WebAssembly/meetings/blob/master/process/phases.md
More information on the feature can be found at:
https://github.com/WebAssembly/nontrapping-float-to-int-conversions/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
Robert Griesemer [Thu, 28 Mar 2019 20:32:31 +0000 (13:32 -0700)]
cmd/compile: better recovery after := (rather than =) in declarations
Before this fix, a mistaken := in a (const/type/var) declaration
ended that declaration with an error from which the parser didn't
recover well. This low-cost change will provide a better error
message and lets the parser recover perfectly.
Fixes #31092.
Change-Id: Ic4f94dc5e29dd00b7ef6d53a80dded638e3cea80
Reviewed-on: https://go-review.googlesource.com/c/go/+/169958 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Keith Randall [Wed, 20 Mar 2019 17:47:17 +0000 (10:47 -0700)]
syscall: avoid _getdirentries64 on darwin
Getdirentries is implemented with the __getdirentries64 function
in libSystem.dylib. That function works, but it's on Apple's
can't-be-used-in-an-app-store-application list.
Implement Getdirentries using the underlying fdopendir/readdir_r/closedir.
The simulation isn't faithful, and could be slow, but it should handle
common cases.
Don't use Getdirentries in the stdlib, use fdopendir/readdir_r/closedir
instead (via (*os.File).readdirnames).
smasher164 [Thu, 7 Feb 2019 08:38:21 +0000 (03:38 -0500)]
cmd/compile: return assignment mismatch error in var declarations
Some var declarations return "extra expression" or "missing expression"
errors when they should return “assignment mismatch” instead. Change
the returned error messages to exhibit the desired behavior.
Fixes #30085.
Change-Id: I7189355fbb0f976d70100779db4f81a9ae64fb11
Reviewed-on: https://go-review.googlesource.com/c/go/+/161558 Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Bryan C. Mills [Tue, 8 Jan 2019 15:34:16 +0000 (10:34 -0500)]
cmd/go/internal/web: reject insecure redirects from secure origins
We rely on SSL certificates to verify the identity of origin servers.
If an HTTPS server redirects through a plain-HTTP URL, that hop can be
compromised. We should allow it only if the user set the -insecure
flag explicitly.
Jay Conrod [Mon, 11 Mar 2019 22:53:08 +0000 (18:53 -0400)]
cmd/go: print require chains in build list errors
mvs.BuildList and functions that invoke it directly (UpgradeAll) now
return an *mvs.BuildListError when there is an error retrieving the
requirements for a module. This new error prints the chain of
requirements from the main module to the module where the error
occurred.
These errors come up most commonly when a go.mod file has an
unexpected module path or can't be parsed for some other reason. It's
currently difficult to debug these errors because it's not clear where
the "bad" module is required from. Tools like "go list -m" and
"go mod why" don't work without the build graph.
Fixes #30661
Change-Id: I3c9d4683dcd9a5d7c259e5e4cc7e1ee209700b10
Reviewed-on: https://go-review.googlesource.com/c/go/+/166984
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
cmd/go/internal/lockedfile: add a sync.Mutex to lockedfile.Mutex
The compiler (and race detector) don't interpret locking a file as a
synchronization operation, so we add an explicit (and redundant)
sync.Mutex to make that property clear.
The additional synchronization makes it safe to parallelize the tests
in cmd/go/internal/modfetch/coderepo_test.go, which cuts the wall time
of that test by around 50%.
Updates #30550
Change-Id: Ief3479020ebf9e0fee524a4aae5568697727c683
Reviewed-on: https://go-review.googlesource.com/c/go/+/170597
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Jay Conrod <jayconrod@google.com>