1
0
mirror of https://github.com/golang/go synced 2024-11-25 08:27:57 -07:00
Commit Graph

59847 Commits

Author SHA1 Message Date
Damien Neil
f82a3616a9 all: update golang.org/x/net
Commands run (in both src and src/cmd):
	go get golang.org/x/net@master
	go mod tidy
	go mod vendor

For #24135

Change-Id: I88084d174c15a65350be1b43e27de619dc6d4dd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/570156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: 胡玮文 <huww98@outlook.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-09 00:09:40 +00:00
Russ Cox
61d6817c83 cmd/compile: compile cap(ch) as call to runtime.chancap
An upcoming CL will give this call more to do.
For now, separate out the compiler change that
stops inlining the computation.

For #37196.

Change-Id: I965426d446964b9b4958e4613246002a7660e7eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/568375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 22:35:22 +00:00
Russ Cox
24fa7544b0 runtime: fix spurious race using Ticker.Reset
Ticker.Reset was added in CL 217362 in 2020.
It added the runtime helper modTimer, which is
analogous to startTimer and resetTimer but for tickers.
Unlike those, it does not contain a racerelease, which
means that code synchronizing by starting a ticker
will be diagnosed with a spurious race.

Add racerelease to modTimer and add tests of all
three racereleases (in startTimer, resetTimer, and modTimer).

Also do not call time.resetTimer from elsewhere in runtime,
since that function is only for package time. Use t.reset instead.

For #33184.

Change-Id: Ie40c1ad24911f21e81b1d3cc608cf086ff2bc83d
Reviewed-on: https://go-review.googlesource.com/c/go/+/568340
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-03-08 22:34:15 +00:00
Russ Cox
a21b275a5b runtime: gofmt
CL 565515 introduced these non-gofmt'ed lines. Gofmt them.

Change-Id: Id64244c204b2d6a0bd6377caa17869284eb34f45
Reviewed-on: https://go-review.googlesource.com/c/go/+/570216
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-08 22:21:27 +00:00
Russ Cox
854dea060e runtime: remove sched, allp < timers lockrank rule
allp < timers has not been necessary since CL 258303.

sched < timers was implied by allp < timers, and that
was still necessary, but only when the world is stopped.
Rewrite the code to avoid that lock since the world is stopped.

Now timers and timer are independent of the scheduler,
so they could call into the scheduler (for example to ready
a goroutine) if we wanted them to.

Change-Id: I12a93013c98e51c9e2f2148175b02afce8384a59
Reviewed-on: https://go-review.googlesource.com/c/go/+/568337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 22:17:02 +00:00
Russ Cox
7381123235 runtime: re-add call to ts.cleanHead (née cleantimers) during timer add
Before CL 564118, there were two ways to add a new timer:
addtimer or modtimer. Much code was duplicated between them
and it was always valid to call modtimer instead of addtimer
(but not vice versa), so that CL changed all addtimer call sites
to use modtimer and deleted addtimer.

One thing that was unique to addtimer, however, was that it
called cleantimers (now named ts.cleanHead) after locking the
timers, while modtimer did not. This was the only difference
in the duplicated code, and I missed it. Restore the call to
ts.cleanHead when adding a new timer.

Also fix double-unlock in cleanHead.

Change-Id: I26cc50d650f31f977c0c31195cd013244883dba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/568338
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-03-08 22:14:47 +00:00
Russ Cox
3c39b2ed11 runtime: avoid pp.timers.lock in updateTimerPMask
The comment in updateTimerPMask is wrong. It says:

	// Looks like there are no timers, however another P
	// may be adding one at this very moment.
	// Take the lock to synchronize.

This was my incorrect simplification of the original comment
from CL 264477 when I was renaming all the things it mentioned:

	// Looks like there are no timers, however another P may transiently
	// decrement numTimers when handling a timerModified timer in
	// checkTimers. We must take timersLock to serialize with these changes.

