1
0
mirror of https://github.com/golang/go synced 2024-09-29 08:24:36 -06:00
Commit Graph

52844 Commits

Author SHA1 Message Date
Cherry Mui
e6b5949a75 cmd/internal/obj/arm64: fix encoding of ADR/ADRP instruction
The referenced address is p.From, not p.To.

Separate from CL 403980, as this is a bug fix. Also, ADR is used
in CL 387336. This is needed to make it work correctly.

Change-Id: Ie0baaeb359b9a7f233458d2becf25dc6a1f8ecbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/407884
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 21:58:35 +00:00
Bryan C. Mills
715ba65563 misc/cgo/testsanitizers: terminate commands with SIGQUIT if hung
If the test hangs due to a deadlock in a subprocess, we want a
goroutine dump of that process to figure out the nature of the
deadlock. SIGQUIT causes the Go runtime to produce exactly
such a dump (unless the runtime itself is badly deadlocked).

For #52998.

Change-Id: Id9b3ba89d8f705e14f6cd789353fc2b7f4774ad3
Reviewed-on: https://go-review.googlesource.com/c/go/+/407954
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 21:33:54 +00:00
Cherry Mui
74f0ccb68b reflect: store receiver in pointer slot for reflect call
The code comment says that the receiver doesn't need to go into
the pointer slot as it will be kept alive in this frame. But it
doesn't. There is no direct reference of rcvr or v (the receiver)
after storing the arguments. Also, it is clearer to explicitly
keep it alive.

Fixes #52800.

Change-Id: Ie3fa8e83f6ecc69d62e8bfab767314d5181f5dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/407508
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 18:40:59 +00:00
Khaled Yakdan
c1d197a96e cmd/compile: support libFuzzer value profiling mode for integer compares
libFuzzer provides a special mode known as “value profiling” in which it
tracks the bit-wise progress made by the fuzzer in satisfying tracked
comparisons. Furthermore, libFuzzer uses the value of the return address
in its hooks to distinguish the progress for different comparisons.

The original implementation of the interception for integer comparisons
in Go simply called the libFuzzer hooks from a function written in Go
assembly. The libFuzzer hooks thus always see the same return address
(i.e., the address of the call instruction in the assembly snippet) and
thus can’t distinguish individual comparisons anymore. This drastically
reduces the usefulness of value profiling.

This is fixed by using an assembly trampoline that injects synthetic but
valid return addresses on the stack before calling the libFuzzer hook,
otherwise preserving the calling convention of the respective platform
(for starters, x86_64 Windows or Unix). These fake PCs are generated
deterministically based on the location of the compare instruction in
the IR representation.

Change-Id: Iea68057c83aea7f9dc226fba7128708e8637d07a
GitHub-Last-Rev: f9184baafd
GitHub-Pull-Request: golang/go#51321
Reviewed-on: https://go-review.googlesource.com/c/go/+/387336
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-23 16:21:22 +00:00
Khaled Yakdan
3f571d1dea cmd/link: set coverage counters as expected by the fuzz package
Set _counters and _ecounters to the start and end locations of
libfuzzer's 8-bit counters section

Change-Id: Icadb503af1ba22495b1d88b69aad26d89843baa4
GitHub-Last-Rev: 4ca6216b76
GitHub-Pull-Request: golang/go#53022
Reviewed-on: https://go-review.googlesource.com/c/go/+/407674
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-23 14:38:06 +00:00
Ian Lance Taylor
0a1a092c4b Revert "cmd/cgo: use --no-gc-sections if available"
This reverts CL 405414.

Reason for revert: Breaks on AIX and iOS.

Change-Id: I4681c6f2fd69616691660916ebf0853e3a6a67ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/407634
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-20 23:37:43 +00:00
Dan Kortschak
c3470ca83c internal/fuzz: trim carriage return from version line
On windows hosts, when code is checked out using git with the default
setting of autocrlf=true, carriage returns are appended to source lines
which then prevent the version check from being successful. This removes
carriage returns to allow version matching.

