1
0
mirror of https://github.com/golang/go synced 2024-11-17 07:54:41 -07:00
Commit Graph

55068 Commits

Author SHA1 Message Date
Robert Griesemer
bd42aa86d3 spec: describe new semantics for comparable and constraint satisfaction
For #56548.
Fixes #57012.

Change-Id: I44f850522e52b1811025fb31bcef289da8f8089d
Reviewed-on: https://go-review.googlesource.com/c/go/+/457437
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-14 19:13:10 +00:00
Robert Griesemer
ffefcd360b spec: introduce notion of strict comparability
- Rephrase the notion of "comparability" from a property
  of values (operands) to a property of types and adjust
  dependent prose.
- Introduce the notion of "strict comparability".
- Fix the definitions of comparability for type interfaces
  and type parameters.
- Define the predeclared identifier "comparable" as stricly
  comparable.

These changes address existing problems in the spec as outlined
in the section on "Related spec issues" in issue #56548.

For #56548.

Change-Id: Ibc8c2f36d92857a5134eadc18358624803d3dd21
Reviewed-on: https://go-review.googlesource.com/c/go/+/457095
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-14 19:12:15 +00:00
miller
cb07765045 syscall: fix closing of reordered FDs in plan9 ForkExec
After dup'ing file descriptors in syscall.ProcAttr.Files to pass
to the exec'ed process, the logic for closing the old descriptors
was incorrect and could close the new descriptor instead.

Fixes #57180

Change-Id: I7725f21a465ffba57050fe4e36f3d36ba181cfb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/457115
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-12-13 17:52:02 +00:00
Robert Griesemer
5ba98b9756 go/types, types2: report type mismatch error when conversion is impossible
Rather than reporting an impossible conversion error when mixing an
untyped value with a pointer type in an operation, report a type
mismatch error. This fixes a regression in error quality compared
to pre-1.18.

For the fix, clean up the implementation of canMix, add documentation,
and give it a better name.

Adjust test case for corresponding error code bacause we now get a
better error message (and error code) for the old error code example.

Fixes #57160.

Change-Id: Ib96ce7cbc44db6905fa2f1c90a3769af609e101b
Reviewed-on: https://go-review.googlesource.com/c/go/+/457055
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-13 16:52:44 +00:00
Oleg Zaytsev
61e2b8ec59 cmd/gc: test temp string comparison with all ops
The comment on `slicebytetostringtmp` mention that `==` operator does
not allocate []byte to string conversion, but the test was testing only
`==` and `!=` and the compiler actually optimizes all comparison
operators.

Also added a test for concatenation comparison, which also should not
allocate.

Change-Id: I6f4c5c4f238808138fa901732e1fd5b6ab25f725
Reviewed-on: https://go-review.googlesource.com/c/go/+/456415
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-12-13 14:05:23 +00:00
Paul E. Murphy
b16e94d13d syscall: skip TestUseCgroupFD if cgroupfs mounted RO
The skipping logic should also trigger if /sys/fs/cgroup is
mounted read-only too. This is how it is mounted on the
ppc64le/p10 containers today.

Fixes #57262

Change-Id: Idc0ab050052ebf5777ac09f9519215b437b0ee7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456835
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
2022-12-12 23:10:52 +00:00
Bryan C. Mills
27301e8247 syscall: fix shadowing bugs in forkAndExecInChild
Fixes #57208.
Updates #23152.

Change-Id: Icc9a74aeb26f1b6f151162c5d6bf1b4d7cd54d0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/456515
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-12 14:38:22 +00:00
Changkun Ou
6f7a95d25e sync: remove unused const
Change-Id: I4382b5317cf7f39a48005516ff6d437883c6fd07
Reviewed-on: https://go-review.googlesource.com/c/go/+/456495
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Changkun Ou <mail@changkun.de>
2022-12-12 14:30:12 +00:00
Alexander Frolov
6b895d9eaa doc/go1.20: fix typo
Change-Id: Id0319a9cc9acc549022fdcd6b7d71c7343afd245
GitHub-Last-Rev: 2b84d25763
GitHub-Pull-Request: golang/go#57187
Reviewed-on: https://go-review.googlesource.com/c/go/+/456395
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-12-12 14:20:13 +00:00
Nikola Jokic
c6ad9dc9b5 debug/buildinfo: check pointer size on buildinfo.Read
Previous implementation has a check on pointer size but only if ptrSize
is 4. but it does not check on ptrSize 8 causing the panic on read for
some inputs.