updateTimerPMask is being called by pidleput, so the P in question
is not in use. And other P's cannot add to this P.
As the original comment more precisely noted, the problem was
that other P's might be calling timers.check, which updates ts.len
occasionally while ts is locked, and one of those updates might
"leak" an ephemeral len==0 even when the heap is not going to
be empty when the P is finally unlocked. The lock/unlock in
updateTimerPMask synchronizes to avoid that. But this defeats
most of the purpose of using ts.len in the first place.

Instead of requiring that synchronization, we can arrange that
ts.len only ever shows a "publishable" length, meaning the len(ts.heap)
we leave behind during ts.unlock.

Having done that, updateTimerPMask can be inlined into pidleput.

The big comment on updateTimerPMask explaining how timerpMask
works is better placed as the doc comment for timerpMask itself,
so move it there.

Change-Id: I5442c9bb7f1473b5fd37c43165429d087012e73f
Reviewed-on: https://go-review.googlesource.com/c/go/+/568336
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 22:14:44 +00:00
Russ Cox
c961ab3fe9 runtime: introduce timers.lock, timers.unlock methods
No semantic changes here.
Cleaning up for next change.

Change-Id: I9706009739677ff9eb893bcc007d805f7877511e
Reviewed-on: https://go-review.googlesource.com/c/go/+/568335
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 22:14:41 +00:00
qmuntal
c220fbabd5 internal/syscall/windows: unexport Version
windows.Version is just a thin wrapper around RtlGetNtVersionNumbers,
which is an undocumented Windows API.

This CL unexports windows.Version so it is harder to use by accident.

Change-Id: Ib782da04e4e8be66970111a75f5c2df27ef51643
Reviewed-on: https://go-review.googlesource.com/c/go/+/570055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-08 22:14:32 +00:00
Russ Cox
336617186a time: make sure tests avoid the special-case channel code
Many of the tests in package time are about proper manipulation
of the timer heap. But now NewTimer bypasses the timer heap
except when something is blocked on the associated channel.
Make the tests test the heap again by using AfterFunc instead of
NewTimer.

In particular, adds a non-chan version of TestZeroTimer, which
was flaky-broken and then fixed by CLs in the cleanup stack.
This new tests makes sure we notice if it breaks again.

Fixes #66006.

Change-Id: Ib59fc1b8b85ef5a21e72fe418c627c9b8b8a083a
Reviewed-on: https://go-review.googlesource.com/c/go/+/568255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2024-03-08 22:13:33 +00:00
Russ Cox
40cc3eb278 runtime: fix mishandling of timer zombie count
The timer zombie count was fundamentally racy and worked around
in CL 569995. We worked around that by ignoring underflow.
The fundamnental race was because t.ts was set before t was
inserted into ts. CL 564997 corrected that fundamental problem,
so now we can account for zombies completely accurately,
never seeing values less than zero. Do that.

Change-Id: Idfbccc6662af5935f29f2a06a35e8ea93929bed7
Reviewed-on: https://go-review.googlesource.com/c/go/+/569996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 21:09:45 +00:00
Russ Cox
85bbb12141 runtime: fix timers.wakeTime inaccuracy race
timers.wakeTime, which is called concurrently by P's trying to decide
how long they should sleep, can return inaccurate values while
timers.adjust is running. (Before the refactoring, this was still true
but the code did not have good names and was spread across more
files, making the race harder to see.)

The runtime thread sleeping code is complex enough that I am not
confident that the inaccuracy can cause delayed timer wakeups,
but I am also not confident that it can't, nor that it won't in the future.

There are two parts to the fix:

1. A simple logic change in timers.adjust.

2. The introduction of t.maybeAdd to avoid having a t that is
marked as belonging to a specific timers ts but not present
in ts.heap. That was okay before when everything was racy
but needs to be eliminated to make timers.adjust fully consistent.
The cost of the change is an extra CAS-lock operation on a timer add
(close to free since the CAS-lock was just unlocked) and a change
in the static lock ranking to allow malloc while holding a timer lock.

Change-Id: I1249e6e24ae9ef74a69837f453e15b513f0d75c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/564977
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 21:09:41 +00:00
Russ Cox
3ad5cd4741 runtime: update timers.len with Store instead of Add
Writes to timers.len are protected by the timers.lock.
There is no need to use an Add instead of a Store,
and the code is clearer (and perhaps slightly faster)
using the Store.

