summaryrefslogtreecommitdiff
path: root/src/syscall
Commit message (Collapse)AuthorAgeFilesLines
* all: disable tests that fail on AlpineRuss Cox2022-08-021-0/+3
| | | | | | | | | | | | | | These changes are enough to pass all.bash using the disabled linux-amd64-alpine builder via debugnewvm. For #19938. For #39857. Change-Id: I7d160612259c77764b70d429ad94f0864689cdce Reviewed-on: https://go-review.googlesource.com/c/go/+/419995 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: gofmt after CL 412114Tobias Klauser2022-07-111-2/+2
| | | | | | | | | | | | Change-Id: Ie51545eaebd22a31379bf8814a2c62b91d1d105b Reviewed-on: https://go-review.googlesource.com/c/go/+/416934 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: clarify Pdeathsig documentation on LinuxVojtěch Boček2022-06-151-1/+5
| | | | | | | | | | | | | | | | This is a rather large footgun, so let's mention that it sends the signal on thread termination and not process termination in the documentation. Updates #27505 Change-Id: I489cf7136e34a1a7896067ae24187b0d523d987e GitHub-Last-Rev: c8722b25d1fb8b0b3696257ec7e955eb421f15a6 GitHub-Pull-Request: golang/go#53365 Reviewed-on: https://go-review.googlesource.com/c/go/+/412114 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> Reviewed-by: Cherry Mui <cherryyz@google.com>
* syscall, runtime/internal/syscall: always zero the higher bits of return ↵Guoqi Chen2022-06-151-1/+1
| | | | | | | | | | | | | | | value on linux/loong64 All loong64 syscalls return values only via R4/A0, and R5/A1 may contain unrelated content. Always zero the second return value. Change-Id: I62af59369bece5bd8028b937c74f4694150f7a55 Reviewed-on: https://go-review.googlesource.com/c/go/+/411615 Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Austin Clements <austin@google.com>
* syscall: remove unused setgroups on linux/loong64Tobias Klauser2022-06-082-11/+0
| | | | | | | | | | | | | | | Setgroups in syscall_linux.go already wraps the setgroups(2) syscall with correct POSIX semantics (ref. CL 210639). Change-Id: I961cd7c7fce1d70d23bf13cc82cad17854bbf40e Reviewed-on: https://go-review.googlesource.com/c/go/+/411214 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* syscall: remove unused accept on linux/loong64Tobias Klauser2022-06-072-12/+0
| | | | | | | | | | | | | | | | | | | | accept is no longer used on Linux since CL 346849 changed Accept to use accept4 only. This follows CL 386415 which already removed accept on all other Linux platforms before the linux/loong64 port was submitted. For #45964 Change-Id: I26945ff780e71174a0b0c2f5313c4bc1e1cbf786 Reviewed-on: https://go-review.googlesource.com/c/go/+/410737 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: update linux/loong64 kernel ABI, emulate fstatat with statxWANG Xuerui2022-05-267-1702/+1894
| | | | | | | | | | | | | | | | | | | | | | | | | The linux/loong64 kernel ABI has changed a little since the inception of the Go port; most notably fstat and fstatat are being removed [1], leaving only statx as the stat mechanism. Fortunately the structs are easy enough to translate, and we now exclusively use statx across the board on loong64 for best compatibility with past and future kernels (due to the architecture's young age, statx is always available). In wiring up the statx calls, it turned out the linux/loong64 syscall definitions were out-of-date, so the generation script received some tweaking as well. [1]: https://lore.kernel.org/all/20220518092619.1269111-1-chenhuacai@loongson.cn/ Change-Id: Ifebb9ab9fef783683e453fa331d623575e824a48 Reviewed-on: https://go-review.googlesource.com/c/go/+/407694 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Rakoczy <alex@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* syscall: add syscall support for linux/loong64Xiaodong Liu2022-05-209-3/+4709
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* all: gofmt main repoRuss Cox2022-05-191-0/+1
| | | | | | | | | | | | | | | | | 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>
* syscall: make //sys lines not doc commentsRuss Cox2022-05-195-0/+27
| | | | | | | | | | | | | 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>
* syscall: update broken linksIan Lance Taylor2022-05-101-3/+2
| | | | | | | | | | | | | | | Remove one link which isn't very interesting, and update another to point to the current location. Fixes #52753 Change-Id: I5f53ede35b0ded197bc0e6d41eabf28d736de5b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/405296 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* os, syscall: don't consider stderr output as part of hostnameDmitri Shuralyov2022-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | A successful invocation of the hostname command prints the hostname to stdout and exits with code 0. No part of the hostname is printed to stderr, so don't consider it. This avoids false positive failures in environments where hostname prints some extraneous information (such as performance warnings) to stderr, and makes the test a bit more robust. Fixes #52781. Change-Id: I46aa6fbf95b6616bacf9c2b5e412b0851b230744 Reviewed-on: https://go-review.googlesource.com/c/go/+/405014 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Jason Donenfeld <Jason@zx2c4.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* internal/poll, net, syscall: use accept4 on solarisTobias Klauser2022-05-033-24/+35
| | | | | | | | | | | | | | | Solaris supports accept4 since version 11.4, see https://docs.oracle.com/cd/E88353_01/html/E37843/accept4-3c.html Use it in internal/poll.accept like on other platforms. Change-Id: I3d9830a85e93bbbed60486247c2f91abc646371f Reviewed-on: https://go-review.googlesource.com/c/go/+/403394 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
* syscall: add //go:norace to RawSyscallMichael Pratt2022-04-281-0/+4
| | | | | | | | | | | | | | | RawSyscall is used in a variety of rather unsafe conditions, such as after fork in forkAndExecInChild1. Disable race instrumentation to avoid calling TSAN in unsafe conditions. For #51087 Change-Id: I47c35e6f0768c77ddab99010ea0404c45ad2f1da Reviewed-on: https://go-review.googlesource.com/c/go/+/402914 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
* syscall: define Syscall6 in terms of RawSyscall6 on linuxMichael Pratt2022-04-2210-242/+10
| | | | | | | | | | | | | This is an exact copy of CL 388478 after fixing #52472 in CL 401654. For #51087 For #52472 Change-Id: I6c6bd7ddcab1512c682e6b44f61c7bcde97f5c58 Reviewed-on: https://go-review.googlesource.com/c/go/+/401655 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* syscall: define Syscall in terms of RawSyscall on linuxMichael Pratt2022-04-2110-234/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a re-do of CL 388477, fixing #52472. It is unsafe to call syscall.RawSyscall from syscall.Syscall with -coverpkg=all and -race. This is because: 1. Coverage adds a sync/atomic call in RawSyscall to increment the coverage counter. 2. Race mode instruments sync/atomic calls with TSAN runtime calls. TSAN eventually calls runtime.racecallbackfunc, which expects getg().m.p != 0, which is no longer true after entersyscall(). cmd/go actually avoids adding coverage instrumention to package runtime in race mode entirely to avoid these kinds of problems. Rather than also excluding all of syscall for this one function, work around by calling RawSyscall6 instead, which avoids coverage instrumention both by being written in assembly and in package runtime/*. For #51087 Fixes #52472 Change-Id: Iaffd27df03753020c4716059a455d6ca7b62f347 Reviewed-on: https://go-review.googlesource.com/c/go/+/401654 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* Revert "syscall: define Syscall in terms of RawSyscall on linux"Michael Pratt2022-04-2110-22/+234
| | | | | | | | | | | | | | | This reverts CL 388477, which breaks cmd/go TestScript/cover_pkgall_runtime. For #51087. For #52472. Change-Id: Id58af419a889281f15df2471c58fece011fcffbc Reviewed-on: https://go-review.googlesource.com/c/go/+/401636 Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* Revert "syscall: define Syscall6 in terms of RawSyscall6 on linux"Michael Pratt2022-04-2110-10/+242
| | | | | | | | | | | | | | | This reverts CL 388478. Parent CL 388477 breaks cmd/go TestScript/cover_pkgall_runtime. For #51087. For #52472. Change-Id: Id5d5a4e138792cf130ecdcc6b996c8102d142a7e Reviewed-on: https://go-review.googlesource.com/c/go/+/401635 Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: define Syscall6 in terms of RawSyscall6 on linuxMichael Pratt2022-04-2110-242/+10
| | | | | | | | | | For #51087 Change-Id: I4a5b5cb74f12db8999c6ff0e98c3034b58af3959 Reviewed-on: https://go-review.googlesource.com/c/go/+/388478 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: define Syscall in terms of RawSyscall on linuxMichael Pratt2022-04-2110-234/+22
| | | | | | | | | | For #51087 Change-Id: I9de7e85ccf137ae73662759382334bcbe7208150 Reviewed-on: https://go-review.googlesource.com/c/go/+/388477 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: define RawSyscall in terms of RawSyscall6 on linuxMichael Pratt2022-04-2110-194/+21
| | | | | | | | | | For #51087 Change-Id: I63e07638507328efe33dbf7dd5f8a8b78890e037 Reviewed-on: https://go-review.googlesource.com/c/go/+/388476 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime/internal/syscall, syscall: replace RawSyscall6 with runtime ↵Michael Pratt2022-04-2110-209/+6
| | | | | | | | | | | | implementation on linux For #51087 Change-Id: I75a1bdeb5089454595f5ca04765a9c6e45cf9bd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/388475 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: move Syscall declarations to OS filesMichael Pratt2022-04-219-9/+42
| | | | | | | | | | | | | | Future CLs will be changing the provenance of these functions. Move the declarations to the individual OS files now so that future CLs can change only 1 OS at a time rather than changing all at once. For #51087 Change-Id: I5e1bca71e670263d8c0faa586c1b6b4de1a114b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/388474 Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: check correct group in FaccessatDamien Neil2022-04-121-1/+1
| | | | | | | | | | | | | | | | | | | The Faccessat call checks the user, group, or other permission bits of a file to see if the calling process can access it. The test to see if the group permissions should be used was made with the wrong group id, using the process's group id rather than the file's group id. Fix this to use the correct group id. No test since we cannot easily change file permissions when not running as root and the test is meaningless if running as root. For #52313 Change-Id: I4e2c84754b0af7830b40fd15dedcbc58374d75ee Reviewed-on: https://go-review.googlesource.com/c/go/+/399539 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: gofmt main repoRuss Cox2022-04-115-16/+17
| | | | | | | | | | | | | | | [This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* all: separate doc comment from //go: directivesRuss Cox2022-04-058-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | A future change to gofmt will rewrite // Doc comment. //go:foo to // Doc comment. // //go:foo Apply that change preemptively to all comments (not necessarily just doc comments). For #51082. Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/384260 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: fix various doc comment formatting nitsRuss Cox2022-04-011-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A run of lines that are indented with any number of spaces or tabs format as a <pre> block. This commit fixes various doc comments that format badly according to that (standard) rule. For example, consider: // - List item. // Second line. // - Another item. Because the - lines are unindented, this is actually two paragraphs separated by a one-line <pre> block. This CL rewrites it to: // - List item. // Second line. // - Another item. Today, that will format as a single <pre> block. In a future release, we hope to format it as a bulleted list. Various other minor fixes as well, all in preparation for reformatting. For #51082. Change-Id: I95cf06040d4186830e571cd50148be3bf8daf189 Reviewed-on: https://go-review.googlesource.com/c/go/+/384257 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: relax output check in TestGroupCleanupUserNamespaceBryan C. Mills2022-03-311-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | “If you have a procedure with ten parameters, you probably missed some.” ― attr. Alan J. Perlis I argue that the same is true for hard-coded special cases. In TestGroupCleanupUserNamespace, instead of a curated list of strings observed in the wild we now check for a prefix, as was done for TestGroupCleanup in CL 24670. Updates #16224. Updates #16303. Updates #19938. Updates #34547. Updates #46752. Fixes #52088. Change-Id: I59c5b0c048113e306996c0f8247e09c714d2423a Reviewed-on: https://go-review.googlesource.com/c/go/+/397316 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* all: use new "unix" build tag where appropriateIan Lance Taylor2022-03-299-9/+9
| | | | | | | | | | For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* syscall: optimize Byte{Ptr,Slice}FromStringKir Kolyshkin2022-03-281-4/+4
| | | | | | | | | | | | | | | | | | | | | Use bytealg.IndexByteString(str, 0) instead of looping through the string to check for a zero byte. A quick and dirty benchmark shows 10x performance improvement (on amd64 machine, using go 1.17.3). BytePtrFromString is used by many functions with string arguments. This change should make many functions in os package, such as those accepting a filename (os.Open, os.Stat, etc.), a tad faster. PS I am aware that syscall package is deprecated and frozen, but this change is mainly for the os package and the likes. The alternative would be for os to switch to x/sys, which is a much bigger change. Change-Id: I18fdd50f9fbfe0a23a4a71bc4bd0a5f5b0eaa475 Reviewed-on: https://go-review.googlesource.com/c/go/+/368457 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: use bytealg.IndexByte in clenTobias Klauser2022-03-181-4/+3
| | | | | | | | | | Change-Id: Ib3f92ea8371a13471acf9304dc9db66c0aae9bf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/393756 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Trust: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: unskip TestDirentRepeat on freebsdTobias Klauser2022-03-181-3/+0
| | | | | | | | | | | | | | | | | TestDirentRepeat fails on FreeBSD 11, but seems to pass on newer versions. Go 1.18 is the last release to support FreeBSD 11 per https://golang.org/doc/go1.18#freebsd and there are no FreeBSD 11 builders anymore. Thus unskip TestDirentRepeat to verify the issue is indeed fixed on FreeBSD 12 and later. For #31416 Change-Id: I189ef06719ff830ffe2e402c74a75874c9e5b97b Reviewed-on: https://go-review.googlesource.com/c/go/+/393618 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: optimize UTF16{,Ptr}FromStringTobias Klauser2022-03-181-4/+3
| | | | | | | | | | | | Use bytealg.IndexByteString in UTF16FromString instead of an open-coded loop. Change-Id: I366448382f2d0adeca6b254131e0087a1f489258 Reviewed-on: https://go-review.googlesource.com/c/go/+/393614 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: allow EINVAL in TestSCMCredentialsJosh Bleecher Snyder2022-03-171-2/+4
| | | | | | | | | | | This can occur on NixOS. Change-Id: I0571b0cc5345d01396dca6a4116aa1024c390a5a Reviewed-on: https://go-review.googlesource.com/c/go/+/393437 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: call ABI0 exitsyscall on Plan 9/AMD64Cherry Mui2022-03-171-4/+4
| | | | | | | | | | | | | | | | | | CL 376356 changes syscall.Syscall to call ABIInternal entersyscall and exitsyscall. As mentioned in the CL description, it is important to call entersyscall without ABI wrapper, but it is not important to call exitsyscall this way. In fact, it is actually problematic -- on Plan 9, syscall may clobber our fixed G register, and we did not restore it. This CL changes it back to ABI0 exitsyscall, which will restore the G register through the wrapper. Should fix Plan 9/AMD64 build. Change-Id: I1f03d553f03e7b9f36d64686f20f2b2df0a0bf79 Reviewed-on: https://go-review.googlesource.com/c/go/+/393494 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* syscall: ensure that Getwd returns absolute pathKir Kolyshkin2022-03-161-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Since Linux kernel 2.6.36, the pathname returned by the getcwd() system call can be prefixed with the string "(unreachable)" in some cases [1]. Getcwd should return an absolute path, and doing otherwise is a conformance issue; it also can be dangerous, since the path returned can be an existing relative path. Fix by returning ENOENT in case the path is not absolute. This is essentially the same as what glibc does (since [2]). [1] https://man7.org/linux/man-pages/man2/getcwd.2.html#BUGS [2] https://sourceware.org/git/?p=glibc.git;a=commit;h=52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94 Change-Id: I444c80eb3c836ff7d32c64c8b65d5112fa8c710f Reviewed-on: https://go-review.googlesource.com/c/go/+/387174 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: call ABIInternal entersyscall on register ABI platformsCherry Mui2022-03-1611-73/+72
| | | | | | | | | | | | | | | | | | | | | | Currently, when register ABI is used, syscall.Syscall calls entersyscall via a wrapper, so the actual entersyscall records the caller PC and SP of the wrapper. At the point of the actual syscall, the wrapper frame is gone, so the recorded PC and SP are technically invalid. Furthermore, in some functions on some platforms (e.g. Syscall9 on NetBSD/AMD64), that frame is overwritten. If we unwind the stack from the recorded syscallpc and syscallsp, it may go wrong. Fix this by calling the ABIInternal function directly. exitsyscall calls are changed as well. It doesn't really matter, just changed for consistency. Change-Id: Iead8dd22cf32b05e382414fef664b7c4c1719b7c Reviewed-on: https://go-review.googlesource.com/c/go/+/376356 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* syscall: add race annotations to Windows ReadFile and WriteFileIan Lance Taylor2022-03-152-24/+34
| | | | | | | | | | | | For #51618 Fixes #51673 Change-Id: Ie63408d62303293d80afed8d5cf1cb164a8abecc Reviewed-on: https://go-review.googlesource.com/c/go/+/392774 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: add race annotations to Pread and PwriteIan Lance Taylor2022-03-1246-106/+142
| | | | | | | | | | | Fixes #51618 Change-Id: Ife894d8c313dce8c4929f40fa0ac90a069f77a89 Reviewed-on: https://go-review.googlesource.com/c/go/+/391954 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
* runtime/pprof, syscall: report MaxRSS on all unix platformsTobias Klauser2022-03-114-0/+28
| | | | | | | | | | | | | | | All unix platforms currently supported by Go provide the getrusage syscall. On aix and solaris the Getrusage syscall wrapper is not available yet, so add and use it to report MaxRSS in memory profiles. Change-Id: Ie880a3058171031fd2e12ccf9adfb85ce18858b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/391434 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* runtime, syscall: implement syscall.Pipe using syscall.Pipe2 on solarisTobias Klauser2022-03-082-16/+1
| | | | | | | | | | | | | | All other platforms providing the pipe2 syscall already implement it that way. Do so as well on solaris, which allows to drop runtime.syscall_pipe and its dependencies as well. Change-Id: Icf04777f21d1804da74325d173fefdc87caa42eb Reviewed-on: https://go-review.googlesource.com/c/go/+/390716 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Trust: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: add Pipe2 on solaris and use it for forkExecPipeTobias Klauser2022-03-084-2/+30
| | | | | | | | | | | | Other platforms already define Pipe2, so add it for solaris as well. Change-Id: If0d2dfc9a3613479fb4611a673a20a4aa0af0b2b Reviewed-on: https://go-review.googlesource.com/c/go/+/390714 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Trust: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: use dup3 in forkAndExecInChild on OpenBSDTobias Klauser2022-03-0514-19/+101
| | | | | | | | | | | | | Use dup3(oldfd, newfd, O_CLOEXEC) to atomically duplicate the file descriptor and mark is as close-on-exec instead of dup2 & fcntl. The dup3 system call first appeared in OpenBSD 5.7. Change-Id: Ic06c2c7089dcdbd931ee24e5e8c316879d81474e Reviewed-on: https://go-review.googlesource.com/c/go/+/389974 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: remove TestRlimitIan Lance Taylor2022-03-041-27/+0
| | | | | | | | | | | | | | | It's more trouble than it's worth. New code should be using x/sys/unix anyhow. Fixes #40564 Fixes #51479 Change-Id: I1c0e13f494380c1565e98359f088af9f52790b79 Reviewed-on: https://go-review.googlesource.com/c/go/+/390020 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall, runtime/internal/syscall: always return 0 in r2 on ppc64{,le} linux ↵Paul E. Murphy2022-03-031-5/+5
| | | | | | | | | | | | | | | | | | | syscalls Both endians perform syscalls similarly. Only CR0S0 and R3 hold the resultant status of a syscall. A random value may be stored into the second return value (r2) result in some cases. Always set it to zero. Fixes #51192 Change-Id: Ida6a5692578d2cdadf3099af28478b3bc364f623 Reviewed-on: https://go-review.googlesource.com/c/go/+/385796 Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Trust: Paul Murphy <murp@ibm.com>
* syscall: remove accept on LinuxTobias Klauser2022-03-0219-133/+0
| | | | | | | | | | | | | | accept is no longer used on Linux since CL 346849 changed Accept to use accept4 only. For #45964 Change-Id: I72c13df1457016c4785ec13d356ab89cbca644b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/386415 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* runtime, syscall: reimplement AllThreadsSyscall using only signals.Michael Pratt2022-02-1511-135/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In issue 50113, we see that a thread blocked in a system call can result in a hang of AllThreadsSyscall. To resolve this, we must send a signal to these threads to knock them out of the system call long enough to run the per-thread syscall. Stepping back, if we need to send signals anyway, it should be possible to implement this entire mechanism on top of signals. This CL does so, vastly simplifying the mechanism, both as a direct result of newly-unnecessary code as well as some ancillary simplifications to make things simpler to follow. Major changes: * The rest of the mechanism is moved to os_linux.go, with fields in mOS instead of m itself. * 'Fixup' fields and functions are renamed to 'perThreadSyscall' so they are more precise about their purpose. * Rather than getting passed a closure, doAllThreadsSyscall takes the syscall number and arguments. This avoids a lot of hairy behavior: * The closure may potentially only be live in fields in the M, hidden from the GC. Not necessary with no closure. * The need to loan out the race context. A direct RawSyscall6 call does not require any race context. * The closure previously conditionally panicked in strange locations, like a signal handler. Now we simply throw. * All manual fixup synchronization with mPark, sysmon, templateThread, sigqueue, etc is gone. The core approach is much simpler: doAllThreadsSyscall sends a signal to every thread in allm, which executes the system call from the signal handler. We use (SIGRTMIN + 1), aka SIGSETXID, the same signal used by glibc for this purpose. As such, we are careful to only handle this signal on non-cgo binaries. Synchronization with thread creation is a key part of this CL. The comment near the top of doAllThreadsSyscall describes the required synchronization semantics and how they are achieved. Note that current use of allocmLock protects the state mutations of allm that are also protected by sched.lock. allocmLock is used instead of sched.lock simply to avoid holding sched.lock for so long. Fixes #50113 Change-Id: Ic7ea856dc66cf711731540a54996e08fc986ce84 Reviewed-on: https://go-review.googlesource.com/c/go/+/383434 Reviewed-by: Austin Clements <austin@google.com> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: use RLIMIT_CPU instead of RLIMIT_NOFILETamir Duberstein2022-02-091-17/+4
| | | | | | | | | | | | | | | | | The latter is subject to kern.maxfilelimit restrictions on darwin which are not reflected in the return value. This makes it difficult to reliably restore the default after the test is complete. RLIMIT_CPU should hopefully sidestep this problem. Updates #40564. Change-Id: Ifb33c7d46f2708130cef366dc245c643a2d5e465 Reviewed-on: https://go-review.googlesource.com/c/go/+/383234 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Bryan Mills <bcmills@google.com>
* syscall: in TestDirent, make as many ReadDirent calls as are neededBryan C. Mills2022-01-071-12/+27
| | | | | | | | | | | | | | | | | | | | ReadDirent returns only as many directory entries as will fit in the buffer, and each entry is variable-length — so we have no guarantee in general that a buffer of a given arbitrary size can hold even one entry, let alone all ten entries expected by the test. Instead, iterate calls to ReadDirent until one of the calls returns zero entries and no error, indicating that the directory has been read to completion. Fixes #37323 Change-Id: I7f1cedde7666107256604e4ea1ac13c71f22151a Reviewed-on: https://go-review.googlesource.com/c/go/+/376334 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: gofmt -w -r 'interface{} -> any' srcRuss Cox2021-12-136-27/+26
| | | | | | | | | | | | | | | | | | | | | | | | And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>