Fixes #52268

Change-Id: I9acc4e907c93a20305f8742cc01687a122a88645
Reviewed-on: https://go-review.googlesource.com/c/go/+/402074
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20 23:05:38 +00:00
Khaled Yakdan
2b0e457b42 cmd/compile: intercept string compares in libFuzzer mode
IR string compares as well as calls to string comparison functions such
as `strings.EqualFold` are intercepted and the corresponding libFuzzer
callbacks are invoked with the corresponding arguments. As a result, the
compared strings will be added to libFuzzer’s table of recent compares,
which feeds future mutations performed by the fuzzer and thus allow it
to reach into branches guarded by string comparisons.

The list of methods to intercept is maintained in
`cmd/compile/internal/walk/expr.go` and can easily be extended to cover
more standard library functions in the future.

Change-Id: I5c8b89499c4e19459406795dea923bf777779c51
GitHub-Last-Rev: 6b8529b555
GitHub-Pull-Request: golang/go#51319
Reviewed-on: https://go-review.googlesource.com/c/go/+/387335
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2022-05-20 22:30:37 +00:00
Michael Anthony Knyszek
b58067013e runtime: allocate physical-page-aligned memory differently
Currently, physical-page-aligned allocations for stacks (where the
physical page size is greater than the runtime page size) first
overallocates some memory, then frees the unaligned portions back to the
heap.

However, because allocating via h.pages.alloc causes scavenged bits to
get cleared, we need to account for that memory correctly in heapFree
and heapReleased. Currently that is not the case, leading to throws at
runtime.

Trying to get that accounting right is complicated, because information
about exactly which pages were scavenged needs to get plumbed up.
Instead, find the oversized region first, and then only allocate the
aligned part. This avoids any accounting issues.

However, this does come with some performance cost, because we don't
update searchAddr (which is safe, it just means the next allocation
potentially must look harder) and we skip the fast path that
h.pages.alloc has for simplicity.

Fixes #52682.

Change-Id: Iefa68317584d73b187634979d730eb30db770bb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/407502
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-05-20 21:54:20 +00:00
Khaled Yakdan
7ec6ef432a cmd/compile, cmd/link: use libFuzzer 8-bit instead of extra counters
By using libFuzzer’s 8-bit counters instead of extra counters, the
coverage instrumentation in libFuzzer mode is improved in three ways:
  1- 8-bit counters are supported on all platforms, including macOS and
     Windows, with all relevant versions of libFuzzer, whereas extra
     counters are a Linux-only feature that only recently received
     support on Windows.
  2- Newly covered blocks are now properly reported as new coverage by
     libFuzzer, not only as new features.
  3- The NeverZero strategy is used to ensure that coverage counters
     never become 0 again after having been positive once. This resolves
     issues encountered when fuzzing loops with iteration counts that
     are multiples of 256 (e.g., larger powers of two).

Change-Id: I9021210d7fbffd07c891ad08750402ee91cb3df5
GitHub-Last-Rev: 9057e4b21d
GitHub-Pull-Request: golang/go#51318
Reviewed-on: https://go-review.googlesource.com/c/go/+/387334
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-05-20 21:32:57 +00:00
Alex Brachet
e66f895667 cmd/cgo: allow DW_TAG_variable's with no name
https://reviews.llvm.org/D123534 is emitting DW_TAG_variable's
that don't have a DW_AT_name. This is allowed in the DWARF
standard. It is adding DIE's for string literals for better
symbolization on buffer overlows etc on these strings. They
no associated name because they are not user provided variables.

Fixes #53000

Change-Id: I2cf063160508687067c7672cef0517bccd707d7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406816
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>
2022-05-20 21:03:28 +00:00
Motiejus Jakštys
4dd9458162 cmd/cgo: use --no-gc-sections if available
zig cc passes `--gc-sections` to the underlying linker, which then
causes undefined symbol errors when compiling with cgo but without C
code. Add `-Wl,--no-gc-sections` to make it work with zig cc. Minimal
example:

