summaryrefslogtreecommitdiff
path: root/src/syscall/syscall.go
Commit message (Collapse)AuthorAgeFilesLines
* syscall: keep allocated C string live across call to SyscallRuss Cox2014-09-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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://codereview.appspot.com/139360044
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+88
| | | | | | 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.
* move src/syscall to src/lib/syscall.Russ Cox2008-09-261-28/+0
| | | | | | | | | | | enforce rule: all kernel data structures and constants go in syscall module. move things that should be in syscall out of net. make net a single package. R=r OCL=15985 CL=15994
* time & date.Russ Cox2008-09-171-1/+1
| | | | | | | | rename AddrToInt, StatToInt, etc -> BytePtr, StatPtr, ... R=r OCL=15450 CL=15456
* preliminary network - just Dial for nowRuss Cox2008-09-161-0/+1
| | | | | | R=r,presotto OCL=15393 CL=15399
* make syscall use strings for file namesRob Pike2008-09-111-0/+14
| | | | | | | | | | | | | | | | | | | | | | tweak os to adjust move StringToBytes into syscall, at least for now this program still works: package main import os "os" func main() { os.Stdout.WriteString("hello, world\n"); a, b := os.NewFD(77).WriteString("no way"); os.Stdout.WriteString(b.String() + "\n"); } R=rsc DELTA=263 (59 added, 176 deleted, 28 changed) OCL=15153 CL=15153
* - switched most of existing Go code to new export syntaxRobert Griesemer2008-08-041-6/+2
| | | | | | | | | - adjusted lang doc R=r DELTA=192 (26 added, 65 deleted, 101 changed) OCL=13844 CL=13848
* fix a commentRob Pike2008-07-291-4/+1
| | | | | | | | fix a register name R=gri OCL=13548 CL=13548
* rewrite system call interface to use less assembler.Rob Pike2008-07-291-6/+7
| | | | | | R=gri OCL=13546 CL=13546
* add lstatRob Pike2008-07-281-4/+4
| | | | | | | | | | clean up some code fix comments add paramter names to interface R=ken OCL=13521 CL=13521
* add fstat, statRob Pike2008-07-261-2/+6
| | | | | | R=ken OCL=13497 CL=13497
* beginnings of a low-level syscall libraryRob Pike2008-07-261-0/+15
R=ken OCL=13483 CL=13496