The explicit check for pointer size 8 is added and error is returned if
ptrSize is not 4 and not 8.

Fixes #57002

Change-Id: Id51de72bdef4da9955d086bfc2a5d735678ee2ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/454616
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-12-12 14:16:49 +00:00
Shengyu Zhang
5dca7ed66f doc/go1.20: fix URL anchor
The URL anchor was invalid. Add the missing "array_or_" part.

Change-Id: Ib27f4d0f21b0148bea8b63ef962ba0ea30166ed3
GitHub-Last-Rev: f8addc6078
GitHub-Pull-Request: golang/go#57154
Reviewed-on: https://go-review.googlesource.com/c/go/+/456175
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2022-12-12 14:15:22 +00:00
Keith Randall
888047c310 cmd/compile: fix conditional move rule on PPC64
Similar to CL 456556 but for ppc64 instead of arm64.

Change docs about how booleans are stored in registers for ppc64.
We now don't promise to keep the upper bits zeroed; they might be junk.

To test, I changed the boolean generation instructions (MOVBZload* and ISEL*
with boolean type) to OR in 0x100 to the result. all.bash still passed,
so I think nothing else is depending on the upper bits of booleans.

Update #57184

Change-Id: Ie66f8934a0dafa34d0a8c2a37324868d959a852c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456437
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: KAMPANAT THUMWONG (KONG PC) <1992kongpc.kth@gmail.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
2022-12-11 16:34:38 +00:00
Ian Lance Taylor
9b8750f53e os: skip size test in TestLstat if the file is a symlink
Tested by temporarily changing sysdir to use a directory where
the expected files were all symlinks. We should consider using
a different approach that doesn't rely on sysdir, but for now
do a minimal fix.

Fixes #57210

Change-Id: Ifb1becef03e014ceb48290ce13527b3e103c0e07
Reviewed-on: https://go-review.googlesource.com/c/go/+/456557
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-10 00:35:24 +00:00
Keith Randall
e8f78cb60c cmd/compile: fix conditional select rule
ARM64 maintains booleans in the low byte of registers. Upper parts
of that register are junk.
This rule is using all 32 bits of a boolean-containing register, which
is wrong. Change the rule to only look at the low bit.

Fixes #57184

Change-Id: Ibbef86b2be859df3d06d993db00e1231c481c428
Reviewed-on: https://go-review.googlesource.com/c/go/+/456556
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2022-12-09 21:38:33 +00:00
Than McIntosh
e76c87b191 doc: fix typo in 1.20 release notes
Fix typo.

Change-Id: Id3a78ac5d8ea429ba1685889cd1661aaca8572c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/456238
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-09 10:49:03 +00:00
Bryan C. Mills
80f7484af7 os/user: zero-initialize C structs returned to Go
In the wrappers for getgrnam_r and similar, the structs to be returned
are allocated on the C stack and may be uninitialized. If the call to
the wrapped C function returns an error (such as ERANGE), it may leave
the struct uninitialized, expecting that the caller will not read it.

However, when that struct is returned to Go, it may be read by the Go
garbage collector. If the uninitialized struct fields happen to
contain wild pointers, the Go garbage collector will throw an error.
(Prior to CL 449335, the Go runtime would not scan the struct fields
because they did not reside in Go memory.)

Fix this by always zeroing the struct before the C call.

Fixes #57170.

Change-Id: I241ae8e4added6f9a406dac37a7f6452341aa0cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/456121
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-12-09 04:05:17 +00:00
Robert Findley
e738a2f19b go/types, types2: always rename type parameters during inference
Type inference uses a trick of "renaming" type parameters in the type
parameter list to avoid cycles during unification. This separates the
identity of type parameters from type arguments. When this trick was
introduced in CL 385494, we restricted its application to scenarios
where inference is truly self-recursive: the type parameter list being
inferred was the same as the type parameter list of the outer function
declaration. Unfortunately, the heuristic used to determine
self-recursiveness was flawed: type-checking function literals clobbers
the type-checker environment, losing information about the outer
signature.