Change-Id: Icc6caef1b7405adec55c9b55b999b71de7d97484
Reviewed-on: https://go-review.googlesource.com/c/go/+/564976
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 21:09:39 +00:00
Russ Cox
2171e628b8 runtime: rename timers fields for clarity
These names were copied over from the p field names,
but now that they are part of the timers type they can use
shorter names that make the relationship clearer.

timer0When -> minWhen
timerModifiedEarliest -> minNextWhen

This code change is only the renaming.

Change-Id: I1c0adc0b3a1289d35639619d5c945585b2d81a9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/564975
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
2024-03-08 21:09:35 +00:00
Michael Anthony Knyszek
707eba9b94 runtime: fix EvFrequency event value on Windows in the new tracer
The value produced for the EvFrequency event on Windows is missing the
fact that the cputicks clock gets divided. This results in durations
that are consistently wrong by the same factor (about 256).

Fixes #65997.

Change-Id: I930cbfce3499d435c20699f41c11e3227d84f911
Reviewed-on: https://go-review.googlesource.com/c/go/+/567937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-03-08 19:59:54 +00:00
Michael Anthony Knyszek
ccfcc30f3e runtime: clean up dead P trace state when disabling tracing too
Right now, we're careful to clean up dead P state when we advance to
future trace generations. If we don't, then if that P comes back to
life, we might end up using its old stale trace state.

Unfortunately, we never handled this in the case when tracing stops,
only when advancing to new generations. As a result, stopping a trace,
starting it again, and then bringing a P back to life in the following
generation meant that the dead P could be using stale state.

Fixes #65318.

Change-Id: I9297d9e58a254f2be933b8007a6ef7c5ec3ef4f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/567077
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-03-08 19:58:37 +00:00
Michael Anthony Knyszek
7348773640 internal/trace/v2: clean up the ordering interface
This change cleans up the ordering interface in several ways.

First, it resolves a TODO about using a proper queue of events for extra
events produced while performing ordering. This will be necessary for a
follow-up change to handle coroutine switch events.

Next, it simplifies the ordering.advance method's signature by not
returning a schedCtx. Instead, ordering.advance will take responsibility
for constructing the final Event instead of the caller, and places it on
its own internal queue (in addition to any other Events generated). The
caller is then responsible for taking events off of the queue with a new
method Next.

Finally, hand-in-hand with the signature change, the implementation of
ordering.advance no longer forces each switch case to return but instead
has them converge past the switch. This has two effects. One is that we
eliminate the deferred call to update the M state. Using a defer here is
technically incorrect, because we might end up changing the M state even
if we don't advance the event! We got lucky here that curCtx == newCtx
in all such cases, but there may have been a subtle bug lurking here.

Unfortunately because of the queue's semantics however, we can't
actually avoid pushing into the queue at every possible successful exit
out of the switch. Hopefully this can become less error-prone in the
future by splitting up the switch into a dispatch of different
functions, instead of everything living in one giant function. This
cleanup will happen in a follow-up change.

Change-Id: Ifebbbf14e8ed5c08be5c1b0fadc2e5df3915c656
Reviewed-on: https://go-review.googlesource.com/c/go/+/565936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-03-08 19:58:33 +00:00
Michael Anthony Knyszek
52b5f164ae runtime: make checking if tracing is enabled non-atomic
Tracing is currently broken when using iter.Pull from the rangefunc
experiment partly because the "tracing is off" fast path in traceAcquire
was deemed too expensive to check (an atomic load) during the coroutine
switch.

This change adds trace.enabled, a non-atomic indicator of whether
tracing is enabled. It doubles trace.gen, which is the source of truth
on whether tracing is enabled. The semantics around trace.enabled are
subtle.

When tracing is enabled, we need to be careful to make sure that if gen
!= 0, goroutines enter the tracer on traceAcquire. This is enforced by
making sure trace.enabled is published atomically with trace.gen. The
STW takes care of synchronization with most Ms, but there's still sysmon
and goroutines exiting syscalls. We need to synchronize with those
explicitly anyway, which luckily takes care of trace.enabled as well.

