aboutsummaryrefslogtreecommitdiff
path: root/src/os
AgeCommit message (Collapse)Author
2021-05-04[release-branch.go1.16] syscall: syscall.AllThreadsSyscall signal handling fixesAndrew G. Morgan
The runtime support for syscall.AllThreadsSyscall() functions had some corner case deadlock issues when signal handling was in use. This was observed in at least 3 build test failures on ppc64 and amd64 architecture CGO_ENABLED=0 builds over the last few months. The fixes involve more controlled handling of signals while the AllThreads mechanism is being executed. Further details are discussed in bug #44193. The all-threads syscall support is new in go1.16, so earlier releases are not affected by this bug. Fixes #45307 Change-Id: I01ba8508a6e1bb2d872751f50da86dd07911a41d Reviewed-on: https://go-review.googlesource.com/c/go/+/305149 Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 7e97e4e8ccdba9677f31ab9380802cd7613f62c5) Reviewed-on: https://go-review.googlesource.com/c/go/+/316869 Run-TryBot: Ian Lance Taylor <iant@golang.org>
2021-02-16internal/poll: if copy_file_range returns 0, assume it failedIan Lance Taylor
On current Linux kernels copy_file_range does not correctly handle files in certain special file systems, such as /proc. For those file systems it fails to copy any data and returns zero. This breaks Go's io.Copy for those files. Fix the problem by assuming that if copy_file_range returns 0 the first time it is called on a file, that that file is not supported. In that case fall back to just using read. This will force an extra system call when using io.Copy to copy a zero-sized normal file, but at least it will work correctly. For #36817 Fixes #44272 Change-Id: I02e81872cb70fda0ce5485e2ea712f219132e614 Reviewed-on: https://go-review.googlesource.com/c/go/+/291989 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-02-11io/fs: allow backslash in ValidPath, reject in os.DirFS.OpenRuss Cox
Rejecting backslash introduces problems with presenting underlying OS file systems that contain names with backslash. Rejecting backslash also does not Windows-proof the syntax, because colon can also be a path separator. And we are not going to reject colon from all names. So don't reject backslash either. There is a similar problem on Windows with names containing slashes, but those are more difficult (though not impossible) to create. Also document and enforce that paths must be UTF-8. Fixes #44166. Change-Id: Iac7a9a268025c1fd31010dbaf3f51e1660c7ae2a Reviewed-on: https://go-review.googlesource.com/c/go/+/290709 TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2021-01-26os: further document limitations around naked file descriptorsVictor Michel
NewFile requires the file descriptor to be either closed through the returned File instance, or to stay valid at least until the finalizer runs during garbage collection. These requirements are easily violated when file descriptors are closed via unix.Close, or when the *File returned by NewFile is garbage collected while the underlying file descriptor is still in use. This commit adds further documentation for NewFile and Fd, making it explicit that using naked file descriptors is subject to constraints due to garbage collection of File objects. Fixes #43863 Change-Id: I49ea1f0054eb2d2a72b616450c8e83476f4d07fb GitHub-Last-Rev: 180d0130ae9009456914fb265b4bafa0e599de0e GitHub-Pull-Request: golang/go#43867 Reviewed-on: https://go-review.googlesource.com/c/go/+/286032 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2021-01-26os: correct names in CreateTemp and MkdirTemp doc commentsIan Lance Taylor
For #42026 Change-Id: I51e3ce9d3a4729cfac44bd3ff3f3ec80dcd5abb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/285376 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-01-25os: force consistent mtime before running fstest on directory on WindowsJason A. Donenfeld
FindFileNext sometimes returns a different mtime than looking at the file directly, because the MFT on NTFS is written to lazily. In order to keep these in sync, we use GetFileInformationByHandle to get the actual mtime, and then write it back to the file explicitly. Fixes #42637. Change-Id: I774016d3ac55d0dc9b0f9c1b681516c33ba0d28a Reviewed-on: https://go-review.googlesource.com/c/go/+/285720 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-18os: do not close syscall.Stdin in TestReadStdinJason A. Donenfeld
By calling NewConsoleFile on syscall.Stdin, we wind up closing it when the function returns, which causes errors when all the tests are run in a loop. To fix this, we instead create a duplicate handle of stdin. Fixes #43720. Change-Id: Ie6426e6306c7e1e39601794f4ff48bbf2fe67502 Reviewed-on: https://go-review.googlesource.com/c/go/+/284140 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
2021-01-15os: invoke processKiller synchronously in testKillProcessBryan C. Mills
Previously, testKillProcess needlessly invoked processKiller in a separate goroutine and failed to wait for that goroutine to complete, causing the calls to t.Fatalf in that goroutine to potentially occur after the test function had already returned. Fixes #43722 Change-Id: I5d03cb24af51bb73f0ff96419dac57ec39776967 Reviewed-on: https://go-review.googlesource.com/c/go/+/284153 Trust: Bryan C. Mills <bcmills@google.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-08testing/fstest,os: clarify racy behavior of TestFSAustin Clements
The testing.TestFS function assumes that the file system it's testing doesn't change under it. Clarify this in the documentation and fix the use of os.TestDirFS that's currently susceptible to this race. Fixes #42637. Change-Id: Ia7792380726177f8953d150ee87381b66cb01cb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/282452 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-23os/signal: fix a deadlock with syscall.AllThreadsSyscall() useAndrew G. Morgan
The syscall.AllThreadsSyscall() fixup mechanism needs to cooperate with signal handling to ensure a notetsleepg() thread can wake up to run the mDoFixup() function. Fixes #43149 Change-Id: I6651b25bc44a4de47d3fb71d0293d51aef8b79c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/277434 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-18os: remove dependency on strings packageIan Lance Taylor
Historically the os package has not imported the strings package. That was enforced by go/build.TestDependencies, but that test was accidentally broken (#43249). A dependency of os on strings was accidentally added by CL 266364; remove it. For #42026 For #43249 Change-Id: If932308f30561fdcc5c608d7563e849c0d2870d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/279072 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-12-18os/signal: fix flaky tests for NotifyContext.Henrique Vicente
Test failures started to happen sporadically on some builds after the introduction of NotifyContext. To make these tests more robust and avoid the risk of crosstalk we run them in a separate process. Fixes #41561. Change-Id: Ia7af105c316afd11765358f1e5e253ccfe2adc2b Reviewed-on: https://go-review.googlesource.com/c/go/+/270198 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Bryan C. Mills <bcmills@google.com> Trust: Cherry Zhang <cherryyz@google.com>
2020-12-09all: update to use os.ReadDir where appropriateRuss Cox
os.ReadDir is a replacement for ioutil.ReadDir that returns a slice of fs.DirEntry instead of fs.FileInfo, meaning it is the more efficient form. This CL updates call sites throughout the Go source tree wherever possible. As usual, code built using the Go 1.4 bootstrap toolchain is not included. There is also a use in go/build that appears in the public API and can't be changed, at least not without additional changes. Fixes #42026. Change-Id: Icfc9dd52c6045020f6830e22c72128499462d561 Reviewed-on: https://go-review.googlesource.com/c/go/+/266366 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-04io/fs: add SubRuss Cox
Sub provides a convenient way to refer to a subdirectory automatically in future operations, like Unix's chdir(2). The CL also includes updates to fstest to check Sub implementations. As part of updating fstest, I changed the meaning of TestFS's expected list to introduce a special case: if you list no expected files, that means the FS must be empty. In general it's OK not to list all the expected files, but if you list none, that's almost certainly a mistake - if your FS were broken and empty, you wouldn't find out. Making no expected files mean "must be empty" makes the mistake less likely - if your file system ever worked, then your test will keep it working. That change found a testing bug: embedtest was making exactly that mistake. Fixes #42322. Change-Id: I63fd4aa866b30061a0e51ca9a1927e576d6ec41e Reviewed-on: https://go-review.googlesource.com/c/go/+/274856 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-02os: add ReadFile, WriteFile, CreateTemp (was TempFile), MkdirTemp (was ↵Russ Cox
TempDir) from io/ioutil io/ioutil was a poorly defined collection of helpers. Proposal #40025 moved out the generic I/O helpers to io. This CL for proposal #42026 moves the OS-specific helpers to os, making the entire io/ioutil package deprecated. For #42026. Change-Id: I018bcb2115ef2ff1bc7ca36a9247eda429af21ad Reviewed-on: https://go-review.googlesource.com/c/go/+/266364 Trust: Russ Cox <rsc@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-11-30os: return proper user directories on iOSChris Waldon
Separating iOS into its own runtime constant broke the logic here to derive the correct home, cache, and config directories on iOS devices. Fixes #42878 Change-Id: Ie4ff57895fcc34b0a9af45554ea3a346447d2e7a GitHub-Last-Rev: 5e74e64917fa46e9c6e0d963cab5194ab89e2f64 GitHub-Pull-Request: golang/go#42879 Reviewed-on: https://go-review.googlesource.com/c/go/+/273947 Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-11-30os/exec: constrain thread usage in leaked descriptor test on illumosJoshua M. Clulow
On illumos systems, libc can under some conditions make use of files from /proc. In the case of this test, the creation of new threads was (in the target thread) causing libc to open and close "/proc/self/lwp/5/lwpname" to set the thread name, which raced with the leaking descriptor check (see detailed analysis in #42431). This change requests that the Go runtime use less threads in the child process used to check for leaked descriptors, without just disabling the test. After a thousand repeated trials, the test no longer fails on illumos. Fixes #42431. Change-Id: Iefda26134fc91f7cb205754676e9845d9b7205cc Reviewed-on: https://go-review.googlesource.com/c/go/+/273966 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2020-11-12os: gofmtTobias Klauser
As reported by John Papandriopoulos, some parts of CL 216622 weren't properly formatted. Change-Id: I3a76abb6213bb17ef440036295c86d930703b456 Reviewed-on: https://go-review.googlesource.com/c/go/+/269218 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com> Trust: Alberto Donizetti <alb.donizetti@gmail.com> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-11-11os: clarify that IsExist and friends do not use errors.IsIan Lance Taylor
Fixes #41122 Change-Id: Ie5cb0b19ac461d321520b1ebfc493a0ca22232a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/268897 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-11-07os/exec: use "pfiles" for fd debugging on illumosJoshua M. Clulow
On illumos (and Solaris) systems, the native "pfiles" tool provides the best information about open file descriptors for a process: https://illumos.org/man/1/pfiles Use that instead of "lsof" when debugging file descriptor leaks. Updates #42431. Change-Id: If1250c4e6c9e8adbd076495a09fb1ce63abcc68b Reviewed-on: https://go-review.googlesource.com/c/go/+/268019 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-11-05os: remove unused variable in unix implementation of File.readdirBrad Fitzpatrick
Change-Id: I0dd8a325bce6ed12d1ec1dc206ded62398925aef Reviewed-on: https://go-review.googlesource.com/c/go/+/267758 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-11-04os: avoid nil returns from Readdirnames, Readdir, ReadDirRuss Cox
The refactoring of this code while adding ReadDir stopped pre-allocating a 100-entry slice for the results. That seemed like a good idea in general, since many directories have nowhere near 100 entries, but it had the side effect of returning a nil slice for an empty directory. Some “golden” tests that are too sensitive about nil vs not inside Google broke because Readdirnames(-1) was now returning nil instead of []string{} on an empty directory. It seems likely there are other such tests in the wild, and it doesn't seem worth breaking them. This commit restores the non-nil-ness of the old result, without restoring the excessive preallocation. Fixes #42367. Change-Id: I2be72030ac703346e859a97c2d4e456fadfce9b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/267637 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-11-03os: export ErrProcessDone variable in windows and plan9Alwin Doss
Exposes ErrProcessDone variable in windows and plan9 also returns this error code instead of errors.New("os: process already finished") Fixes #42311 Change-Id: Ie807b6526e7b6c27636e6bffe5ff0c904b319be4 GitHub-Last-Rev: 2153e0d7020d8ee9e94087d02977ea049b7fd6a0 GitHub-Pull-Request: golang/go#42313 Reviewed-on: https://go-review.googlesource.com/c/go/+/266997 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-10-31os: export errFinished as ErrProcessDoneColin Arnott
(*Process).Signal returns an error sentinel, previously errFinished, when (*Process).done or syscall.ESRCH. Callers would like the ability to test for this state, so the value has been exported as ErrProcessDone. Fixes #39444 Change-Id: I510e7647cc032af290180de5149f35ab7b09a526 Reviewed-on: https://go-review.googlesource.com/c/go/+/242998 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2020-10-28os: do not use procfs for os.Executable in dragonflyAntonio Huete Jimenez
procfs(5) is not always mounted in DragonFly BSD, for example during the binary package build with synth. os.Executable() consumers will then fail, we've spotted this when trying to build tinygo: [...] copying source files ./build/tinygo build-builtins -target=armv6m-none-eabi [...] panic: could not get executable path: readlink /proc/curproc/file: no such file or directory [...] Use KERN_PROC_PATHNAME as FreeBSD does. Change-Id: Ic65bea02cd0309fb24dec8ba8d2b151d1acde67b GitHub-Last-Rev: 083120a43b3158bb45d7e1a66fa32e3335a2d407 GitHub-Pull-Request: golang/go#36826 Reviewed-on: https://go-review.googlesource.com/c/go/+/216622 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20os: add DirFSRuss Cox
It will inevitably be important to be able to pass an operating system directory to code written to expect an fs.FS. os.DirFS provides the conversion. For #41190. Change-Id: Id1a8fcbe4c7a30de2c47dea0504e9481a88b1b39 Reviewed-on: https://go-review.googlesource.com/c/go/+/243911 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-10-20io/fs: add FS, File, ReadDirFile; move DirEntry from osRuss Cox
These are the core interfaces for the io/fs design. See #41190 and https://golang.org/s/draft-iofs-design for details. DirEntry was left behind in the previous move from os but is needed for ReadDirFile, so it moves in this commit. Also apply a couple comment changes suggested in the review of CL 261540. For #41190. Change-Id: I087741545139ed30b9ba5db728a0bad71129500b Reviewed-on: https://go-review.googlesource.com/c/go/+/243908 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-20all: update references to symbols moved from os to io/fsRuss Cox
The old os references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. For #41190. Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/243907 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-10-20io/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fsRuss Cox
First step of creating the new io/fs package. For #41190. Change-Id: I1339b1abdd533b0f1deab283628088b2f706fb5b Reviewed-on: https://go-review.googlesource.com/c/go/+/243906 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20os: use keyed literals for PathErrorRuss Cox
Necessary to move PathError to io/fs. For #41190. Change-Id: I05e87675f38a22f0570d4366b751b6169f7a1b13 Reviewed-on: https://go-review.googlesource.com/c/go/+/243900 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-20os: add File.ReadDir method and DirEntry typeRuss Cox
ReadDir provides a portable, efficient way to read a directory and discover the type of directory entries. This enables a more efficient file system walk, yet to be added. See #41467 for the proposal review for the API. Fixes #41467. Change-Id: I461a526793ae46df48821aa448b04f1705546739 Reviewed-on: https://go-review.googlesource.com/c/go/+/261540 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-10-19Revert "test: add regression test from #41474"Alberto Donizetti
This reverts CL 263097. Reason for revert: broke the noopt builder. Change-Id: Ie36d2c3ed9449b4425732072db624c8e18f965f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/263537 Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2020-10-17test: add regression test from #41474Alberto Donizetti
This issue was fixed with multiple individual compiler optimizations, each of which had their own respective test cases. This CL just adds the capstone test case to demonstrate that the issue has been fixed and doesn't regress again. Updates #41474. Change-Id: Iae752d4b0e7b83ee356b946843340a4fbc254058 Reviewed-on: https://go-review.googlesource.com/c/go/+/263097 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-12os: call f.Close before t.Fatal to avoid vet unreachable code warningsgzdaijie
Change-Id: Ic3f756ecf9b4fad8fb8c259e7dad6df894863b0e GitHub-Last-Rev: 303e524029289fb4c0cb114dad7cb03c4fce9637 GitHub-Pull-Request: golang/go#41900 Reviewed-on: https://go-review.googlesource.com/c/go/+/261217 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-09all: enable more tests on macOS/ARM64Cherry Zhang
On macOS, we can do "go build", can exec, and have the source tree available, so we can enable more tests. Skip ones that don't work. Most of them are due to that it requires external linking (for now) and some tests don't work with external linking (e.g. runtime deadlock detection). For them, helper functions CanInternalLink/MustInternalLink are introduced. I still want to have internal linking implemented, but it is still a good idea to identify which tests don't work with external linking. Updates #38485. Change-Id: I6b14697573cf3f371daf54b9ddd792acf232f2f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/260719 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-09-28os: fix SyscallConn typos in the File.Fd commentsChangkun Ou
This CL fixes two typos introduced in CL 256899. Change-Id: I47f0a3097deeeec8d6e9bbe7073fcf7a28c5dff9 Reviewed-on: https://go-review.googlesource.com/c/go/+/257997 Trust: Tobias Klauser <tobias.klauser@gmail.com> Trust: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-09-28os: remove ENOTSUP special case in Getwd on darwinTobias Klauser
ENOTSUP was used as a signaling error in the custom implementation of syscall.Getwd to fall back to the slow algorithm. Since CL 257637 Getwd directly calls the respective function from libSystem.dylib which can no longer return ENOTSUP. Change-Id: I8e65e42b3ea069bf78969a29f2af1c55552e2949 Reviewed-on: https://go-review.googlesource.com/c/go/+/257644 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-27os: document and emphasize a potential misuse of File.FdChangkun Ou
This CL revises the document of File.Fd that explicitly points its user to runtime.SetFinalizer where contains the information that a file descriptor could be closed in a finalizer and therefore causes a failure in syscall.Write if runtime.KeepAlive is not invoked. The CL also suggests an alternative of File.Fd towards File.SyscallConn. Fixes #41505 Change-Id: I6816f0157add48b649bf1fb793cf19dcea6894b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/256899 Reviewed-by: Rob Pike <r@golang.org> Trust: Ian Lance Taylor <iant@golang.org>
2020-09-23all: add GOOS=iosCherry Zhang
Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2020-09-22os: close fd if fd.Stat fails in GetwdTobias Klauser
Avoid leaking fd in case fd.Stat() fails in the fall back implementation of Getwd. Change-Id: I8656d42e8dbc8893b7159873f173d6bf0d4febe6 Reviewed-on: https://go-review.googlesource.com/c/go/+/256221 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2020-09-16os, internal/syscall/unix: use pipe2 instead of pipe on illumosTobias Klauser
Illumos provides the pipe2 syscall. Add a wrapper to internal/syscall/unix and use it to implement os.Pipe. Change-Id: I26ecdbcae1e8d51f80e2bc8a86fb129826387b1f Reviewed-on: https://go-review.googlesource.com/c/go/+/254981 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-15os/signal: add NotifyContext to cancel context using system signalsHenrique Vicente
Fixes #37255 Change-Id: Ic0fde3498afefed6e4447f8476e4da7c1faa7145 Reviewed-on: https://go-review.googlesource.com/c/go/+/219640 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Giovanni Bajo <rasky@develer.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-11os: implement File.Chmod on WindowsConstantin Konstantinidis
Fixes: #39606 Change-Id: I4def67ef18bd3ff866b140f6e76cdabe5d51a1c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/250077 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-08-27cmd/go, testing, os: fail test that calls os.Exit(0)Ian Lance Taylor
This catches cases where a test calls code that calls os.Exit(0), thereby skipping all subsequent tests. Fixes #29062 Change-Id: If9478972f40189e27623557e7141469ca4234d89 Reviewed-on: https://go-review.googlesource.com/c/go/+/250977 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-25os: return a *PathError from Readdirnames and Readdir on POSIX platformsBryan C. Mills
Previously, Readdirnames returned a *PathError on Windows and Plan 9, but a *SyscallError on POSIX systems. In contrast, similar methods (such as Stat) return a *PathError on all platforms. Fixes #38923 Change-Id: I26395905b1e723933f07b792c7aeee7c335949cd Reviewed-on: https://go-review.googlesource.com/c/go/+/233917 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-19os, internal/poll: loop on EINTR for all file syscallsIan Lance Taylor
When using a FUSE file system, any system call that touches the file system can return EINTR. Fixes #40846 Change-Id: I25d32da22cec08dea81ab297291a85ad72db2df7 Reviewed-on: https://go-review.googlesource.com/c/go/+/249178 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-07-08runtime: mark OpenBSD raise function nosplitIan Lance Taylor
It is called by the signal handler before switching to gsignal (sigtrampgo -> sigfwdgo -> dieFromSignal -> raise) which means that it must not split the stack. All other instances of raise are already marked nosplit. Fixes #40076 Change-Id: I4794491331af48c46d0d8ebc82d34c6483f0e6cd Reviewed-on: https://go-review.googlesource.com/c/go/+/241121 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-07-08os: fix regression with handling of nil *FileJoe Tsai
Use of a nil *File as an argument should not result in a panic, but result in the ErrInvalid error being returned. Fix the copy_file_range implementation to preserve this semantic. Fixes #40115 Change-Id: Iad5ac39664a3efb7964cf55685be636940a8db13 Reviewed-on: https://go-review.googlesource.com/c/go/+/241417 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>