We could fix this by introducing yet more state into the type-checker
(e.g. a 'declSig' field that would hold the signature of the active
function declaration), but it is simpler to just avoid this optimization
and always perform type parameter renaming. We can always optimize
later.

This CL removes the check for true self-recursion, always performing the
renaming.

Fixes golang/go#57155

Change-Id: I34c7617005c1f0ccfe2192da0e5ed104be6b92c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/456236
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-08 23:06:18 +00:00
Zhizhen He
8247b9f17a doc: fix typo
Change-Id: Ie639fe39b83336c0d885cdcb2fddc06f2b06c2dd
GitHub-Last-Rev: b5cc78ad42
GitHub-Pull-Request: golang/go#57082
Reviewed-on: https://go-review.googlesource.com/c/go/+/455196
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2022-12-08 19:06:14 +00:00
Dmitri Shuralyov
f368abb46e doc/go1.20: correct test binary -v flag value for test2json
The -v flag value is "test2json", not "json", since it emits output
in a custom format that the cmd/test2json tool interprets.
The cmd/test2json documentation and implementation have this right.

For #54202.

Change-Id: I2b52861d926e14488aa9fc89fff8c26da32ca710
Reviewed-on: https://go-review.googlesource.com/c/go/+/456124
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-12-08 18:29:35 +00:00
Than McIntosh
7973b0e508 cmd/{go,cover,covdata}: fix 'package main' inconsistent handling
Fix a buglet in cmd/cover in how we handle package name/path for the
"go build -o foo.exe *.go" and "go run *.go" cases.

The go command assigns a dummy import path of "command-line-arguments"
to the main package built in these cases; rather than expose this
dummy to the user in coverage reports, the cover tool had a special
case hack intended to rewrite such package paths to "main". The hack
was too general, however, and was rewriting the import path of all
packages with (p.name == "main") to an import path of "main". The hack
also produced unexpected results for cases such as

  go test -cover foo.go foo_test.go

This patch removes the hack entirely, leaving the package path for
such cases as "command-line-arguments".

Fixes #57169.

Change-Id: Ib6071db5e3485da3b8c26e16ef57f6fa1712402c
Reviewed-on: https://go-review.googlesource.com/c/go/+/456237
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-12-08 18:29:31 +00:00
cia-rana
0aad4d3257 cmd/link: fix dynamic interpreter path for musl-based linux amd64
Change-Id: Ia07e237647b419b73d6faa11baa32e6176c8b7ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/456215
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-12-08 15:23:23 +00:00
Bryan C. Mills
eaf0e3d465 runtime: remove arbitrary timeouts in finalizer tests
These short timeouts can overrun due to system scheduling delay
(or GC latency) on a slow or heavily-loaded host.

Moreover, if the test deadlocks we will probably want to know what the
GC goroutines were doing at the time. With an arbitrary timeout, we
never get that information; however, if we allow the test to time out
completely we will get a goroutine dump (and, if GOTRACEBACK is
configured in the environment, that may even include GC goroutines).

Fixes #57166.

Change-Id: I136501883373c3ce4e250dc8340c60876b375f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/456118
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2022-12-08 14:19:25 +00:00
Bryan C. Mills
c8313d4fa8 cmd/go: deflake TestScript/test2json_interrupt
- Start handling signals in 'go test' just before starting the test
  subprocess instead of just after. (It is unlikely that starting the
  process will cause cmd/go to hang in a way that requires signals to
  debug, and it is possible that something the test does — such as
  sending os.Interrupt to its parent processes — will immediately
  send a signal that needs to be handled.)