When tracing is disabled, it's always OK for trace.enabled to be stale,
since traceAcquire will always double-check gen before proceeding.

For #61897.

Change-Id: I47c2a530fb5339c15e419312fbb1e22d782cd453
Reviewed-on: https://go-review.googlesource.com/c/go/+/565935
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-03-08 19:58:29 +00:00
Russ Cox
e38be310a4 time: gracefully handle ts.zombies underflow
The current implementation sets t.ts before adding t to ts;
that can cause inconsistencies with temporarily negative
ts.zombies values. Handle them gracefully, since we only
care about detecting very positive values.

Pending CL 564977 removes the race that sets t.ts early,
and then CL 569996 builds on top of that to make the count precise.
This CL just gets examples like the new test working sooner.

Change-Id: Ibe1aecc2554f83436f761f48e4050bd962982e4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/569995
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 19:41:32 +00:00
guoguangwu
e03e06d560 net/http: close res.Body
Change-Id: I0f9faf2a946ebebf9ae30f065f20ec6028c65c22
GitHub-Last-Rev: d957ce1020
GitHub-Pull-Request: golang/go#66181
Reviewed-on: https://go-review.googlesource.com/c/go/+/569976
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-08 19:01:29 +00:00
Russ Cox
32014d5496 Revert "encoding/xml: reject XML declaration after start of document"
This reverts commit 8a0fbd75a5.

Reason for revert: Breaking real-world tests inside Google,
which means it probably breaks real-world tests outside Google.

One instance I have seen is a <!-- --> comment (often a copyright notice) before the procinst.

Another test checks that a canonicalizer can handle a test input that simply has procinsts mid-XML.

XML is full of contradictions, XML implementations more so. If we are going to start being picky, that probably needs to be controlled by a GODEBUG (and a proposal).

For #65691 (will reopen manually).

Change-Id: Ib52d0944b1478e71744a2a35b271fdf7e1c972ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/570175
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-08 18:46:41 +00:00
Damien Neil
a46285f8c2 net/url: consider an empty base Path as equivalent to / in JoinPath
A Path that starts with / is absolute.
A Path that starts with any other character is relative.

The meaning of a Path of "" is not defined,
but RequestURI converts a "" Path to "/"
and an empty Path may represent a URL with just
a hostname and no trailing / such as "http://localhost".

Handle empty paths in the base URL of JoinPath consistently with
RequestURI, so that joining to an empty base produces an absolute
path rather than a relative one.

	u, _ := url.Parse("http://localhost")
	u = u.JoinPath("x")
	fmt.Println(u.Path) // "/x", not "x"

Fixes #58605

Change-Id: Iacced9c173b0aa693800dd01caf774f3f9a66d56
Reviewed-on: https://go-review.googlesource.com/c/go/+/469935
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 17:01:05 +00:00
apocelipes
c8c46e746b runtime: use built-in clear to simplify code
Change-Id: Icb6d9ca996b4119d8636d9f7f6a56e510d74d059
GitHub-Last-Rev: 08178e8ff7
GitHub-Pull-Request: golang/go#66188
Reviewed-on: https://go-review.googlesource.com/c/go/+/569979
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2024-03-08 16:28:44 +00:00
Jes Cok
69583738eb unicode/utf8: update doc for RuneLen
As CL 569755 did, for consistency, this CL slightly improves
the documentation for RuneLen.

Change-Id: Ic9776648baf2809af36cd16a94d1313938bb0e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/569816
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-03-08 02:00:36 +00:00
Cuong Manh Le
5a329c3bfb cmd/compile: fix copying SSA-able variables optimization
CL 541715 added an optimization to copy SSA-able variables.

When handling m[k] = append(m[k], ...) case, it uses ir.SameSafeExpr to
check that m[k] expressions are the same, then doing type assertion to
convert the map index to ir.IndexExpr node. However, this assertion is
not safe for m[k] expression in append(m[k], ...), since it may be
wrapped by ir.OCONVNOP node.

