Commit graph

53420 commits

Author SHA1 Message Date
Matthew Dempsky 1355ea3045 cmd/compile: remove -importmap flag
Obsoleted by -importcfg, and no longer used by anything.

Updates #51225.

Change-Id: I49e646d2728347f862f90805051bb03dd4f4bed2
Reviewed-on: https://go-review.googlesource.com/c/go/+/415235
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-07-13 21:42:13 +00:00
Bryan C. Mills f71f3d1b86 misc/cgo/testshared: run tests only in GOPATH mode
-buildmode=shared installs shared libraries into GOROOT
and expects to reuse them across builds.
Builds in module mode, however, each have their own set of
dependencies (determined by the module's requirements), so in general
cannot share dependencies with a single GOROOT.

Ideally in the long term we would like to eliminate -buildmode=shared
entirely (see #47788), but first we need a replacement for the subset
of use-cases where it still works today.

In the meantime, we should run these tests only in GOPATH mode.
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway,
and this test heavily relies on installing non-main packages.

For #37015.

Change-Id: I7c5d90b4075d6f33e3505d6a8f12752309ae5c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/417194
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-07-13 20:43:22 +00:00
Bryan C. Mills feada53661 misc/cgo/testcshared: don't rely on an erroneous install target in tests
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.

This change switches the 'go install' command in createHeaders to
instead use 'go build' (with an extension determined by the install
target for 'runtime/cgo', which is well-defined at least for the
moment), and switches TestCachedInstall (which appears to be
explicitly testing 'go install') to explicitly request GOPATH mode
(which provides a well-defined install target for the library).

This change follows a similar structure to CL 416954.

For #37015.

Change-Id: I22ae4af0f0d4c50adc9e0f0dc279859d1f258cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/417096
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-13 20:43:20 +00:00
Michael Pratt c006b7ac27 runtime: clear timerModifiedEarliest when last timer is deleted
timerModifiedEarliest contains the lowest possible expiration for a
modified earlier timer, which may be earlier than timer0When because we
haven't yet updated the heap. Note "may", as the modified earlier timer
that set timerModifiedEarliest may have since been modified later or
deleted.

We can clear timerModifiedEarliest when the last timer is deleted
because by definition there must not be any modified earlier timers.

Why does this matter? checkTimersNoP claims that there is work to do if
timerModifiedEarliest has passed, causing findRunnable to loop back
around to checkTimers. But the code to clean up timerModifiedEarliest in
checkTimers (i.e., the call to adjusttimers) is conditional behind a
check that len(pp.timers) > 0.

Without clearing timerModifiedEarliest, a spinning M that would
otherwise go to sleep will busy loop in findRunnable until some other
work is available.

Note that changing the condition on the call to adjusttimers would also
be a valid fix. I took this approach because it feels a bit cleaner to
clean up timerModifiedEarliest as soon as it is known to be irrelevant.

Fixes #51654.

Change-Id: I3f3787c67781cac7ce87939c5706cef8db927dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/417434
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-13 18:35:00 +00:00
Wayne Zuo 923740a8cc cmd/compile: fix type assert in dict pass
For type assertions, if src type is empty interface, we should
use normal type assertions rather than dynamic type assertions.

Fixes #53762

Change-Id: I596b2e4ad647fe5e42ad884f7273c78f8f50dac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/416736
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-07-13 16:06:45 +00:00
Bryan C. Mills bf2ef26be3 cmd/go: in script tests, avoid checking non-main packages for staleness
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.
Lacking a proper install location, 'go install' becomes a no-op
for non-main packages in module mode.

This change switches the 'go install' commands in the test_fuzz_cache
and build_overlay tests to instead use 'go build', using the '-x' flag
to check for compile commands instead of querying 'go list' about
staleness.

For #37015.

Change-Id: I56d80cf2a43efb6163c62082c86cd3e4f0ff73c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/417095
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-07-12 21:54:06 +00:00
Bryan C. Mills 5f5cae7200 cmd/go: avoid indexing GOROOT packages when the compiler is 'gccgo'
The gccgo compiler does not load standard-library packages from
GOROOT/src, so we cannot load those packages from the GOROOT/src
index when using that compiler.

This fixes TestScript/gccgo_link_c (and perhaps other gccgo tests)
when a 'gccgo' executable is present. Unfortunately, only a few
builders caught the broken test because 'gccgo' is not installed
on most Go project builders (see #35786).

For #53577.
Fixes #53815.

Change-Id: I11a5cf6dbf4ac9893c4d02bd6ab7ef60f67b1e87
Reviewed-on: https://go-review.googlesource.com/c/go/+/417094
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-07-12 21:54:02 +00:00
Bryan C. Mills c2edb2c841 cmd/go: port TestIssue16471 to a script test and add verbose logging
For #50471

Change-Id: I082c1f96113a3228f2ef423a04eaa9fbaa6c7522
Reviewed-on: https://go-review.googlesource.com/c/go/+/376359
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 21:37:38 +00:00
Bryan C. Mills 9c2526e637 cmd/go/internal/modfetch/codehost: add missing newline in '# lock' log message
Change-Id: Ib92e983b6cdeed2b275a028c85b2bba583def059
Reviewed-on: https://go-review.googlesource.com/c/go/+/403850
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2022-07-12 21:31:27 +00:00
Bryan C. Mills 85486bcccb image/jpeg: increase TestLargeImageWithShortData timeout by an order of magnitude
Also dump goroutines on failure.

The original bug report in #10413 reported a hang of “several
minutes”. An apparently-spurious failure was observed in
https://build.golang.org/log/e5ac3ce3fb7d04ec13e5bbfadea8bb5869a4dd1e,
with a delay of only 3.64s.

Moreover, if the test does fail due to a regression, we will want a
goroutine dump to diagnose where it got stuck. The current call to
t.Fatalf does not produce such a dump, so is not nearly as useful if
the failure only occasionally reproduces.

Updates #10413.

Change-Id: I6ab9d112f14f438a0c54e02ec95934627acdc64b
Reviewed-on: https://go-review.googlesource.com/c/go/+/408355
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 21:23:11 +00:00
Jay Conrod 27794c4d4a cmd/go/internal/modload: ignore disallowed errors when checking for updates
addUpdate calls Query with the query "upgrade". Normally, this returns
the highest release version (or prerelease, etc.) that is higher than
the current version and is not retracted or excluded. If there is no
such version, Query should return the current version. If the current
version is retracted or excluded, then Query currently returns an error.

addUpdate should ignore this error, as it ignores ErrNotExist and
NoMatchingVersionError. For 'go list -m -u', addRetraction is also
called, and that will detect the retraction.

Fixes #53594

Change-Id: I90a2872cdeabf03894acad9e0cbdd7db4a4e269e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414825
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-07-12 20:57:09 +00:00
Matthew Dempsky 9371a65584 internal/pkgbits: change EnableSync into a dynamic knob
Rather than requiring users to recompile the compiler and all tools to
enable/disable sync markers, this CL adds a flag word into the Unified
IR file format to allow indicating whether they're enabled or not.
This in turn requires bumping the file format version.

Thanks to drchase@ for benchmarks showing this isn't as expensive as I
feared it would be.

Change-Id: I99afa0ee0b6ef5f30ed8ca840805ff9fd46b1857
Reviewed-on: https://go-review.googlesource.com/c/go/+/417097
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 19:30:30 +00:00
Tatiana Bradley b2b8872c87 compress/gzip: fix stack exhaustion bug in Reader.Read
Replace recursion with iteration in Reader.Read to avoid stack
exhaustion when there are a large number of files.

Fixes CVE-2022-30631
Fixes #53168

Change-Id: I47d8afe3f2d40b0213ab61431df9b221794dbfe0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1455673
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417067
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 15:06:07 +00:00
Julie Qiu ac68c6c683 path/filepath: fix stack exhaustion in Glob
A limit is added to the number of path separators allowed by an input to
Glob, to prevent stack exhaustion issues.

Thanks to Juho Nurminen of Mattermost who reported the issue.

Fixes CVE-2022-30632
Fixes #53416

Change-Id: I1b9fd4faa85411a05dbc91dceae1c0c8eb021f07
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1498176
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417066
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2022-07-12 15:06:01 +00:00
Julie Qiu fa2d41d0ca io/fs: fix stack exhaustion in Glob
A limit is added to the number of path separators allowed by an input to
Glob, to prevent stack exhaustion issues.

Thanks to Juho Nurminen of Mattermost who reported a similar issue in
path/filepath.

Fixes CVE-2022-30630
Fixes golang/go#53415

Change-Id: I5a9d02591fed90cd3d52627f5945f1301e53465d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1497588
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417065
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-07-12 15:05:55 +00:00
Roland Shoemaker 6fa37e98ea encoding/gob: add a depth limit for ignored fields
Enforce a nesting limit of 10,000 for ignored fields during decoding
of messages. This prevents the possibility of triggering stack
exhaustion.

Fixes #53615
Fixes CVE-2022-30635

Change-Id: I05103d06dd5ca3945fcba3c1f5d3b5a645e8fb0f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1484771
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417064
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2022-07-12 15:05:49 +00:00
Roland Shoemaker 695be961d5 go/parser: limit recursion depth
Limit nested parsing to 100,000, which prevents stack exhaustion when
parsing deeply nested statements, types, and expressions. Also limit
the scope depth to 1,000 during object resolution.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #53616
Fixes CVE-2022-1962

Change-Id: I4d7b86c1d75d0bf3c7af1fdea91582aa74272c64
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1491025
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417063
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 15:05:44 +00:00
Roland Shoemaker 08c46ed43d encoding/xml: use iterative Skip, rather than recursive
Prevents exhausting the stack limit in _incredibly_ deeply nested
structures.

Fixes #53614
Fixes CVE-2022-28131

Change-Id: I47db4595ce10cecc29fbd06afce7b299868599e6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1419912
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417062
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 15:05:39 +00:00
Roland Shoemaker c4c1993fd2 encoding/xml: limit depth of nesting in unmarshal
Prevent exhausting the stack limit when unmarshalling extremely deeply
nested structures into nested types.

Fixes #53611
Fixes CVE-2022-30633

Change-Id: Ic6c5d41674c93cfc9a316135a408db9156d39c59
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1421319
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/417061
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 15:05:33 +00:00
Russ Cox 913d05133c cmd/go: avoid spurious readdir during fsys.Walk
fsys.Walk is cloned from filepath.Walk, which has always handled
a walk of a directory by reading the full directory before calling the
callback on the directory itself. So if the callback returns fs.SkipDir,
those entries are thrown away, but the expense of reading them was
still incurred. (Worse, this is the expensive directory read that also
calls Stat on every entry.) On machines with slow file system I/O,
these reads are particularly annoying. For example, if I do

	go list m...

there is a call to filepath.Walk that is told about $GOROOT/src/archive
and responds by returning filepath.SkipDir because archive does not
start with m, but it only gets the chance to do that after the archive
directory has been read. (Same for all the other top-level directories.)
Even something like go list github.com/foo/bar/... reads every top-level
$GOPATH/src directory.

When we designed filepath.WalkDir, one of the changes we made was
to allow calling the callback twice for a directory: once before reading it,
and then possibly again if the read produces an error (uncommon).
This CL changes fsys.Walk to use that same model. None of the callbacks
need changing, but now the $GOROOT/src/archive and other top-level
directories won't be read when evaluating a pattern like 'm...'.

For #53577.
Fixes #53765.

Change-Id: Idfa3b9e2cc335417bfd9d66dd584cb16f92bd12e
Reviewed-on: https://go-review.googlesource.com/c/go/+/416179
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 09:11:26 +00:00
Damien Neil d3d7998756 net/http: clarify that MaxBytesReader returns *MaxBytesError
A MaxBytesReader returns a *MaxBytesError when reading beyond
its limit, not a MaxBytesError.

Fixes #53764.

Change-Id: Icac3aeac96fd8b172f951241f8f111cda633752c
Reviewed-on: https://go-review.googlesource.com/c/go/+/416914
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-12 04:04:17 +00:00
Tobias Klauser 126c22a098 syscall: gofmt after CL 412114
Change-Id: Ie51545eaebd22a31379bf8814a2c62b91d1d105b
Reviewed-on: https://go-review.googlesource.com/c/go/+/416934
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-11 21:46:19 +00:00
Michael Pratt 123a6328b7 internal/trace: don't report regions on system goroutines
If a goroutine is started within a user region, internal/trace assigns
the child goroutine a nameless region for its entire lifetime which is
assosciated the same task as the parent's region.

This is not strictly necessary: a child goroutine is not necessarily
related to the task unless it performs some task operation (in which
case it will be associated with the task through the standard means).

However, it can be quite handy to see child goroutines within a region,
which may be child worker goroutines that you simply didn't perform task
operations on.

If the first GC occurs during a region, the GC worker goroutines will
also inherit a child region. We know for sure that these aren't related
to the task, so filter them out from the region list.

Note that we can't exclude system goroutines from setting activeRegions
in EvGoCreate handling, because we don't know the goroutine start
function name until the first EvGoStart.

Fixes #53784.

Change-Id: Ic83d84e23858a8400a76d1ae2f1418ef49951178
Reviewed-on: https://go-review.googlesource.com/c/go/+/416858
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-07-11 21:24:38 +00:00
Than McIntosh 846490110a runtime/race: update amd64 syso images to avoid sse4
Rebuild selected amd64 syso images with updated LLVM build rules that
avoid the use of SSE4, so as to ensure that the Go race detector
continues to work on older x86 cpus. No changes to the syso files for
openbsd/amd64 (upstream support has been removed in LLVM) or
netbsd/amd64 (work still in progress there).

Fixes #53743.

Change-Id: I738ae4d1e0528c6e06dd4ddb78e7039a30a51779
Reviewed-on: https://go-review.googlesource.com/c/go/+/416857
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
2022-07-11 20:39:53 +00:00
Tobias Klauser b75ad09cae cmd/trace: fix typo in web documentation
Change-Id: I950224c3f698fbdf2bcab6f847f4afddaa6e9c2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/416974
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-07-11 19:54:22 +00:00
Russ Cox 7510e597de cmd/go: make module index loading O(1)
For a large module, opening the index was populating tables with
entries for every package in the module. If we are only using a small
number of those packages, this is wasted work that can dwarf the
benefit from the index.

This CL changes the index reader to avoid loading all packages
at module index open time. It also refactors the code somewhat
for clarity.

It also removes some duplication by defining that a per-package
index is a per-module index containing a single package, rather
than having two different formats and two different decoders.

It also changes the string table to use uvarint-prefixed data
instead of having to scan for a NUL byte. This makes random access
to long strings more efficient - O(1) instead of O(n) - and can significantly
speed up the strings.Compare operation in the binary search looking
for a given package.

Also add a direct test of the indexing code.

For #53577.

Change-Id: I7428d28133e4e7fe2d2993fa014896cd15af48af
Reviewed-on: https://go-review.googlesource.com/c/go/+/416178
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-07-11 19:09:00 +00:00
Bryan C. Mills b8bf820d5d cmd/nm: don't rely on an erroneous install target in tests
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.
This change switches the 'go install' command in testGoLib to instead
use 'go build -buildmode=archive' with an explicit output file.

For #37015.

Change-Id: I15781aa33d1b2adc6a4437a58622276f4e20b889
Reviewed-on: https://go-review.googlesource.com/c/go/+/416955
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-07-11 19:01:02 +00:00
Bryan C. Mills ad641e8521 misc/cgo/testcarchive: don't rely on an erroneous install target in tests
Non-main packages in module mode should not be installed to
GOPATH/pkg, but due to #37015 they were installed there anyway.

This change switches the 'go install' command in TestPIE to instead
use 'go build', and switches TestInstall and TestCachedInstall
(which appear to be explicitly testing 'go install') to explicitly
request GOPATH mode (which does have a well-defined install target).

For #37015.

Change-Id: Ifb24657d2781d1e35cf40078e8e3ebf56aab9cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/416954
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-11 18:57:03 +00:00
Sean Liao bf5898ef53 net/url: use EscapedPath for url.JoinPath
Fixes #53763

Change-Id: I08b53f159ebdce7907e8cc17316fd0c982363239
Reviewed-on: https://go-review.googlesource.com/c/go/+/416774
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-07-11 18:09:14 +00:00
Dmitri Goutnik 398dcd1cf0 database/sql: make TestTxContextWaitNoDiscard test more robust
Similar to CL 385934, rely on waiter trigger instead of the WAIT query
prefix and factor out the common test code.

Fixes #53222

Change-Id: I46efc85ca102b350bb4dbe8e514921e016870ffb
Reviewed-on: https://go-review.googlesource.com/c/go/+/416655
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-07-11 17:14:33 +00:00
Russ Cox f956941b0f cmd/go: use package index for std in load.loadPackageData
load.loadPackageData was only using an index for modules,
not for standard library packages. Other parts of the code were
using the index, so there was some benefit, but not as much
as you'd hope.

With the index disabled, the Script/work test takes 2.2s on my Mac.
With the index enabled before this CL, it took 2.0s.
With the index enabled after this CL, it takes 1.6s.

Before this CL, the Script/work test issued:

	 429 IsDir
	  19 IsDirWithGoFiles
	   7 Lstat
	9072 Open
	 993 ReadDir
	 256 Stat
	   7 Walk
	   3 indexModule
	  24 openIndexModule
	 525 openIndexPackage

After this CL, it issued:

	  19 IsDirWithGoFiles
	   7 Lstat
	  60 Open
	 606 ReadDir
	 256 Stat
	   7 Walk
	   3 indexModule
	  24 openIndexModule
	 525 openIndexPackage

This speedup helps the Dragonfly builder, which has very slow
file I/O and is timing out since a recent indexing change.

Times for go test -run=Script/^work$ on the Dragonfly builder:

	50s before indexing changes
	31s full module indexing of std
	46s per-package indexing of std

It cuts the time for go test -run=Script/^work$ from 44s to 20s.

For #53577.

Change-Id: I7189a77fc7fdf61de3ab3447efc4e84d1fc52c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/416134
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-07-11 16:51:38 +00:00
Mitar 59ab6f351a net/http: remove Content-Encoding in writeNotModified
Additional header to remove if set before calling http.ServeContent.

The API of ServeContent is that one should set Content-Encoding before calling it, if the content is encoded (e.g., compressed). But then, if content has not been modified, that header should be removed, according to RFC 7232 section 4.1.

Change-Id: If51b35b7811a4dbb19de2ddb73f40c5e68fcec7e
GitHub-Last-Rev: 53df6e73c4
GitHub-Pull-Request: golang/go#50903
Reviewed-on: https://go-review.googlesource.com/c/go/+/381955
Run-TryBot: hopehook <hopehook@qq.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-07-11 08:23:57 +00:00
Keith Randall c1a4e0fe01 cmd/compile: fix libfuzzer instrumentation line number
Set a reasonable starting line number before processing the body of
the function in the order pass.

We update base.Pos each time we process a node, but some of the
libfuzzer instrumentation is added before we process any node, so the
base.Pos used is junk.

Fixes #53688

Change-Id: I3654b805eabb8866a9a1574845ef4ff062797319
Reviewed-on: https://go-review.googlesource.com/c/go/+/416654
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-08 23:41:37 +00:00
Bryan C. Mills 5c1a13e7a4 cmd/go: avoid setting variables for '/' and ':' in TestScript subprocess environments
Also simplify platform-dependent handling of the PATH variable,
to make it more like the existing platform-dependent handling for
HOME and TMPDIR.

Fixes #53671.

Change-Id: Ica2665d3f61988c66fb6982b9feb61ca48eced79
Reviewed-on: https://go-review.googlesource.com/c/go/+/416554
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-08 18:51:33 +00:00
Damien Neil 180bcad33d net/http: wait for listeners to exit in Server.Close and Shutdown
Avoid race conditions when a new connection is accepted just after
Server.Close or Server.Shutdown is called by waiting for the
listener goroutines to exit before proceeding to clean up active
connections.

No test because the mechanism required to trigger the race condition
reliably requires such tight coupling to the Server internals that
any test would be quite fragile in the face of reasonable refactorings.

Fixes #48642
Updates #33313, #36819

Change-Id: I109a93362680991bf298e0a95637595dcaa884af
Reviewed-on: https://go-review.googlesource.com/c/go/+/409537
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-07-08 17:00:50 +00:00
Cuong Manh Le 14abe8aa73 cmd/compile: don't convert to interface{} for un-comparable types in generic switch
Fixes #53635

Change-Id: I41f383be8870432fc0d29fa83687911ddd8217f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/415634
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-07-08 12:57:49 +00:00
Michael Anthony Knyszek 1ebc983000 runtime: overestimate the amount of allocated memory in heapLive
CL 377516 made it so that memory metrics are truly monotonic, but also
updated how heapLive tracked allocated memory to also be monotonic.

The result is that cached spans with allocated memory aren't fully
accounted for by the GC, causing it to make a worse assumption (the
exact mechanism is at this time unknown), resulting in a memory
regression, especially for smaller heaps.

This change is a partial revert of CL 377516 that makes heapLive a
non-monotonic overestimate again, which appears to resolve the
regression.

For #53738.

Change-Id: I5c51067abc0b8e0a6b89dd8dbd4a0be2e8c0c1b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/416417
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-07 21:15:48 +00:00
Roland Shoemaker c177d9d98a crypto/x509: restrict CRL number to <=20 octets
Similar to certificate serial numbers, RFC 5280 restricts the length of
the CRL number field to no more than 20 octets. Enforce this in
CreateRevocationList.

Fixes #53543

Change-Id: If392ef6b0844db716ae9ee6ef317135fceab039c
Reviewed-on: https://go-review.googlesource.com/c/go/+/415134
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
2022-07-07 19:43:03 +00:00
Aaron Gable 486fc01770 crypto/x509: correctly parse CRL entry extensions
When checking to see if a CRL entry has any extensions, attempt to read
them from the individual revokedCertificate, rather than from the parent
TBSCertList.

Additionally, crlEntryExtensions is not an EXPLICIT field (c.f.
crlExtension and Certificate extensions), so do not perform an extra
layer of unwrapping when parsing the field.

The added test case fails without the accompanying changes.

Fixes #53592

Change-Id: Icc00e4c911f196aef77e3248117de64ddc5ea27f
Reviewed-on: https://go-review.googlesource.com/c/go/+/414877
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-07-07 19:26:16 +00:00
Aaron Gable 8ac58de185 crypto/x509: populate Number and AKI of parsed CRLs
The x509.RevocationList type has two fields which correspond to
extensions, rather than native fields, of the underlying ASN.1 CRL:
the .Number field corresponds to the crlNumber extension, and
the .AuthorityKeyId field corresponds to the authorityKeyIdentifier
extension.

The x509.CreateRevocationList() function uses these fields to populate
their respective extensions in the resulting CRL. However, the
x509.ParseRevocationList() function does not perform the reverse
operation: the fields retain their zero-values even after parsing a CRL
which contains the relevant extensions.

Add code which populates these fields when parsing their extensions.
Add assertions to the existing tests to confirm that the values are
populated appropriately.

Fixes #53726

Change-Id: Ie5b71081e53034e0b5b9ff3c122065c62f15cf23
Reviewed-on: https://go-review.googlesource.com/c/go/+/416354
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2022-07-07 19:06:45 +00:00
Than McIntosh 0c7fcf6bd1 cmd/link: explicitly disable PIE for windows/amd64 -race mode
Turn off PIE explicitly for windows/amd64 when -race is in effect,
since at the moment the race detector runtime doesn't seem to handle
PIE binaries correctly. Note that newer C compilers on windows
produce PIE binaries by default, so the Go linker needs to explicitly
turn off PIE when invoking the external linker in this case.

Updates #53539.

Change-Id: Ib990621f22cf61a5fa383584bab81d3dfd7552e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/415676
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2022-07-07 14:33:55 +00:00
Than McIntosh eaf2125654 cmd/go: default to "exe" build mode for windows -race
This patch changes the default build mode from "pie" to "exe" when
building programs on windows with "-race" in effect. The Go command
already issues an error if users explicitly ask for -buildmode=pie in
combination with -race on windows, but wasn't revising the default
"pie" build mode if a specific buildmode was not requested.

Updates #53539.
Updates #35006.

Change-Id: I2f81a41a1d15a0b4f5ae943146175c5a1202cbe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/416174
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
2022-07-07 14:33:31 +00:00
Cuong Manh Le 1243ec9c17 cmd/compile: only check implicit dots for method call enabled by a type bound
Fixes #53419

Change-Id: Ibad64f5c4af2112deeb0a9ecc9c589b17594bd05
Reviewed-on: https://go-review.googlesource.com/c/go/+/414836
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-07-06 20:29:10 +00:00
Daniel Martí c391156f96 cmd/go: set up git identity for build_buildvcs_auto.txt
Just like in other tests like get_dotfiles.txt or
version_buildvcs_git.txt. Without it, I get a failure on my machine:

	fatal: empty ident name (for <mvdan@p14s.localdomain>) not allowed

Change-Id: I1c17c0d58c539b59154570b5438c7bd850bac5aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/416095
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-07-06 17:17:08 +00:00
Keith Randall 2acd3646fc cmd/compile: rework induction variable detector
Induction variable detection is still not quite right. I've added
another failing test.

Redo the overflow/underflow detector so it is more obviously correct.

Update #53600
Fixes #53653
Fixes #53663

Change-Id: Id95228e282fdbf6bd80b26e1c41d62e935ba08ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/415874
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-07-06 17:00:37 +00:00
Ian Lance Taylor 53a4152d47 os/exec: clarify that Wait must be called
Fixes #52580

Change-Id: Ib2dd8a793b9c6fcb083abb3f7c346f6279adefc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/414056
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-07-06 16:51:00 +00:00
Ian Lance Taylor 177306f630 cmd/internal/notsha256: add purego tag as needed
This permits building the package with gccgo, when using gccgo
as a bootstrap compiler.

Fixes #53662

Change-Id: Ic7ae9323ec5954e9306a32e1160e9aa1ed3aa202
Reviewed-on: https://go-review.googlesource.com/c/go/+/415935
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-07-06 16:39:07 +00:00
Ian Lance Taylor f4755fc733 cmd/dist: use purego tag when building the bootstrap binaries
This is in addition to the current math_big_pure_go tag.
Using purego ensures that we can build the cmd binaries with gccgo.

For #53662

Change-Id: Ib82f8bf10659b5f94935f2b427ae8b2da875cd3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/415934
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-07-06 16:22:03 +00:00
Cherry Mui 4484c30f78 misc/cgo/test: make TestSetgidStress cheaper
TestSetgidStress spawns 1000 threads, which can be expensive on
some platforms or slow builders. Run with 50 threads in short
mode instead.

This makes the failure less reproducible even with buggy code. But
one can manually stress test it (e.g. when a flaky failure appear
on the builder).

Fixes #53641.

Change-Id: I33b5ea5ecaa8c7a56f59c16f9171657ee295db47
Reviewed-on: https://go-review.googlesource.com/c/go/+/415677
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-07-06 14:23:50 +00:00
Ian Lance Taylor 2007599dc8 test: recognize new gofrontend error message
The new gofrontend message matches other gofrontend error messages,
so adjust the test to accept it.

For #27938
For #51237

Change-Id: I29b536f83a0cf22b1dbdae9abc2f5f6cf21d522d
Reviewed-on: https://go-review.googlesource.com/c/go/+/416014
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-07-06 00:02:11 +00:00