- In the test-test, don't try to re-parse the parent PIDs after
  sending signals, and sleep for a much shorter time interval.
  (Overrunning the sleep caused the next call to strconv.Atoi — which
  shouldn't even happen! — to fail with a parse error, leading to the
  failure mode observed in
  https://build.golang.org/log/f0982dcfc6a362f9c737eec3e7072dcc7ef29e32.)

Fixes #56083.
Updates #53563.

Change-Id: I346a95bdda5619632659ea854f98a9e17a6aede7
Reviewed-on: https://go-review.googlesource.com/c/go/+/456115
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-12-08 03:52:44 +00:00
Ian Lance Taylor
b9747e0e6b os/user: on AIX getpwuid_r seems to return -1 on overflow
The getpwuid_r function is expected to return ERANGE on overflow.
Accept -1 on AIX as we see that in practice.

This problem was uncovered by, but not caused by, CL 455815,
which introduced a test that forced a buffer overflow.

Change-Id: I3ae94faf1257d2c73299b1478e49769bb807fc4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/456075
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-08 03:49:48 +00:00
David du Colombier
9431237d77 internal/safefilepath: fix TestFromFS on Plan 9
CL 455716 added TestFromFS. This test was failing on Plan 9
because fromFS didn't return an empty string in case of error.

This change fixes TestFromFS by returning an empty string
in case of error.

Fixes #57142.

Change-Id: Ie50dfba5e70154d641f762fa43f1c26c3d12b6f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/455835
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
2022-12-07 23:52:46 +00:00
Bryan C. Mills
7c7cd56870 cmd/go: in TestTerminalPassthrough, delay subprocess exit until the PTY has been read
Empirically, unread PTY output may be discarded on macOS when the
child process exits.

Fixes #57141.

Tested with 'go test cmd/go -run=TestTerminalPassthrough -count=1000'
on a darwin-amd64-12_0 gomote.

Change-Id: I11508e6429c61488f30e10d9ae0cc94fdf059257
Reviewed-on: https://go-review.googlesource.com/c/go/+/455915
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-12-07 18:18:50 +00:00
Michael Pratt
e57e673e7f api: promote next to go1.20
Change-Id: I180f262837b164095f9ac9459d900ec1ac0585a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/455697
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-07 16:56:12 +00:00
Michael Pratt
3ec5085eac doc/go1.20: delete remaining TODO
This section is complete.

For #54202.

Change-Id: I304cc55a5b8ed53e8b8dff73a5feb5ef39207846
Reviewed-on: https://go-review.googlesource.com/c/go/+/455895
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-07 16:49:08 +00:00
Than McIntosh
f715d28cea doc/go1.20: add section on coverage
Add some basic material on the changes to code coverage testing
to the release notes.

For #54202.

Change-Id: I28200d43b4952ce8e8ecf46c8fe8e97c81d245e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/453857
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-12-07 16:26:42 +00:00
Russ Cox
7ed50cfd09 os/user: fix buffer retry loop on macOS
getpwnam_r and friends return the errno as the result,
not in the global errno. The code changes in CL 449316
inadvertently started using the global errno.
So if a lookup didn't fit in the first buffer size,
it was treated as not found instead of growing the buffer.

Fixes #56942.

Change-Id: Ic5904fbeb31161bccd858e5adb987e919fb3e9d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/455815
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2022-12-07 16:09:09 +00:00
Russ Cox
a4a86c7b24 doc/go1.20: relnote and take care of TODOs
The main change here is documenting the last-minute addition types.Satisfies.

Change-Id: I8be2d2ad730ba108706bd849b68cbd1f4d68a4b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/455698
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-12-07 14:20:49 +00:00
Matthew Dempsky
a398963203 go/internal/gcimporter: simplify unified IR importer
CL 424854 changed the unified IR writer's handling of type
declarations to write the underlying type rather than the RHS type
expression's type. This in turn allows us to simplify the go/types
importer, because now there's no need to delay caling SetUnderlying.

Fixes #57015.

Change-Id: I80caa61f6cad5b7f9d829939db733a66cfca621c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424876
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-12-07 03:45:50 +00:00
Matthew Dempsky
dddc1ba847 cmd/compile: restore test/nested.go test cases
[Re-land of CL 424854, which was reverted as CL 425214.]

When handling a type declaration like:

```
type B A
```

unified IR has been writing out that B's underlying type is A, rather
than the underlying type of A.

This is a bit awkward to implement and adds complexity to importers,
who need to handle resolving the underlying type themselves. But it
was necessary to handle when A was declared like:

```
//go:notinheap
type A int
```

Because we expected A's not-in-heap'ness to be conferred to B, which
required knowing that A was on the path from B to its actual
underlying type int.

However, since #46731 was accepted, we no longer need to support this
case. Instead we can write out B's actual underlying type.

One stumbling point though is the existing code for exporting
interfaces doesn't work for the underlying type of `comparable`, which
is now needed to implement `type C comparable`. As a bit of a hack, we
we instead export its underlying type as `interface{ comparable }`.

Fixes #54512.

Change-Id: I9aa087e0a277527003195ebc7f4fbba6922e788c
Reviewed-on: https://go-review.googlesource.com/c/go/+/455279
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-07 03:44:27 +00:00
Damien Neil
8cd931ff0d all: update vendored golang.org/x/net
Pull in HTTP/2 security fix:

	1e63c2f08a http2: limit canonical header cache by bytes, not entries

Fixes #56350

Change-Id: Ib14024ed894ba266f05d4a6e8c454234a45677d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/455717
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-07 00:51:44 +00:00
Russ Cox
10bb003401 lib/time: update to 2022g/2022g
Commit generated by update.bash.

For #22487.

Change-Id: I6a995a3baea7c511b9bd5155f81d8b8e2cdff09d
Reviewed-on: https://go-review.googlesource.com/c/go/+/455356
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-07 00:25:27 +00:00
Damien Neil
7dc9fcb13d os, net/http: avoid escapes from os.DirFS and http.Dir on Windows
Do not permit access to Windows reserved device names (NUL, COM1, etc.)
via os.DirFS and http.Dir filesystems.

Avoid escapes from os.DirFS(`\`) on Windows. DirFS would join the
the root to the relative path with a path separator, making
os.DirFS(`\`).Open(`/foo/bar`) open the path `\\foo\bar`, which is
a UNC name. Not only does this not open the intended file, but permits
reference to any file on the system rather than only files on the
current drive.

Make os.DirFS("") invalid, with all file access failing. Previously,
a root of "" was interpreted as "/", which is surprising and probably
unintentional.

Fixes CVE-2022-41720
Fixes #56694

Change-Id: I275b5fa391e6ad7404309ea98ccc97405942e0f0
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663834
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/455362
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jenny Rakoczy <jenny@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/455716
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-12-06 23:50:47 +00:00
Cherry Mui
e535d6776c Revert "runtime/pprof: unskip TestTimeVDSO on Android"
This reverts CL 455358, commit 98da0fb43f.

Reason for revert: still failing https://build.golang.org/log/c9f13a76069f523b5b4a37a75ec52b30a1f3427a

Change-Id: I8246d233c4fb86781b882f19dea82065cc21bc26
Reviewed-on: https://go-review.googlesource.com/c/go/+/455696
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-12-06 22:07:25 +00:00
Bryan C. Mills
89871dd832 cmd/go: unskip TestScript/build_issue48319 on Windows
Now that we have newer C compilers on the Windows builders, they
should fully support reproducible builds.

Updates #35006.

Change-Id: I0a8995fe327067c9e73e5578c385ea01ae5dee5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/454504
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-12-06 20:53:50 +00:00
Roland Shoemaker
5167e5cd64 archive/zip: only consider UncompressedSize when checking dirs
CL 454475 switched from checking CompressedSize to UncompressedSize
when determining if we should consider an archive malformed because
it contains data and added a test for an example of this (a JAR). We
should also remove the hasDataDescriptor check, since that is basically
an alias for CompressedSize > 0. The test didn't catch this because we
didn't actually attempt to read from the returned reader.

Change-Id: Ibc4c1aa9c3a733f3ebf4a956d1e2f8f4900a29cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/455523
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-06 20:19:47 +00:00
Dmitri Shuralyov
03bf6f4917 run.bash, cmd/dist: document GO_TEST_SHORT and GO_TEST_TIMEOUT_SCALE
These environment variables affect cmd/dist, and in turn run.bash.
They exist primarily for the Go build system, but are still needed
sometimes when investigating problems. Document them in one place.

Fixes #46054.

Change-Id: I5dea2ac79b0d203d2f3c9ec2980382f62bead5cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/455517
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-12-06 19:52:35 +00:00
Robert Griesemer
dfd13ce59d go/types, types2: better error message for invalid method expression
Fixes #53358.

Change-Id: I38528da1596b6e1aaedcab89b1513fb8acac596c
Reviewed-on: https://go-review.googlesource.com/c/go/+/455335
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-12-06 18:32:51 +00:00
Cherry Mui
98da0fb43f runtime/pprof: unskip TestTimeVDSO on Android
It is possible that CL 455166 fixes this. Try unskipping the test
and see. If it fails again we can skip it again.

Fixes #48655.

Change-Id: Ia81b06cb7608f74adb276bc018e8fc840285bc11
Reviewed-on: https://go-review.googlesource.com/c/go/+/455358
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-06 18:11:17 +00:00
Than McIntosh
fe67a21625 cmd/link: pass -Wl,--no-insert-timestamp to external linker on windows
Pass -Wl,--no-insert-timestamp to the external linker on windows, so
as to suppress generation of the PE file header data/time stamp. This
is in order to make it possible to get reproducible CGO builds on
windows (note that we already zero the timestamp field in question for
internal linkage).

Updates #35006.

Change-Id: I3d69cf1fd32e099bd9bb4b0431a4c5f43e4b08f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/455535
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-06 15:55:39 +00:00
Keith Randall
1eb0465fa5 cmd/compile: turn off jump tables when spectre retpolines are on
Fixes #57097

Change-Id: I6ab659abbca1ae0ac8710674d39aec116fab0baa
Reviewed-on: https://go-review.googlesource.com/c/go/+/455336
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
2022-12-06 05:12:12 +00:00
Keith Randall
9dde2de454 cmd/asm: improve assembler error messages
Provide file/line numbers for errors when we have them.
Make the assembler error text closer to the equivalent errors from the compiler.

Abort further processing when we come across errors.
Fixes #53994

Change-Id: I4d6a037d6d713c1329923fce4c1189b5609f3660
Reviewed-on: https://go-review.googlesource.com/c/go/+/455276
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-05 23:21:07 +00:00
Robert Griesemer
0b323a3c16 go/types, types2: better error message for failing constraint type inference
We know the type argument against which constraint type inference fails:
print the type argument instead of the corresponding type parameter.

Fixes #57096.

Change-Id: Ia1da9c87fac6f8062e4d534b82e895fa4617fddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/455278
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-05 22:29:44 +00:00
Keith Randall
9e059630ad cmd/compile: clean up amd64 opcode comments
Put comments about what operations do per block of related opcodes
instead of on each line. This is less repetitive and lets us be a bit
more verbose in our descriptions.

Doesn't change the generated code at all.

Change-Id: I98fbd4029df6537b10aac2113a00df121d0fca1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/433736
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-12-05 22:22:11 +00:00
Cherry Mui
185e1a7b27 runtime: prioritize VDSO and libcall unwinding in profiler
In the profiler, when unwinding the stack, we have special
handling for VDSO calls. Currently, the special handling is only
used when the normal unwinding fails. If the signal lands in the
function that makes the VDSO call (e.g. nanotime1) and after the
stack switch, the normal unwinding doesn't fail but gets a stack
trace with exactly one frame (the nanotime1 frame). The stack
trace stops because of the stack switch. This 1-frame stack trace
is not as helpful. Instead, if vdsoSP is set, we know we are in
VDSO call or right before or after it, so use vdsoPC and vdsoSP
for unwinding. Do the same for libcall.

Also remove _TraceTrap for VDSO unwinding, as vdsoPC and vdsoSP
correspond to a call, not an interrupted instruction.

Fixes #56574.

Change-Id: I799aa7644d0c1e2715ab038a9eef49481dd3a7f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/455166
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-05 22:01:50 +00:00
Mateusz Poliwczak
a5b10be471 net: support context cancellation in resSearch
As with all the stuff that call cgo from net package.

Change-Id: I7c42ae44a1d47f4f949b203682217498fcdba92a
GitHub-Last-Rev: 70406493bb
GitHub-Pull-Request: golang/go#57043
Reviewed-on: https://go-review.googlesource.com/c/go/+/454697
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-05 20:45:49 +00:00
David Chase
b45cb0ce86 doc: 1.20 compiler changes
This adds the nonPGO, non-coverage compiler changes
for the 1.20 release.  There's not that much user
visible change.

For #54202.

Change-Id: Ib2964ed5f7e73bb89c720d09b868ab79682f5070
Reviewed-on: https://go-review.googlesource.com/c/go/+/454536
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
2022-12-05 19:25:34 +00:00