summaryrefslogtreecommitdiffstats
path: root/libgo/runtime
Commit message (Collapse)AuthorAgeFilesLines
* runtime: Check for CPU_COUNT itself, don't check glibc version.ian2014-10-031-1/+1
| | | | | | | Fixes issue 38. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@215831 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Don't get confused if m changes during runtime_gc.ian2014-08-151-0/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@214047 138bc75d-0d04-0410-961f-82ee72b054a4
* compiler, runtime: Fix unexpected GC interfering with closure passing.ian2014-08-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | The Go frontend passes closures through to functions using the functions __go_set_closure and __go_get_closure. The expectation is that there are no function calls between set_closure and get_closure. However, it turns out that there can be function calls if some of the function arguments require type conversion to an interface type. Converting to an interface type can allocate memory, and that can in turn trigger a garbage collection, and that can in turn call pool cleanup functions that may call __go_set_closure. So the called function can see the wrong closure value, which is bad. This patch fixes the memory allocation function to preserve the closure value across any possible garbage collection. A test case is the libgo database/sql check run with the environment variable GOGC set to 1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@213933 138bc75d-0d04-0410-961f-82ee72b054a4
* PR other/61895ian2014-08-021-0/+12
| | | | | | | | | | | | | | | | | runtime: Ignore small argv[0] file for backtrace. Reportedly in some cases Docker starts processes with argv[0] pointing to an empty file. That would cause libgo to pass that empty file to libbacktrace, which would then fail to do any backtraces. Everything should work fine if libbacktrace falls back to /proc/self/exe. This patch to libgo works around the problem by ignoring argv[0] if it is a small file, or if stat fails. This is not a perfect fix but it's an unusual problem. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@213512 138bc75d-0d04-0410-961f-82ee72b054a4
* libgo/runtime: fix unused-result warningian2014-05-271-1/+2
| | | | | | | | | Result of runtime_write is ignored, causing an unused-result result warning (error in my case, with -Werror=unused-result). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@210986 138bc75d-0d04-0410-961f-82ee72b054a4
* PR go/60931ian2014-04-251-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | runtime: Fix garbage collector issue with non 4kB system page size The go garbage collector tracks memory in terms of 4kB pages. Most of the code checks getpagesize() at runtime and does the right thing. On a 64kB ppc64 box I see SEGVs in long running processes which has been diagnosed as a bug in scavengelist. scavengelist does a madvise(MADV_DONTNEED) without rounding the arguments to the system page size. A strace of one of the failures shows the problem: madvise(0xc211030000, 4096, MADV_DONTNEED) = 0 The kernel rounds the length up to 64kB and we mark 60kB of valid data as no longer needed. Round start up to a system page and end down before calling madvise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@209776 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix GC bug caused by Entersyscall modifying reg.ian2014-03-071-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes a rare but serious bug. The Go garbage collector only examines Go stacks. When Go code calls a function that is not written in Go, it first calls syscall.Entersyscall. Entersyscall records the position of the Go stack pointer and saves a copy of all the registers. If the garbage collector runs while the thread is executing the non-Go code, the garbage collector fetches the stack pointer and registers from the saved location. Entersyscall saves the registers using the getcontext function. Unfortunately I didn't consider the possibility that Entersyscall might itself change a register before calling getcontext. This only matters for callee-saved registers, as caller-saved registers would be visible on the saved stack. And it only matters if Entersyscall is compiled to save and modify a callee-saved register before it calls getcontext. And it only matters if a garbage collection occurs while the non-Go code is executing. And it only matters if the only copy of a valid Go pointer happens to be in the callee-saved register when Entersyscall is called. When all those conditions are true, the Go pointer might get collected incorrectly, leading to memory corruption. This patch tries to avoid the problem by splitting Entersyscall into two functions. The first is a simple function that just calls getcontext and then calls the rest of Entersyscall. This should fix the problem, provided the simple Entersyscall function does not itself modify any callee-saved registers before calling getcontext. That seems to be true on the systems I checked. But since the argument to getcontext is an offset from a TLS variable, it won't be true on a system which needs to save callee-saved registers in order to get the address of a TLS variable. I don't know why any system would work that way, but I don't know how to rule it out. I think that on any such system this will have to be implemented in assembler. I can't put the ucontext_t structure on the stack, because this function can not split stacks, and the ucontext_t structure is large enough that it could cause a stack overflow. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208390 138bc75d-0d04-0410-961f-82ee72b054a4
* libgo: Update to Go 1.2.1 release.ian2014-03-031-1/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208286 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Use a better heap location on arm64 systems.ian2014-02-211-3/+27
| | | | | | | | | | Before this, the heap location used on a 64-bit system was not available to user-space on arm64, so the "32-bit" strategy ended up being used. So use somewhere that is available, and for bonus points is far away from where the kernel allocates address space by default. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207977 138bc75d-0d04-0410-961f-82ee72b054a4
* PR go/59866ian2014-01-171-1/+1
| | | | | | | runtime: Force work variable in mgc0 to be aligned on 8-byte boundary. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206738 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: fix 32-bit malloc for pointers >= 0x80000000ian2014-01-093-24/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spans array is allocated in runtime_mallocinit. On a 32-bit system the number of entries in the spans array is MaxArena32 / PageSize, which (2U << 30) / (1 << 12) == (1 << 19). So we are allocating an array that can hold 19 bits for an index that can hold 20 bits. According to the comment in the function, this is intentional: we only allocate enough spans (and bitmaps) for a 2G arena, because allocating more would probably be wasteful. But since the span index is simply the upper 20 bits of the memory address, this scheme only works if memory addresses are limited to the low 2G of memory. That would be OK if we were careful to enforce it, but we're not. What we are careful to enforce, in functions like runtime_MHeap_SysAlloc, is that we always return addresses between the heap's arena_start and arena_start + MaxArena32. We generally get away with it because we start allocating just after the program end, so we only run into trouble with programs that allocate a lot of memory, enough to get past address 0x80000000. This changes the code that computes a span index to subtract arena_start on 32-bit systems just as we currently do on 64-bit systems. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206501 138bc75d-0d04-0410-961f-82ee72b054a4
* PR go/59433ian2014-01-081-16/+45
| | | | | | | net: Don't use stack space for fd_sets when using select. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206411 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Remove unused runtime_cpuid variables.ian2014-01-061-5/+0
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206353 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix defer of unlock thread at program startup.ian2013-12-126-5/+19
| | | | | | | | Don't free stack allocated defer block. Also ensure we have a Go context in a few more places before freeing the block. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205940 138bc75d-0d04-0410-961f-82ee72b054a4
* compiler, reflect, runtime: Implement method values in reflect.ian2013-12-121-0/+5
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205913 138bc75d-0d04-0410-961f-82ee72b054a4
* reflect, runtime: Let reflect.MakeFunc functions call recover.ian2013-12-114-2/+78
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205908 138bc75d-0d04-0410-961f-82ee72b054a4
* PR go/59408ian2013-12-061-0/+4
| | | | | | | runtime: Don't require g != m->g0 in sema notesleep. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205756 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Use pthread_sigmask instead of sigprocmask.ian2013-12-043-4/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205652 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix prototype and one use of runtime_traceback.ian2013-12-032-2/+2
| | | | | | | From Richard Biener. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205634 138bc75d-0d04-0410-961f-82ee72b054a4
* libgo: Avoid some cases of getting callers recursively.ian2013-12-013-0/+19
| | | | | | | | Avoids hanging inside older versions of glibc that do not support recurive calls to dl_iterate_phdr. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205561 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix handling of surrogate pairs in string([]rune).ian2013-11-261-0/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205422 138bc75d-0d04-0410-961f-82ee72b054a4
* syscall: Only call varargs libc functions from C code.ian2013-11-241-0/+47
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205321 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Update for change to libbacktrace library.ian2013-11-191-1/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205031 138bc75d-0d04-0410-961f-82ee72b054a4
* reflect: Handle calls to functions that take or return empty structsian2013-11-191-1/+4
| | | | | | | | | | | | Fixes issue 6761 This simple change seems to work fine, slightly to my surprise. This includes the tests I submitted to the main Go repository at https://codereview.appspot.com/26570046 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205001 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Use runtime_m to get m value after call to runtime_mcall.ian2013-11-151-1/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204853 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Don't use filename without '/' for backtrace library.ian2013-11-141-0/+7
| | | | | | | Fixes http://golang.org/issue/6715. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204828 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Add netpoll code that uses select.ian2013-11-146-2/+247
| | | | | | | Required for Solaris support. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204817 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix GC flag in when allocating memory from cgo.ian2013-11-141-1/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204815 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Correct flag (FlagNoGC => FlagNoInvokeGC).ian2013-11-091-1/+1
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204617 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fixes for Alpha.ian2013-11-072-1/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204551 138bc75d-0d04-0410-961f-82ee72b054a4
* libgo: Update to October 24 version of master library.ian2013-11-0646-1318/+2062
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204466 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix typo in dup3 fallback implementation.ian2013-10-181-1/+1
| | | | | | | From Uros Bizjak. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203820 138bc75d-0d04-0410-961f-82ee72b054a4
* syscall: Add Dup3, {Get,List,Remove,Set}xattr, {Get,Set}priority.ian2013-10-171-0/+57
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203788 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix build on systems without split stack.ian2013-10-161-0/+2
| | | | | | | From Uros Bizjak. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203703 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Don't clobber saved context when catching signal.ian2013-10-141-2/+3
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203577 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Report len out of range for large len when making slice.ian2013-10-111-1/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203401 138bc75d-0d04-0410-961f-82ee72b054a4
* compiler, runtime: Fix complex division of NaN / 0.ian2013-10-091-0/+46
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203331 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Do not report thunks and recover functions in backtrace.ian2013-10-091-0/+15
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203294 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix append of slice with elements of zero size.ian2013-10-021-6/+6
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203140 138bc75d-0d04-0410-961f-82ee72b054a4
* compiler, runtime: Use runtime functions to pass closure value.ian2013-09-035-20/+36
| | | | | | | | | | | | This changes the compiler and runtime to not pass a closure value as the last argument, but to instead pass it via __go_set_closure and retrieve it via __go_get_closure. This eliminates the need for function descriptor wrapper functions. It will make it possible to retrieve the closure value in a reflect.MakeFunc function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202233 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Handle allocating memory in cgo/SWIG function.ian2013-07-241-2/+19
| | | | | | | | | A function that returns an interface type and returns a value that requires memory allocation will try to allocate while appearing to be in a syscall. This patch lets that work. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201226 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Check _end rather than end to find end of program.ian2013-07-241-2/+2
| | | | | | | | | This fixes a problem on Solaris, where end is not defined in the main program but comes from some shared library. This only matters for 32-bit targets. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201220 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Move new 1.1.1 functions from thread-linux.c to runtime.c.ian2013-07-242-46/+47
| | | | | | | This way they are compiled on non-GNU/Linux systems. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201209 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Declare epoll_create1 if necessary.ian2013-07-231-0/+4
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201181 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Support cgo callbacks from threads started by C.ian2013-07-235-20/+131
| | | | | | | | | This adjusts the extram support to work with gccgo. There are some corresponding changes to cgo in https://codereview.appspot.com/11406047/ . git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201179 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Ignore SIGPROF if not on a Go thread.ian2013-07-231-6/+7
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201154 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime: Fix build on non-split-stack systems.ian2013-07-161-2/+6
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200983 138bc75d-0d04-0410-961f-82ee72b054a4
* libgo: Update to Go 1.1.1.ian2013-07-1639-1354/+4078
| | | | git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200974 138bc75d-0d04-0410-961f-82ee72b054a4
* compiler, runtime: Use function descriptors.ian2013-06-187-26/+55
| | | | | | | | | | | | | | | | This changes the representation of a Go value of function type from being a pointer to function code (like a C function pointer) to being a pointer to a struct. The first field of the struct points to the function code. The remaining fields, if any, are the addresses of variables referenced in enclosing functions. For each call to a function, the address of the function descriptor is passed as the last argument. This lets us avoid generating trampolines, and removes the use of writable/executable sections of the heap. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200181 138bc75d-0d04-0410-961f-82ee72b054a4
* runtime, testing/quick: libffi doesn't handle complex on Alpha.ian2013-03-011-1/+11
| | | | | | | From Uros Bizjak. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196389 138bc75d-0d04-0410-961f-82ee72b054a4
OpenPOWER on IntegriCloud