**main.go**

    package main
    import _ "runtime/cgo"
    func main() {}

Run (works after the patch, doesn't work before):

    CC="zig cc" go build main.go

Among the existing code, `src/runtime/testdata/testprognet` fails to
build:

    src/runtime/testdata/testprognet$ CC="zig cc" go build .
    net(.text): relocation target __errno_location not defined
    net(.text): relocation target getaddrinfo not defined
    net(.text): relocation target freeaddrinfo not defined
    net(.text): relocation target gai_strerror not defined
    runtime/cgo(.text): relocation target stderr not defined
    runtime/cgo(.text): relocation target fwrite not defined
    runtime/cgo(.text): relocation target vfprintf not defined
    runtime/cgo(.text): relocation target fputc not defined
    runtime/cgo(.text): relocation target abort not defined
    runtime/cgo(.text): relocation target pthread_create not defined
    runtime/cgo(.text): relocation target nanosleep not defined
    runtime/cgo(.text): relocation target pthread_detach not defined
    runtime/cgo(.text): relocation target stderr not defined
    runtime/cgo(.text): relocation target strerror not defined
    runtime/cgo(.text): relocation target fprintf not defined
    runtime/cgo(.text): relocation target abort not defined
    runtime/cgo(.text): relocation target pthread_mutex_lock not defined
    runtime/cgo(.text): relocation target pthread_cond_wait not defined
    runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
    runtime/cgo(.text): relocation target pthread_cond_broadcast not defined
    runtime/cgo(.text): relocation target malloc not defined

With the patch both examples build as expected.

@ianlancetaylor suggested:

> It would be fine with me if somebody wants to send a cgo patch that
passes -Wl,--no-gc-sections, with a fallback if that option is not
supported.

... and this is what we are doing. Tested with zig
0.10.0-dev.2252+a4369918b

Fixes #52690

Change-Id: Ib6d1b2bd59335e9663afefd360ddad7da358a938
GitHub-Last-Rev: 58406b36ca
GitHub-Pull-Request: golang/go#52815
Reviewed-on: https://go-review.googlesource.com/c/go/+/405414
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20 21:03:26 +00:00
Matthew Dempsky
69b412b7d6 internal/pkgbits: better documentation
Change-Id: I3f96a6e8a43faa5c8111b9d979aa37822c1dce06
Reviewed-on: https://go-review.googlesource.com/c/go/+/407434
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-20 19:01:40 +00:00
Xiaodong Liu
ec464edb22 cmd/dist: port to linux/loong64 completed
For #46229

Change-Id: I5c207482d0a2cfb3a66f7e293cf413a5b54daa26
Reviewed-on: https://go-review.googlesource.com/c/go/+/397074
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-20 16:17:43 +00:00
Xiaodong Liu
c6ef69e7d7 misc, test: fix test error for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I6760b4a7e51646773cd0f48baa1baba01b213b7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/342325
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-20 16:16:37 +00:00
Wang Deyu
22a3209bc6 runtime: update description of GODEBUG=scavtrace=1
For #48409.

Change-Id: I056afcdbc417ce633e48184e69336213750aae28
Reviewed-on: https://go-review.googlesource.com/c/go/+/406575
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20 15:17:29 +00:00
Xiaodong Liu
1371339530 go, math, os, reflect: support standard library for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I2ad9ed01fc913b90e75023ac0fa70de87a9f5de1
Reviewed-on: https://go-review.googlesource.com/c/go/+/342324
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-20 15:12:52 +00:00
Xiaodong Liu
ae3ee9a7ec syscall: add syscall support for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ia676bd2875701639314cadbd39d97620afb3f0a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/342317
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:49 +00:00
Xiaodong Liu
ed7c487178 runtime: add loong64 to architectures known to TestGCInfo
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I61bef32b38ab07543a147cf172b169eae21b26cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/368082
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:39 +00:00
Xiaodong Liu
0811559ddd runtime: add build tag for common support on linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ide01fb8a39fe3e890f6cbc5d28f4a1d47eb5d79b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368081
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-05-20 15:12:37 +00:00
Xiaodong Liu
2a5ceaaa78 runtime: implement runtime entry for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I252ecd0b13580c5e71723715023b1951985045f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/342322
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-20 15:12:31 +00:00
nimelehin
5370494577 runtime: add BenchmarkMemclrRange
This benchmark is added to test improvements in memclr_amd64.
As it is stated in Intel Optimization Manual 15.16.3.3, AVX2-implemented
memclr can produce a skewed result with the branch predictor being
trained by the large loop iteration count.

This benchmark generates sizes between some specified range. This should
help to measure how memclr works when branch predictors may be incorrectly
trained.

Change-Id: I14d173cafe43ca47198ed920e655547a66b3909f
Reviewed-on: https://go-review.googlesource.com/c/go/+/373362
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-20 13:51:52 +00:00
Keith Randall
d8762b2f45 runtime: fix overflow in PingPongHog test
On 32-bit systems the result of hogCount*factor can overflow.
Use division instead to do comparison.

Update #52207

Change-Id: I429fb9dc009af645acb535cee5c70887527ba207
Reviewed-on: https://go-review.googlesource.com/c/go/+/407415
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-05-19 21:33:15 +00:00
Ian Lance Taylor
dd83fd8a70 cmd/dist: pass a -test.timeout option to a host test
For a host test we build the test using "go test -c" and then run the
test binary. A test binary run in this way has no default timeout.
This CL gives it a timeout of 5 minutes, scaled for the target.
We can adjust the timeout if necessary.

For #52998

Change-Id: Ib759142f3e71cbb37ec858182998fc5d4fba7ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/407374
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 21:32:46 +00:00
Xiaodong Liu
34507e879d runtime/cgo: add cgo function call support for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I8ef0e7f17d6ada3d2f07c81524136b78457e7795
Reviewed-on: https://go-review.googlesource.com/c/go/+/342319
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-05-19 21:15:04 +00:00
Xiaodong Liu
a7cc865edb runtime/internal/atomic: add atomic support for loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I0333503db044c6f39df2d7f8d9dff213b1361d6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342320
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 21:14:49 +00:00
Daniel Martí
87039c7d34 cmd/go: reference BuildID field from list's -export docs
In https://golang.org/cl/263542 we added BuildID to the Package struct
in the docs for "go list", correctly pointing out that it's only set
when -export is used.

Further down, the doc details the -export flag on its own.
It already mentioned the Export field, and we forgot to add a mention to
BuildID as well. Do that.

Change-Id: I5838a8900edae8012fe333937d86baea3066c5f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/392114
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2022-05-19 20:54:47 +00:00
Tobias Klauser
a1ceacedd8 net/netip: fix receiver name in Addr.{has,without}Zone comments
Change-Id: I851900cb52abfe75224a9dd9b9760eafd2cfc85f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407175
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:31:45 +00:00
Jinzhu
29057b707d database/sql: fix close rows error ignored in Next
Change-Id: I19f0d764e2a6122307f3f26a6dd3be7b1155c73b
GitHub-Last-Rev: 9f1f883c45
GitHub-Pull-Request: golang/go#52756
Reviewed-on: https://go-review.googlesource.com/c/go/+/404794
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:21:12 +00:00
Mostafa Solati
97ce98ac20 cmd/go: do not ignore flags option with bad quoting
Fixes #43177

Change-Id: I7d8ef8dee0dcade3cc88fc6423e23f41d1f8ffb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/339289
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>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-05-19 20:20:43 +00:00
Keith Randall
6b6813fdb7 runtime: test alignment of fields targeted by 64-bit atomics
Make sure that all the targets of 64-bit atomic operations
are actually aligned to 8 bytes. This has been a source of
bugs on 32-bit systems. (e.g. CL 399754)

The strategy is to have a simple test that just checks the
alignment of some explicitly listed fields and global variables.

Then there's a more complicated test that makes sure the list
used in the simple test is exhaustive. That test has some
limitations, but it should catch most cases, particularly new
uses of atomic operations on new or existing fields.

Unlike a runtime assert, this check is free and will catch
accesses that occur even in very unlikely code paths.

Change-Id: I25ac78df471ac33b57cb91375bd8453d6ce2814f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407034
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 20:10:40 +00:00
Daniel Martí
9b89c38020 cmd/gofmt: use SkipObjectResolution with -s as well
The "simplify" feature used go/ast's object tracking in only one place -
to replace s[a:len(s)] with s[a:].
Using go/ast.Object did allow us to not simplify code like:

	len := func(s []int) int { ... }
	s = s[a:len(s)]

The existing code already noted the limitation with that approach,
such as "len" being redeclared in a different file in the same package.
Since go/ast's object tracking is file-based and very basic,
it wouldn't work with edge cases like those.

The reasoning is that redeclaring len and abusing it that way is
extremely unlikely, and hasn't been a problem in about a decade now.
I reason that the same applies to len being redeclared in the same file,
so we should be able to safely remove the use of go/ast.Object here.

Per https://go.dev/cl/401454, this makes "gofmt -s" about 5% faster.
If we ever wanted to truly get rid of false positive simplifications,
I imagine we'd want to reimplement the feature under go/analysis,
which is able to fully typecheck packages and suggest edits.
That seems unnecessary at this point, but we can always course correct
in the presumably unlikely scenario that users start reporting bugs.

See #46485.
For #52463.

Change-Id: I77fc97adceafde8f0fe6887ace83ae325bfa7416
Reviewed-on: https://go-review.googlesource.com/c/go/+/401875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-19 20:06:14 +00:00
Mostafa Solati
81a9a7f4c2 reflect: add example for FieldByName
Change-Id: I47e1cc261fdcd6f83a8593893b979d130150d0b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/407174
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-19 20:04:36 +00:00
Michael Anthony Knyszek
a6c75aa5c3 runtime: use correct heap goal in GC traces
Currently gctrace and gcpacertrace recompute the heap goal for
end-of-cycle information but this is incorrect.

Because both of these traces are printing stats from the previous cycle
in this case, they should print the heap goal at the end of the previous
cycle.

Change-Id: I967621cbaff9f331cd3e361de8850ddfe0cfc099
Reviewed-on: https://go-review.googlesource.com/c/go/+/407138
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-05-19 19:57:28 +00:00
Xiaodong Liu
8542bd8938 runtime: support vdso for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ie9bb5ccfc28e65036e2088c232bb333dcb259a60
Reviewed-on: https://go-review.googlesource.com/c/go/+/368076
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:32:35 +00:00
Xiaodong Liu
0084706528 runtime: implement signal for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ifa0229d2044dd53683de4a2b3ab965b16263f267
Reviewed-on: https://go-review.googlesource.com/c/go/+/368075
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:32:33 +00:00
Xiaodong Liu
c8de7628cb runtime: implement syscalls for runtime bootstrap on linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I848608267932717895d5cff9e33040029c3f3c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/368080
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: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:28:24 +00:00
Xiaodong Liu
96a10b9c84 runtime: implement duffzero/duffcopy for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: Ida040e76dc8172f60e6aee1ea2b5bce13ab3581e
Reviewed-on: https://go-review.googlesource.com/c/go/+/368077
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-05-19 19:13:17 +00:00
Xiaodong Liu
2a5114f49a runtime: support memclr/memmove for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I7c1f39670034db6714630d479bc41b6620ba2b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/368079
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 19:13:01 +00:00
Russ Cox
946b4baaf6 all: gofmt main repo
Excluding vendor and testdata.
CL 384268 already reformatted most, but these slipped past.

The struct in the doc comment in debug/dwarf/type.go
was fixed up by hand to indent the first and last lines as well.

For #51082.

Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/407137
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19 15:49:05 +00:00
Bryan C. Mills
e23cc0844d misc/cgo/testplugin: set the package name in TestIssue19534
The fix for #19534 (in CL 40994) adjusted escaping in the
dynamically-linked name lookup logic for the plugin package. However,
the regression test added for it incorrectly included quotes within
the -ldflags flag, causing the flag to inadvertently be ignored.

Possibly in that same CL or possibly at some other point, the
condition that the test thought it was checking stopped working: the
dynamic lookup used the path passed to ldflags, but the object file
actually contained the symbol indexed by the original package name.

Ideally we should stop mucking around with ldflags in this test and
run 'go build' from a suitably-named directory instead, to mimic the
actual conditions in which the original bug was reported. For now, as
a more targeted fix, we can pass the '-p' flag to the compiler to
adjust the package path used at compile time to match the one that
will be set at link time.

For #43177.
Updates #19534.

Change-Id: I9763961feb37cfb05dee543f273492e91a350663
Reviewed-on: https://go-review.googlesource.com/c/go/+/407314
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-05-19 15:38:08 +00:00
Russ Cox
0aa8a87b5d syscall: make //sys lines not doc comments
If they are doc comments then gofmt will put a space between // and sys.
Most of syscall was already this way, following CL 7324056 (in 2013).
These were not.

Change-Id: Ie6ebf82809c199d0d06b87c86045bbb62b687d5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/407136
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-05-19 15:32:36 +00:00
Bryan C. Mills
9bc544a158 misc/cgo: invoke "go" from $GOROOT/bin instead of $PATH
If PATH doesn't contain GOROOT/bin as the first element, this could
otherwise end up running entirely the wrong command (and from the
wrong GOROOT, even).

I pre-tested this change on release-branch.go1.17 using a gomote.
I believe that it will fix the test failure on that branch,
but will need to be backported.

For #52995.

Change-Id: Ib0c43289a1e0ccf9409f0f0ef8046501a955ce65
Reviewed-on: https://go-review.googlesource.com/c/go/+/407294
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 15:04:11 +00:00
Michael Anthony Knyszek
b93ceefa7b runtime: use osyield in runqgrab on netbsd
NetBSD appears to have the same issue OpenBSD had in runqgrab. See
issue #52475 for more details.

For #35166.

Change-Id: Ie53192d26919b4717bc0d61cadd88d688ff38bb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/407139
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-05-19 14:18:41 +00:00
Joel Sing
128279e503 cmd/compile: regenerate ssa
This is the result of running `go run *.go` in src/cmd/compile/internal/ssa/gen,
which should be a no-op - it would seem that it may not have been regenerated
before CL 367039 landed.

Updates #46229

Change-Id: I4d6b6e8425948429ede509682c7e997edbb905e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/406474
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
2022-05-19 07:13:47 +00:00
Xiaodong Liu
740b0ebb76 runtime: implement asyncPreempt for linux/loong64
Contributors to the loong64 port are:
  Weining Lu <luweining@loongson.cn>
  Lei Wang <wanglei@loongson.cn>
  Lingqin Gong <gonglingqin@loongson.cn>
  Xiaolin Zhao <zhaoxiaolin@loongson.cn>
  Meidan Li <limeidan@loongson.cn>
  Xiaojuan Zhai <zhaixiaojuan@loongson.cn>
  Qiyuan Pu <puqiyuan@loongson.cn>
  Guoqi Chen <chenguoqi@loongson.cn>

This port has been updated to Go 1.15.6:
  https://github.com/loongson/go

Updates #46229

Change-Id: I7a64e38b15a99816bd74262c02f62dad021cc166
Reviewed-on: https://go-review.googlesource.com/c/go/+/368078
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-19 02:40:14 +00:00
Cherry Mui
c087121daf runtime: relax the threshold for TestPingPongHog
The test checks that the scheduling of the goroutines are within
a small factor, to ensure the scheduler handing off the P
correctly. There have been flaky failures on the builder (probably
due to OS scheduling delays). Increase the threshold to make it
less flaky. The gap would be much bigger if the scheduler doesn't
work correctly.

For the long term maybe it is better to test it more directly
with the scheduler, e.g. with scheduler instrumentation.

May fix #52207.

Change-Id: I50278b70ab21b7f04761fdc8b38dd13304c67879
Reviewed-on: https://go-review.googlesource.com/c/go/+/407134
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-18 19:52:53 +00:00
Tatiana Bradley
fe4de36198 crypto/tls: randomly generate ticket_age_add
As required by RFC 8446, section 4.6.1, ticket_age_add now holds a
random 32-bit value. Before this change, this value was always set
to 0.

This change also documents the reasoning for always setting
ticket_nonce to 0. The value ticket_nonce must be unique per
connection, but we only ever send one ticket per connection.

Fixes #52814
Fixes CVE-2022-30629

Change-Id: I6c2fc6ca0376b7b968abd59d6d3d3854c1ab68bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/405994
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Tatiana Bradley <tatiana@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-05-18 18:30:03 +00:00
Cherry Mui
1c77137d4f cmd/compile: do not use special literal assignment if LHS is address-taken
A composite literal assignment

x = T{field: v}

may be compiled to

x = T{}
x.field = v

We already do not use this form is RHS uses LHS. If LHS is
address-taken, RHS may uses LHS implicitly, e.g.

v = &x.field
x = T{field: *v}

The lowering above would change the value of RHS (*v).

Fixes #52953.

Change-Id: I3f798e00598aaa550b8c17182c7472fef440d483
Reviewed-on: https://go-review.googlesource.com/c/go/+/407014
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-05-18 18:24:59 +00:00
Volker dobler
4ba114ec05 net/http/cookiejar: allow cookies with an IP address in the domain attribute
A set domain attribute in a cookie in a Set-Cookie header is intended to
create a domain cookie, i.e. a cookie that is not only sent back to the
domain the Set-Cookie was received from, but to all subdomains thereof
too. Sometimes people set this domain attribute to an IP address. This
seems to be allowed by RFC 6265 albeit it's not really sensible as there
are no "subdomains" of an IP address.
Contemporary browsers allow such cookies, currently Jar forbids them.

This CL allows to persist such cookies in the Jar and send them back
again in subsequent requests. Jar allows those cookies that all
contemporary browsers allow (not all browsers behave the same and none
seems to conform to RFC 6265 in regards to these cookies, see below).

The following browsers in current version) were tested:
  - Chrome (Mac and Windows)
  - Firefox (Mac and Windows)
  - Safari (Mac)
  - Opera (Mac)
  - Edge (Windows)
  - Internet Explorer (Windows)
  - curl (Mac, Linux)

All of them allow a cookie to be set via the following HTTP header if
the request was made to e.g. http://35.206.97.83/ :

    Set-Cookie: a=1; domain=35.206.97.83

They differ in handling a leading dot "." before the IP address as in

    Set-Cookie: a=1; domain=.35.206.97.83

sets a=1 only in curl and in Internet Explorer, the other browsers just
reject such cookies.

As far as these internals can be observed the browsers do not treat such
cookies as domain cookies but as host cookies. RFC 6265 would require to
treat them as domain cookies; this is a) nonsensical and b) doesn't make
an observable difference. As we do not expose Jar entries and their
HostOnly flag it probably is still okay to claim that Jar implements a
RFC 6265 cookie jar.

RFC 6265 would allow cookies with dot-prefixed domains like
domain=.35.206.97.83 but it seems as if this feature of RFC 6265 is not
used in real life and not requested by users of package cookiejar (probably
because it doesn't work in browsers) so we refrain from documenting this
detail.

Fixes #12610

Change-Id: Ibd883d85bde6b958b732cbc3618a1238ac4fc84a
Reviewed-on: https://go-review.googlesource.com/c/go/+/326689
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-05-18 18:15:37 +00:00