summaryrefslogtreecommitdiff
path: root/src/syscall/syscall_linux_arm.go
Commit message (Collapse)AuthorAgeFilesLines
* syscall: add race annotations to Pread and PwriteIan Lance Taylor2022-03-121-2/+2
| | | | | | | | | | | 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>
* syscall: remove accept on LinuxTobias Klauser2022-03-021-1/+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-151-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: implement Pipe using pipe2 syscall on all linux platformsTobias Klauser2021-09-171-26/+0
| | | | | | | | | | | | | | | | | | | | | Most architectures currently already implement Pipe using the pipe2 syscall. Only 386, amd64 and mips{,le} still use the pipe syscall. However, some systems (e.g. Android seccomp policies) block that syscall, see #40828 for an example. The pipe2 syscall was added in Linux kernel version 2.6.27. The minimum required Linux kernel version for Go 1.18 will be changed to 2.6.32 per #45964 so it is possible to unify the implementation of Pipe using the pipe2 syscall. For #45964 Change-Id: I8ed6a391300c95f3107b4ec6b27d320e42fb535b Reviewed-on: https://go-review.googlesource.com/c/go/+/350530 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>
* syscall: drop fallback to pipe in Pipe on linux/armTobias Klauser2021-09-091-4/+0
| | | | | | | | | | | | | | | | | Follow-up for CL 346789 The minimum required Linux kernel version for Go 1.18 will be changed to 2.6.32, see #45964. The pipe2 syscall was added in 2.6.27, so the fallback to use pipe in Pipe on linux/arm can be removed. For #45964 Change-Id: I8b18244ca1f849f10e90565b4fef80ce777fef69 Reviewed-on: https://go-review.googlesource.com/c/go/+/347349 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>
* syscall: implement rawVforkSyscall for remaining linux platformsJoel Sing2021-03-031-3/+1
| | | | | | | | | | | | | | | This allows the use of CLONE_VFORK and CLONE_VM for fork/exec, preventing 'fork/exec ...: cannot allocate memory' failures from occuring when attempting to execute commands from a Go process that has a large memory footprint. Additionally, this should reduce the latency of fork/exec on these platforms. Fixes #31936 Change-Id: I4e28cf0763173145cacaa5340680dca9ff449305 Reviewed-on: https://go-review.googlesource.com/c/go/+/295849 Trust: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* syscall: handle undefined r2 value on linux-ppc64xAndrew G. Morgan2020-10-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | This change fixes two failng tests on linux-ppc64x: - TestAllThreadsSyscall() exposed a real bug in the ppc64x support: - It turns out that the r2 syscall return value is not defined on all architectures. Notably linux-ppc64x so address that by introducing a private architectural constant in the syscall package, archHonorsR2: true if r2 has a determanistic value. - TestSetuidEtc() was sensitive to /proc/<PID>/status content: - The amount of padding space has changed with kernel vintage. - Stress testing revealed a race with /proc files disappearing. Fixes #42178 Change-Id: Ie6fc0b8f2f94a409ac0e5756e73bfce113274709 Reviewed-on: https://go-review.googlesource.com/c/go/+/266202 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
* syscall: support POSIX semantics for Linux syscallsAndrew G. Morgan2020-10-231-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds two new methods for invoking system calls under Linux: syscall.AllThreadsSyscall() and syscall.AllThreadsSyscall6(). These system call wrappers ensure that all OSThreads mirror a common system call. The wrappers serialize execution of the runtime to ensure no race conditions where any Go code observes a non-atomic OS state change. As such, the syscalls have higher runtime overhead than regular system calls, and only need to be used where such thread (or 'm' in the parlance of the runtime sources) consistency is required. The new support is used to enable these functions under Linux: syscall.Setegid(), syscall.Seteuid(), syscall.Setgroups(), syscall.Setgid(), syscall.Setregid(), syscall.Setreuid(), syscall.Setresgid(), syscall.Setresuid() and syscall.Setuid(). They work identically to their glibc counterparts. Extensive discussion of the background issue addressed in this patch can be found here: https://github.com/golang/go/issues/1435 In the case where cgo is used, the C runtime can launch pthreads that are not managed by the Go runtime. As such, the added syscall.AllThreadsSyscall*() return ENOTSUP when cgo is enabled. However, for the 9 syscall.Set*() functions listed above, when cgo is active, these functions redirect to invoke their C.set*() equivalents in glibc, which wraps the raw system calls with a nptl:setxid fixup mechanism. This achieves POSIX semantics for these functions in the combined Go and C runtime. As a side note, the glibc/nptl:setxid support (2019-11-30) does not extend to all security related system calls under Linux so using native Go (CGO_ENABLED=0) and these AllThreadsSyscall*()s, where needed, will yield more well defined/consistent behavior over all threads of a Go program. That is, using the syscall.AllThreadsSyscall*() wrappers for things like setting state through SYS_PRCTL and SYS_CAPSET etc. Fixes #1435 Change-Id: Ib1a3e16b9180f64223196a32fc0f9dce14d9105c Reviewed-on: https://go-review.googlesource.com/c/go/+/210639 Trust: Emmanuel Odeke <emm.odeke@gmail.com> Trust: Ian Lance Taylor <iant@golang.org> Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Austin Clements <austin@google.com>
* syscall: avoid dup2 in forkAndExecInChild1 on AndroidElias Naur2020-05-281-4/+1
| | | | | | | | | | Android O and newer blocks the dup2 syscall. Change-Id: Ibca01fc72ef114deeef6c0450a8b81a556ed0530 Reviewed-on: https://go-review.googlesource.com/c/go/+/235537 Run-TryBot: Elias Naur <mail@eliasnaur.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: don't use deprecated syscalls on linux/arm64Tobias Klauser2019-10-081-1/+6
| | | | | | | | | | | | | Reimplement syscall wrappers for linux/arm64 in terms of supported syscalls (or in case of Ustat make it return ENOSYS) and remove the manually added SYS_* consts for the deprecated syscalls. Adapted from golang.org/x/sys/unix where this is already done since CL 119655. Change-Id: I94ab48a4645924df3822497d0575f1a1573d509f Reviewed-on: https://go-review.googlesource.com/c/go/+/199140 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: move Renameat to syscall_linux_$GOARCH.goTobias Klauser2019-08-281-0/+1
| | | | | | | | | | | | | | | On linux/riscv64, the renameat syscall no longer exists and has been superseded by renameat2. Thus we'll have to use Renameat2 to implement Renameat on linux/riscv64 for #27532. Prepare for this by moving the Renameat definition to the GOARCH specific files. Follow CL 157899 which did the same for golang.org/x/sys/unix Change-Id: I9670213cc3987df48fee962ddee36915a7785560 Reviewed-on: https://go-review.googlesource.com/c/go/+/192077 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: on ARM GNU/Linux let Pipe fall back to pipeIan Lance Taylor2019-03-051-0/+6
| | | | | | | | | | | | | | Android O seems to require Pipe to call the pipe2 system call. But kernel version 2.6.23 only supports pipe, not pipe2. So try pipe2 first, then fall back to pipe. Fixes #30549 Change-Id: I3c5d86e8e945a5ec8a0ecea7853302952c0476c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/165217 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: replace lstat, lchown, stat to please Android OElias Naur2018-09-241-3/+12
| | | | | | | | | | | | | | | | | | | | Implement Lstat with fstatat and Lchown with Fchownat on linux/amd64, linux/arm and linux/386. Furthermore, implement Stat with fstatat on linux/arm and linux/386. Linux/arm64 already had similar replacements. The fstatat and fchownat system calls were added in kernel 2.6.16, which is before the Go minimum, 2.6.23. The three syscalls then match the android bionic implementation and avoids the Android O seccomp filter. Fixes #27797 Change-Id: I07fd5506955d454a1a660fef5af0e1ac1ecb0959 Reviewed-on: https://go-review.googlesource.com/136795 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: support Faccessat flags argumentIan Lance Taylor2018-07-271-0/+1
| | | | | | | | | | | | | | | | | | The Linux kernel faccessat system call does not take a flags parameter. The flag parameter to the C library faccessat function is implemented in C. The syscall.Faccessat function takes a flags parameter. In older releases we have passed the flags parameter to the kernel, which ignored it. In CL 120015 we started returning an error if any flags were set. That seems clearly better than ignoring them, but it turns out that some code was using the flags. The code was previously subtly broken. Now it is obviously broken. That is better, but we can do better still: we can implement the flags as the C library does. That is what this CL does. Change-Id: I259bd6f240c3951e939b81c3032dead3d9c567b4 Reviewed-on: https://go-review.googlesource.com/126415 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: fix EpollWait for arm64Wei Xiao2018-06-041-0/+1
| | | | | | | | | | | | The SYS_EPOLL_WAIT syscall doesn't exist on arm64. This CL implements EpollWait with SYS_EPOLL_PWAIT syscall. Change-Id: Ica9107a58d7da45351fe2e900f59bec5b7b18f39 Reviewed-on: https://go-review.googlesource.com/115735 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: use SYS_GETDENTS64 on linux/mips64{,le}Tobias Klauser2018-01-311-1/+0
| | | | | | | | | | | | | | | | | | | | The getdents64 syscall is only available for mips64/mips64le starting with Linux kernel 3.10. Since mips64le requires at least 4.8 according to [1] (regarding #16848) using it should be fine. [1] https://golang.org/wiki/MinimumRequirements This CL changes the binary layout of type Dirent for mips64/mips64le, but not the public API. But since the currently used layout doesn't match the struct linux_dirent returned by the getdents syscall this should be fine as well. Fixes #23624 Change-Id: Iaa7306fa6e4442ad2fed41c60b37627a7314f117 Reviewed-on: https://go-review.googlesource.com/91055 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
* syscall: use CLONE_VFORK and CLONE_VMRichard Musiol2017-03-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This greatly improves the latency of starting a child process when the Go process is using a lot of memory. Even though the kernel uses copy-on-write, preparation for that can take up to several 100ms under certain conditions. All other goroutines are suspended while starting a subprocess so this latency directly affects total throughput. With CLONE_VM the child process shares the same memory with the parent process. On its own this would lead to conflicting use of the same memory, so CLONE_VFORK is used to suspend the parent process until the child releases the memory when switching to to the new program binary via the exec syscall. When the parent process continues to run, one has to consider the changes to memory that the child process did, namely the return address of the syscall function needs to be restored from a register. A simple benchmark has shown a difference in latency of 16ms vs. 0.5ms at 10GB memory usage. However, much higher latencies of several 100ms have been observed in real world scenarios. For more information see comments on #5838. Fixes #5838 Change-Id: I6377d7bd8dcd00c85ca0c52b6683e70ce2174ba6 Reviewed-on: https://go-review.googlesource.com/37439 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* syscall: delete the "use" function and calls in non-generated files.Sameer Ajmani2017-02-131-1/+0
| | | | | | | | | | | Delete use stub from asm.s, leaving only a dummy file. Deleting the file causes Windows build to fail. Fixes #16607 Change-Id: Ic5a55e042e588f1e1bc6605a3d309d1eabdeb288 Reviewed-on: https://go-review.googlesource.com/36716 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: for ForkExec on Linux, always use 32-bit setgroups system callRuss Cox2016-10-191-2/+3
| | | | | | | | Fixes #17092. Change-Id: If203d802a919e00594ddc1282782fc59a083fd63 Reviewed-on: https://go-review.googlesource.com/31458 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: unify NsecToTime{spec,val}, fix for times < 1970Ian Lance Taylor2016-10-121-9/+4
| | | | | | | | | | | | | | | | | | | All the implementations of NsecToTimespec and NsecToTimeval were the same other than types. Write a single version that uses GOARCH/GOOS-specific setTimespec and setTimeval functions to handle the types. The logic in NsecToTimespec and NsecToTimeval caused times before 1970 to have a negative usec/nsec. The Linux kernel requires that usec contain a positive number; for consistency, we do this for both NsecToTimespec and NsecToTimeval. Change-Id: I525eaba2e7cdb00cb57fa00182dabf19fec298ae Reviewed-on: https://go-review.googlesource.com/30826 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* syscall: unify TimespecToNsec and TimevalToNsecIan Lance Taylor2016-10-111-2/+0
| | | | | | | | | | All implementations of these functions are identical. Change-Id: I7cbea53c02bb0cee75e30beed19d29ba0a7ef657 Reviewed-on: https://go-review.googlesource.com/30819 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: make Getpagesize return page size from runtimeAustin Clements2016-09-061-2/+0
| | | | | | | | | | | | | | | | syscall.Getpagesize currently returns hard-coded page sizes on all architectures (some of which are probably always wrong, and some of which are definitely not always right). The runtime now has this information, queried from the OS during runtime init, so make syscall.Getpagesize return the page size that the runtime knows. Updates #10180. Change-Id: I4daa6fbc61a2193eb8fa9e7878960971205ac346 Reviewed-on: https://go-review.googlesource.com/25051 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: added support for linux/mips64{,le}Yao Zhang2015-11-121-1/+4
| | | | | | | | | | | Syscall getdents64 is relatively new in linux/mips64, only since kernel version 3.10. To support older kernel, syscall getdents is used for mips64. Change-Id: I892b05dff7d93e7ddb0d700abd6a5e6d4084ab4c Reviewed-on: https://go-review.googlesource.com/14449 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
* syscall: fix InotifyInit on linux/arm64Shenghou Ma2015-05-091-0/+1
| | | | | | | | | | | There is no SYS_INOTIFY_INIT on linux/arm64, only SYS_INOTIFY_INIT1. Change-Id: I97f430f2c2b910fb19dce495ff1adf591b8634fc Reviewed-on: https://go-review.googlesource.com/9870 Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
* syscall: change Dup,Dup2,Dup3 to use Syscall, not RawSyscallIan Lance Taylor2015-03-261-1/+1
| | | | | | | | | | | | | | | | | This avoids hanging when a Go program uses a FUSE filesystem and the dup system call has to close a file descriptor. When dup uses RawSyscall then the goroutine calling dup will occupy a scheduler slot (a p structure) during the call, and may block waiting for some other goroutine to respond to the close call on the FUSE filesystem. Changing to Syscall avoids the problem. This makes Dup a tiny bit slower but is quite unlikely to make a difference for any real programs. Fixes #10202. Change-Id: If6490a8f9b3c9cfed6acbfb4bfd1eaeac62ced17 Reviewed-on: https://go-review.googlesource.com/8095 Reviewed-by: Rob Pike <r@golang.org>
* syscall: exec_linux.go: support platforms without SYS_DUP2Dave Cheney2015-03-101-0/+2
| | | | | | | | | | | | | | | | | Updates #9974 This change is in preparation for merging the arm64 platform. Arm64 does not support SYS_DUP2 at all, so define a new constant to be the minimum dup(2) version supported. This constant defaults to SYS_DUP2 on all existing platforms. Change-Id: If405878105082c7c880f8541c1491970124c9ce4 Reviewed-on: https://go-review.googlesource.com/7123 Reviewed-by: Minux Ma <minux@golang.org> Run-TryBot: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
* syscall: Reimplement linux syscalls in terms of their *at replacements.Dave Cheney2015-02-261-1/+0
| | | | | | | | | | | | | | | | | | Updates #9974 This proposal tackles the body of syscalls which have been replaced, and are now deprecated in linux. This is needed for the arm64 port as arm64 is the first linux architecture to remove the "legacy" forms of these syscalls. The *AT variants were added in kernel 2.6.16, so well before our 2.6.23 cutoff (hey, it'll even work on RHEL5). Discussion: https://groups.google.com/forum/#!topic/golang-dev/zpeFtN2z5Fc Change-Id: I473a7c9a295d6f776fcdc75dcce06cbe9e3564ee Reviewed-on: https://go-review.googlesource.com/5837 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: split implementation of Dup2 per linux GOOSDave Cheney2015-02-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Updates #9974 This proposal moves the definition of Dup2 from the generic syscall_linux.go to the GOOS specific variants. This is in preparation for the arm64 port. For all existing platforms Dup2 is not affected. When arm64 is added we'll use either a forwarding method to Dup3 or //sysnb Dup2(oldfd int, newfd int) (err error) = SYS_DUP3 Because mksycall.pl does not sort symbols before generating the output file the diff includes some unavoidable code moves as Dup2 is processed latter in the run. Discussion: https://groups.google.com/forum/#!topic/golang-dev/zpeFtN2z5Fc Change-Id: Icdedf55bb29e749c4230e1ee371bf9d0bd0cfb38 Reviewed-on: https://go-review.googlesource.com/5835 Reviewed-by: Minux Ma <minux@golang.org> Run-TryBot: Dave Cheney <dave@cheney.net>
* syscall: split implementation of Pipe/Pipe2 per GOOSDave Cheney2015-02-251-0/+24
| | | | | | | | | | | | | | | | | | | | | | | Updates #9974 This proposal moves the definition of Pipe an Pipe2 from the generic syscall_linux.go to the GOOS specific variants. This is in preparation for the arm64 port. For platforms where pipe2(2) is not supported in the minimum 2.6.23 kernel, amd64 and 386, we retain pipe(2). For all other platforms pipe(2) is removed and Pipe forwards to pipe2(2). Because mksycall.pl does not sort symbols before generating the output file the diff includes some unavoidable code moves as Pipe and Pipe2 are processed latter in the run. Discussion: https://groups.google.com/forum/#!topic/golang-dev/zpeFtN2z5Fc Change-Id: Ie26d6761eeb9760dbaff974ee8bc0d57a9ceaee4 Reviewed-on: https://go-review.googlesource.com/5833 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: keep allocated C string live across call to SyscallRuss Cox2014-09-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given: p := alloc() fn_taking_ptr(p) p is NOT recorded as live at the call to fn_taking_ptr: it's not needed by the code following the call. p was passed to fn_taking_ptr, and fn_taking_ptr must keep it alive as long as it needs it. In practice, fn_taking_ptr will keep its own arguments live for as long as the function is executing. But if instead you have: p := alloc() i := uintptr(unsafe.Pointer(p)) fn_taking_int(i) p is STILL NOT recorded as live at the call to fn_taking_int: it's not needed by the code following the call. fn_taking_int is responsible for keeping its own arguments live, but fn_taking_int is written to take an integer, so even though fn_taking_int does keep its argument live, that argument does not keep the allocated memory live, because the garbage collector does not dereference integers. The shorter form: p := alloc() fn_taking_int(uintptr(unsafe.Pointer(p))) and the even shorter form: fn_taking_int(uintptr(unsafe.Pointer(alloc()))) are both the same as the 3-line form above. syscall.Syscall is like fn_taking_int: it is written to take a list of integers, and yet those integers are sometimes pointers. If there is no other copy of those pointers being kept live, the memory they point at may be garbage collected during the call to syscall.Syscall. This is happening on Solaris: for whatever reason, the timing is such that the garbage collector manages to free the string argument to the open(2) system call before the system call has been invoked. Change the system call wrappers to insert explicit references that will keep the allocations alive in the original frame (and therefore preserve the memory) until after syscall.Syscall has returned. Should fix Solaris flakiness. This is not a problem for cgo, because cgo wrappers have correctly typed arguments. LGTM=iant, khr, aram, rlh R=iant, khr, bradfitz, aram, rlh CC=dvyukov, golang-codereviews, r https://golang.org/cl/139360044
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+195
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.