Fixing this by un-wrapping any ir.OCONVNOP before doing type assertion.

Fixes #66096

Change-Id: I9ff7165ab97bc7f88d0e9b7b31604da19a8ca206
Reviewed-on: https://go-review.googlesource.com/c/go/+/569716
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-08 02:00:33 +00:00
Alexander Yastrebov
8590f0aef3 net/http: remove persistConn reference from wantConn
Transport getConn creates wantConn w, tries to obtain idle connection for it
based on the w.key and, when there is no idle connection, puts wantConn into
idleConnWait wantConnQueue.

Then getConn dials connection for w in a goroutine and blocks.
After dial succeeds getConn unblocks and returns connection to the caller.

At this point w is stored in the idleConnWait and will not be evicted
until another wantConn with the same w.key is requested or alive
connection returned into the idle pool which may not happen e.g. if
server closes the connection.

The problem is that even after tryDeliver succeeds w references
persistConn wrapper that allocates bufio.Reader and bufio.Writer and
prevents them from being garbage collected.

To fix the problem this change removes persistConn and error references
from wantConn and delivers them via channel to getConn.

This way wantConn could be kept in wantConnQueues arbitrary long.

Fixes #43966
Fixes #50798

Change-Id: I77942552f7db04c225fb40d770b3101a8cfe655d
GitHub-Last-Rev: 027a0833f9
GitHub-Pull-Request: golang/go#62227
Reviewed-on: https://go-review.googlesource.com/c/go/+/522095
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-08 01:59:51 +00:00
apocelipes
b57a544f99 archive/tar: use built-in clear to simplify code
Change-Id: I0e55dd68d92c39aba511b55368bf50d929d75f86
GitHub-Last-Rev: 1743014078
GitHub-Pull-Request: golang/go#66158
Reviewed-on: https://go-review.googlesource.com/c/go/+/569696
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-08 01:59:14 +00:00
Tobias Klauser
80a91d34f4 os: use goarch.BigEndian
Change-Id: I83c23ae0933f6abe4c07144f69c3d9c18aece6e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/569175
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-08 01:59:11 +00:00
Tobias Klauser
1a800d1c88 syscall: use goarch.BigEndian
Change-Id: I99e5f6fab900b0bf301f78460c618c01b231f62b
Reviewed-on: https://go-review.googlesource.com/c/go/+/568956
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08 01:59:07 +00:00
Michael Pratt
c57b18b48f cmd/go: always include action mode in trace name
For actions with no package, the title "Executing action" is extremely
vague. Add the action mode so that there is some differentiation.

Change-Id: If6dcf81c7cd1f19a9532e56dd9f88abd1182ea97
Reviewed-on: https://go-review.googlesource.com/c/go/+/567936
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 21:49:37 +00:00
Cuong Manh Le
cb733da42c net/http: set Cache-Control header only if presents on error
CL 544019 changes http.Error to remove misleading response headers.
However, it also adds new "Cache-Control" header unconditionally, which
may breaks existing clients out there, who do not expect to see the
this header in the response like test in golang.org/x/net/http2.

To keep thing backward compatible, http.Error should only add
Cache-Control header if it has been presented.

Updates #50905

Change-Id: I989e9f999a30ec170df4fb28905f50aed0267dad
Reviewed-on: https://go-review.googlesource.com/c/go/+/569815
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-07 20:48:58 +00:00
cui fliter
8d3703ed77 all: remove redundant string conversions when formatting []byte with %s
Change-Id: I1285ee047fd465f48028186ae04d4de60cc9969e
Reviewed-on: https://go-review.googlesource.com/c/go/+/569715
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 20:46:32 +00:00
Alex Driuk
7101fd1e97 sort: fix typo in sort_test.go
Change-Id: Ibc1344b678d5f7c730b924c697717305c90c26e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/569537
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-07 19:41:04 +00:00
Mauri de Souza Meneguzzo
db44044f75 internal/poll: change Fsync to fallback to syscall.Fsync on darwin
In certain scenarios, such as network mounts, calling Fsync results in
ENOTSUP in OSX. This issue was introduced in CL 130676 since
syscall.FSync was not properly flushing contents to disk, and it was
replaced with fcntl(fd, F_FULLSYNC). Most SMB servers, like Windows
Server and Samba don't support F_FULLSYNC.

To avoid such issues fallback to syscall.Fsync if fcntl returns ENOTSUP.

Fixes #64215

Change-Id: I567191e1179b7e70ddffb6b881469de1872746ef
GitHub-Last-Rev: 62e6931cf7
GitHub-Pull-Request: golang/go#64258
Reviewed-on: https://go-review.googlesource.com/c/go/+/543535
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-07 19:20:48 +00:00
Jes Cok
ef4f2a0597 unicode/utf16: add func RuneLen
This CL adds func RuneLen, while here, also uses RuneLen to simplify
code in Encode.

Fixes #44940

Change-Id: Ifd3b537f69880dfd32a69a6733d8d3c2b5d4ecba
Reviewed-on: https://go-review.googlesource.com/c/go/+/569755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-07 19:08:48 +00:00
guoguangwu
e0ba596c15 cmd/link: replace bytes.Compare call with bytes.Equal
Change-Id: Icc254cad3c861fd2b33228aa4d19424ce57a1b55
GitHub-Last-Rev: f557a696e4
GitHub-Pull-Request: golang/go#66153
Reviewed-on: https://go-review.googlesource.com/c/go/+/569695
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 19:08:09 +00:00
guoguangwu
47079b5e80 cmd/trace: fix typo in comment
Change-Id: I6ac2863e2af8c23588d35bf142f607e241f98405
GitHub-Last-Rev: 445cf7b29e
GitHub-Pull-Request: golang/go#66152
Reviewed-on: https://go-review.googlesource.com/c/go/+/569675
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 19:08:04 +00:00
guoguangwu
d44ec4c05f cmd/go: fix typo in comment
Change-Id: I211442f2bbdab29820126a350cbdb0886a10d6e5
GitHub-Last-Rev: 0347054a55
GitHub-Pull-Request: golang/go#66160
Reviewed-on: https://go-review.googlesource.com/c/go/+/569697
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2024-03-07 19:04:09 +00:00
Michael Matloob
f93f6e501e cmd/go: test that each script test increments at least one counter
Add code that will set a scriptGoInvoked bit for the testing.TB when
it invokes the go command. If the go command was invoked, make sure
that at least one counter was incremented.

Also add the counters cmd/go/gomodcache-entry-relative,
cmd/go/gopath-entry-relative, and cmd/go/invalid-toolchain-in-file so
we can increment counters when a test errors out before the flag
subcommand counters are processed. This enforces the invariant that at
least one counter is incremented by every test that invokes the go
command.

Add the counter cmd/go/exec-go-toolchain for when a toolchain switch
happens.

Add cmd/go/subcommand:help for invoking help without arguments and
cmd/go/help-unknown-topic for when an unknown command is provided
to help.

Change-Id: Id90f2bbe4c7e89b846da00ec1ed9595ece2b269c
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/568259
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 18:33:17 +00:00
Andy Pan
da5871d582 net: consolidate the existing Windows version checks
Change-Id: I9c0ad69bd61923e9e272f157dc380a9120f08423
Reviewed-on: https://go-review.googlesource.com/c/go/+/565595
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-07 16:46:10 +00:00
Andy Pan
1cce1a6a11 net: support TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT on newer Windows
Follows up CL 542275

Fixes #65817

Change-Id: I0b77c23f15d595d58492dfa20839a08e8670448b
Reviewed-on: https://go-review.googlesource.com/c/go/+/565495
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-07 16:02:18 +00:00
Joel Sing
997636760e cmd/compile,cmd/internal/obj: provide rotation pseudo-instructions for riscv64
Provide and use rotation pseudo-instructions for riscv64. The RISC-V bitmanip
extension adds support for hardware rotation instructions in the form of ROL,
ROLW, ROR, RORI, RORIW and RORW. These are easily implemented in the assembler
as pseudo-instructions for CPUs that do not support the bitmanip extension.

This approach provides a number of advantages, including reducing the rewrite
rules needed in the compiler, simplifying codegen tests and most importantly,
allowing these instructions to be used in assembly (for example, riscv64
optimised versions of SHA-256 and SHA-512). When bitmanip support is added,
these instruction sequences can simply be replaced with a single instruction
if permitted by the GORISCV64 profile.

Change-Id: Ia23402e1a82f211ac760690deb063386056ae1fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/565015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
2024-03-07 14:57:07 +00:00
Michael Matloob
58052fe8e7 cmd: update telemetry to d5a85b2
commands run:
	go get golang.org/x/telemetry@d5a85b2
	go mod tidy
	go mod vendor

Fixes #66099

Change-Id: Ia9215855f1472fa885792d5b23a986f29759af18
Reviewed-on: https://go-review.googlesource.com/c/go/+/569421
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
2024-03-07 05:27:04 +00:00
Michael Matloob
a062470186 cmd: update to golang.org/x/sys@v0.18.0
This is a requirement of x/telemetry so update it before updating
telemetry.

Commands run (in both std and cmd):
	go get golang.org/x/sys@v0.18.0
	go mod tidy
	go mod vendor

For #66099

Change-Id: I636f0c0be89c05b9213c461b1a2eb2a4afb8a84b
Reviewed-on: https://go-review.googlesource.com/c/go/+/569420
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
2024-03-07 05:26:45 +00:00
Marin Petrunic
90d24b4f4e net/ip: proper ipv6 address parsing
Fixes #57760

Change-Id: Ic3698a18e1c80833b07e0e06bc7328d9714794c6
GitHub-Last-Rev: d185467491
GitHub-Pull-Request: golang/go#57761
Reviewed-on: https://go-review.googlesource.com/c/go/+/461605
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-03-07 01:17:29 +00:00
guoguangwu
1922cef5d7 internal/fuzz: remove useless code
Change-Id: I4534a116ef421379b2356bbe80760adae8cdd95f
GitHub-Last-Rev: a3fab3f1fa
GitHub-Pull-Request: golang/go#65892
Reviewed-on: https://go-review.googlesource.com/c/go/+/566315
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-03-07 00:20:34 +00:00
Alexander Yastrebov
70fbc88288 net/http: add ResponseController http2 request without body read deadline test
Requires CL 464936

For #58237

Change-Id: I007b61f0f216d759f8e5327d77affbd9e8f8ff23
GitHub-Last-Rev: 30a10909b0
GitHub-Pull-Request: golang/go#58282
Reviewed-on: https://go-review.googlesource.com/c/go/+/465035
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-06 19:20:31 +00:00
qmuntal
911b066bf8 internal/syscall/windows/registry: append .dll when loading kernel32
Win32 LoadLibrary supports loading a DLL omitting the .dll extension,
but it is better to be explicit and include the extension. This is
consistent with all other uses of LoadLibrary in the Go standard
library.

Change-Id: I7349d0a27db5f8ab59061434f37d10918e43b869
Reviewed-on: https://go-review.googlesource.com/c/go/+/569535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2024-03-06 19:19:00 +00:00
Jes Cok
e2459e627f encoding/binary: use built-in clear to simplify code
Change-Id: I2f3c7f4a4848ad0fbbf79bd8919b1e2abee72f3f
GitHub-Last-Rev: 06d0047b28
GitHub-Pull-Request: golang/go#66136
Reviewed-on: https://go-review.googlesource.com/c/go/+/569280
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-06 19:15:56 +00:00
Mitar
d463de61b3 net/http: remove misleading response headers on error
ServeContent API is to set some headers you want to see in the response
before calling ServeContent. But if there is an error, those headers
should be removed otherwise they might confused the client.

Removing those headers is useful in general in the case of an error,
so we remove them in http.Error.

Fixes #50905.

Change-Id: If8d2786c1512906ac93e6b388df6ab1c5ecd1ea9
GitHub-Last-Rev: 32b6f045a7
GitHub-Pull-Request: golang/go#64312
Reviewed-on: https://go-review.googlesource.com/c/go/+/544019
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-03-06 19:15:50 +00:00