aboutsummaryrefslogtreecommitdiff
path: root/libgo
AgeCommit message (Collapse)AuthorFilesLines
2014-10-20compiler, runtime: Add type information to single object allocation.Ian Lance Taylor1-4/+8
From-SVN: r216490
2014-10-20reflect: allocate correct type in assignTo and cvtT2IIan Lance Taylor1-11/+11
Backport https://codereview.appspot.com/155450044 from the master Go library. Original description: I came across this while debugging a GC problem in gccgo. There is code in assignTo and cvtT2I that handles assignment to all interface values. It allocates an empty interface even if the real type is a non-empty interface. The fields are then set for a non-empty interface, but the memory is recorded as holding an empty interface. This means that the GC has incorrect information. This is extremely unlikely to fail, because the code in the GC that handles empty interfaces looks like this: obj = nil; typ = eface->type; if(typ != nil) { if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers)) obj = eface->data; In the current runtime the condition is always true--if KindDirectIface is set, then KindNoPointers is clear--and we always want to set obj = eface->data. So the question is what happens when we incorrectly store a non-empty interface value in memory marked as an empty interface. In that case eface->type will not be a *rtype as we expect, but will instead be a pointer to an Itab. We are going to use this pointer to look at a *rtype kind field. The *rtype struct starts out like this: type rtype struct { size uintptr hash uint32 // hash of type; avoids computation in hash tables _ uint8 // unused/padding align uint8 // alignment of variable with this type fieldAlign uint8 // alignment of struct field with this type kind uint8 // enumeration for C An Itab always has at least two pointers, so on a little-endian 64-bit system the kind field will be the high byte of the second pointer. This will normally be zero, so the test of typ->kind will succeed, which is what we want. On a 32-bit system it might be possible to construct a failing case by somehow getting the Itab for an interface with one method to be immediately followed by a word that is all ones. The effect would be that the test would sometimes fail and the GC would not mark obj, leading to an invalid dangling pointer. I have not tried to construct this test. I noticed this in gccgo, where this error is much more likely to cause trouble for a rather random reason: gccgo uses a different layout of rtype, and in gccgo the kind field happens to be the low byte of a pointer, not the high byte. From-SVN: r216489
2014-10-17configure: Quote some shell variables.Ian Lance Taylor2-16/+16
From Dominik Vogt. From-SVN: r216355
2014-10-16runtime: Don't create threads with a small stack.Ian Lance Taylor1-55/+0
We want to create goroutines with a small stack, at least on systems where split stacks are supported. We don't need to create threads with a small stack. From-SVN: r216353
2014-10-08re PR go/60406 (recover.go: test13reflect2 test failure)Ian Lance Taylor5-76/+195
PR go/60406 runtime: Check callers in can_recover if return address doesn't match. Also use __builtin_extract_return_address and tighten up the checks in FFI code. Fixes PR 60406. From-SVN: r216003
2014-10-03re PR go/61877 (reflect: cannot use []string as type string in Call)Ian Lance Taylor2-39/+97
PR go/61877 refect: fix direct call of variadic method value As reported in bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61877 gcc mainline has regressed in this. This CL adds the tests proposed for the main Go repository: https://codereview.appspot.com/151280043/ https://codereview.appspot.com/152060043/ restores the code from the amd64/386 path that makes this work and was lost when the Go 1.3 stdlib was merged and changes the FFI path to call into the same helper code as the amd64/386 path. I've only tested this on amd64 but I did test a version that was patched to unconditionally take the FFI path. From-SVN: r215859
2014-10-03runtime: Check for CPU_COUNT itself, don't check glibc version.Ian Lance Taylor1-1/+1
Fixes issue 38. From-SVN: r215832
2014-09-29libgo/configure: Use -Qunused-arguments for asm tests if supported.Ian Lance Taylor2-0/+61
This supports clang, which by default issues warnings about unused command line arguments, a habit that interacts poorly with configure scripts. From-SVN: r215699
2014-09-22runtime: Mark runtime_goexit function as noinline.Ian Lance Taylor1-0/+1
If the compiler inlines this function into kickoff, it may reuse the TLS block address to load g. However, this is not necessarily correct, as the call to g->entry in kickoff may cause the TLS address to change. If the wrong value is loaded for g->status in runtime_goexit, it may cause a runtime panic. By marking the function as noinline we prevent the compiler from reusing the TLS address. From-SVN: r215484
2014-09-20runtime: Restore copyright notice accidentally removed from mgc0.c.Ian Lance Taylor1-1/+1
From-SVN: r215423
2014-09-05runtime: Use the clone system call on GNU/Linux.Ian Lance Taylor1-2/+2
Without this we weren't supporting the standard Cloneflags field of SysProcAttr. From-SVN: r214972
2014-09-05runtime: Use correct size for unsafe.Pointer GC instructions.Ian Lance Taylor1-1/+1
From-SVN: r214965
2014-09-03compiler: Add precise type information on the heap.Chris Manghane6-60/+84
* go-gcc.cc (Gcc_backend::implicit_variable): Remove init parameter. Add is_hidden parameter. (Gcc_backend::implicit_variable_set_init): New method. (Gcc_backend::implicit_variable_reference): New method. From-SVN: r214894
2014-08-15runtime: Don't get confused if m changes during runtime_gc.Ian Lance Taylor1-0/+1
From-SVN: r214048
2014-08-13compiler, runtime: Fix unexpected GC interfering with closure passing.Ian Lance Taylor1-0/+8
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 problem in two different ways. First, we move all type conversions in function arguments into temporary variables so that they can not appear before the call to __go_set_closure. (This required shifting the flatten phase after the simplify_thunk phase, since the latter expects to work with unconverted argument types.) Second, we fix 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. From-SVN: r213932
2014-08-04runtime: Add casts to mincore call to compile on Solaris.Ian Lance Taylor1-1/+1
Based on patch from Rainer Orth. From-SVN: r213599
2014-08-02re PR other/61895 (libbacktrace crashes with bus error with empty file argv[0])Ian Lance Taylor1-0/+12
PR other/61895 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. From-SVN: r213513
2014-07-20runtime: remove unused variableIan Lance Taylor1-4/+3
This variable is unused apparently as a result of local changes. gccgo accepts this variable declaration, but other frontends may not. From-SVN: r212873
2014-07-20runtime: add a missing importIan Lance Taylor1-1/+1
This adds an import of the runtime package to fix compilation of the TestStopCPUProfilingWithProfilerOff function. The gccgo compiler should never have accepted this. The patch for the comiler is http://codereview.appspot.com/116960043 . The test is https://codereview.appspot.com/118000043 . From-SVN: r212870
2014-07-20runtime: also disable split stacks for runtime_snprintf function under ClangIan Lance Taylor1-0/+6
From-SVN: r212862
2014-07-19reflect, runtime: Use libffi closures to implement reflect.MakeFunc.Ian Lance Taylor18-408/+709
Keep using the existing 386 and amd64 code on those archs, since it is more efficient. From-SVN: r212853
2014-07-19libgo: Bump version number.Ian Lance Taylor2-2/+2
From-SVN: r212840
2014-07-19libgo: Update to Go 1.3 release.Ian Lance Taylor456-4836/+15264
From-SVN: r212837
2014-07-12runtime: Merge master revision 19185.Ian Lance Taylor25-561/+279
This revision renames several files in the runtime directory from .c to .goc. From-SVN: r212472
2014-07-11runtime: Rename iface.goc to go-iface.goc.Ian Lance Taylor3-4/+4
Rename in order to avoid confusion with the new runtime/iface.goc file in the Go library master sources. From-SVN: r212447
2014-07-11runtime: Drop reflectFlags tests.Ian Lance Taylor7-30/+0
The flags were used by the reflect package in the past, but not for a couple of years now. From-SVN: r212446
2014-07-02re PR go/61620 (FAIL: go.test/test/fixedbugs/bug242.go execution, -O2 -g)Ian Lance Taylor1-1/+3
PR go/61620 runtime: Don't free tiny blocks in map deletion. The memory allocator now has a special case for tiny blocks (smaller than 16 bytes) and they can not be explicitly freed. From-SVN: r212233
2014-07-01runtime: introduce build targets for running benchmarksIan Lance Taylor3-14/+44
This introduces the "bench" build target, which can be used to run all benchmarks. It is also possible to run subsets of benchmarks with the "package/check" build targets by setting GOBENCH to a matching regex. From-SVN: r212212
2014-06-24runtime: add missing benchmark input files to the repositoryIan Lance Taylor7-0/+0
From-SVN: r211961
2014-06-13re PR go/52583 (Several new go testsuite failues on Solaris)Ian Lance Taylor1-0/+26
PR go/52583 runtime: Stop backtrace at a few recognized functions. On x86_64 Solaris the makecontext function does not properly indicate that it is at the top of the stack. Attempting to unwind the stack past a call to makecontext tends to crash. This patch changes libgo to look for certain functions that are always found at the top of the stack, and to stop unwinding when it reaches one of those functions. There is never anything interesting past these functions--that is, there is never any code written by the user. From-SVN: r211640
2014-06-13re PR go/61498 (Many 64-bit Go tests SEGV in scanblock)Ian Lance Taylor1-5/+2
PR go/61498 runtime: Always set gcnext_sp to pointer-aligned address. The gcnext_sp field is only used on systems that do not use split stacks. It marks the bottom of the stack for the garbage collector. This change makes sure that the stack bottom is always aligned to a pointer value. Previously the garbage collector would align all the addresses that it scanned, but it now expects them to be aligned before scanning. From-SVN: r211639
2014-06-10runtime: Initialize variable to avoid compiler warning.Ian Lance Taylor1-1/+1
From-SVN: r211394
2014-06-06libgo: Merge to master revision 19184.Ian Lance Taylor319-6342/+11965
The next revision, 19185, renames several runtime files, and will be handled in a separate change. From-SVN: r211328
2014-06-04libgo: Merge from revision 18783:00cce3a34d7e of master library.Ian Lance Taylor222-7865/+9333
This revision was committed January 7, 2014. The next revision deleted runtime/mfinal.c. That will be done in a subsequent merge. This merge changes type descriptors to add a zero field, pointing to a zero value for that type. This is implemented as a common variable. * go-gcc.cc (Gcc_backend::implicit_variable): Add is_common and alignment parameters. Permit init parameter to be NULL. From-SVN: r211249
2014-05-30runtime: Use _mm_pause rather than __builtin_ia32_pause.Ian Lance Taylor1-1/+5
Based on a patch from Peter Collingbourne. From-SVN: r211081
2014-05-29runtime: add the --without-libatomic configure optionIan Lance Taylor5-9/+46
This adds the --without-libatomic configure option, which is useful for building libgo with a non-gcc compiler. It disables libgo's dependency on libatomic. This is useful for platforms where it is known that the libatomic runtime functions are not required, or where the compiler automatically provides an implementation of them. From-SVN: r211065
2014-05-29runtime: disable split stacks for runtime_printf function under ClangIan Lance Taylor1-1/+21
LLVM's code generator does not currently support split stacks for vararg functions, so we disable split stacks for the only function that uses this feature under Clang. This appears to be OK as long as: - this function only calls non-inlined, internal-linkage (hence no dynamic loader) functions compiled with split stacks (i.e. go_vprintf), which can allocate more stack space as required; - this function itself does not occupy more than BACKOFF bytes of stack space (see libgcc/config/i386/morestack.S). These conditions are currently known to be satisfied by Clang on x86-32 and x86-64. Note that signal handlers receive slightly less stack space than they would normally do if they happen to be called while this function is being run. If this turns out to be a problem we could consider increasing BACKOFF. From-SVN: r211037
2014-05-28runtime: fix misc gcc-isms and undefined behaviorIan Lance Taylor5-142/+113
This includes the use of __complex and __builtin_ functions where unprefixed entities would suffice, and the use of a union for bit-casting between types. From-SVN: r211036
2014-05-27libgo/runtime: fix unused-result warningIan Lance Taylor1-1/+2
Result of runtime_write is ignored, causing an unused-result result warning (error in my case, with -Werror=unused-result). From-SVN: r210987
2014-05-07mksysinfo: Define some more non-trivial TIOC constants.Ian Lance Taylor1-0/+32
From-SVN: r210192
2014-05-07mksysinfo: Define CLONE flags.Ian Lance Taylor4-2/+12
From-SVN: r210189
2014-05-01runtime: ask $GOC rather than $CC for the version and multi-os-directoryIan Lance Taylor4-4/+4
The Go compiler may have different values for these than the C compiler. From-SVN: r209967
2014-04-25re PR go/60931 (libgo has issues when page size is not 4k)Ian Lance Taylor1-2/+12
PR go/60931 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. From-SVN: r209777
2014-04-17gofrontend: deduplicate C syscall function declarationsIan Lance Taylor1-2/+5
A gccgo language extension allows a function to be declared multiple times. Avoid the use of this extension by dedeplicating declarations in mksyscall.awk. From-SVN: r209508
2014-04-17runtime: remove use of obsolete map deletion syntaxIan Lance Taylor1-1/+1
The use of this syntax was eliminated upstream in Go 992248b2adc2, but this particular use slipped through somehow. From-SVN: r209506
2014-04-17gofrontend: avoid use of unsafe.Sizeof extensionIan Lance Taylor1-1/+1
Avoid the use of a gccgo language extension which allows unsafe.Sizeof to accept a type by passing an expression of the relevant type. From-SVN: r209503
2014-04-16libgo: Remove Solaris 8 & 9 support.Ian Lance Taylor5-55/+0
From Rainer Orth. From-SVN: r209448
2014-04-14Sync to current external repository.Chris Manghane1-24/+3
user: Ian Lance Taylor <iant@golang.org> date: Thu Apr 10 09:25:24 2014 -0700 files: go/expressions.cc description: compiler: add checks for constant overflow Prevent extremely large constants from eating all of memory. user: Chris Manghane <cmang@golang.org> date: Mon Apr 07 16:57:09 2014 -0700 files: go/gogo-tree.cc go/gogo.cc go/gogo.h go/statements.cc description: compiler: Use backend interface for variable initialization. user: Chris Manghane <cmang@golang.org> date: Thu Apr 03 19:56:05 2014 -0700 files: go/backend.h go/gogo-tree.cc go/gogo.cc go/gogo.h description: compiler: Use backend interface to build function code. changeset: 1269:6e30875d539e user: Chris Manghane <cmang@golang.org> date: Wed Apr 02 13:16:00 2014 -0700 files: go/backend.h go/gogo-tree.cc go/gogo.cc go/gogo.h description: compiler: Use backend interface for building function defer wrappers. user: Chris Manghane <cmang@golang.org> date: Mon Mar 31 12:42:49 2014 -0700 files: go/expressions.cc go/gogo-tree.cc go/gogo.cc go/gogo.h description: compiler: Use backend interface for memory allocation. user: Chris Manghane <cmang@golang.org> date: Thu Mar 27 14:22:49 2014 -0700 files: go/backend.h go/expressions.cc go/expressions.h description: compiler: Use backend interface for fixed array construction. user: Chris Manghane <cmang@golang.org> date: Mon Mar 17 21:25:04 2014 -0700 files: go/expressions.cc description: compiler: Check for loops in self-referential array types. Fixes issue 7525. user: Chris Manghane <cmang@golang.org> date: Mon Mar 17 14:31:59 2014 -0700 files: go/gogo.cc go/parse.cc description: compiler: Don't declare blank labels. Fixes issue 7539. user: Chris Manghane <cmang@golang.org> date: Mon Mar 17 13:12:32 2014 -0700 files: go/backend.h go/expressions.cc go/expressions.h go/runtime.def description: compiler: Use backend interface for call expressions. user: Chris Manghane <cmang@golang.org> date: Wed Mar 12 13:34:27 2014 -0700 files: go/expressions.cc go/expressions.h go/gogo-tree.cc go/statements.cc description: compiler: Use backend interface map construction. user: Chris Manghane <cmang@golang.org> date: Tue Mar 11 12:53:06 2014 -0700 files: go/backend.h go/expressions.cc go/gogo-tree.cc go/gogo.h description: compiler: Use backend interface for string expressions. user: Chris Manghane <cmang@golang.org> date: Sat Mar 08 15:56:59 2014 -0800 files: go/backend.h go/expressions.cc go/expressions.h description: compiler: Use backend interface for array and string indexing. user: Chris Manghane <cmang@golang.org> date: Fri Mar 07 16:02:18 2014 -0800 files: go/expressions.cc description: compiler: Use backend interface for constant expressions. user: Chris Manghane <cmang@golang.org> date: Thu Mar 06 16:00:18 2014 -0800 files: go/expressions.cc description: compiler: Use backend interface for struct construction. user: Chris Manghane <cmang@golang.org> date: Wed Mar 05 13:09:37 2014 -0800 files: go/expressions.cc description: compiler: Use backend interface for type conversions. user: Chris Manghane <cmang@golang.org> date: Tue Mar 04 07:03:47 2014 -0800 files: go/expressions.cc go/expressions.h go/gogo-tree.cc go/gogo.h go/runtime.def libgo/runtime/chan.c description: compiler: Use backend interface for channel receive. user: Chris Manghane <cmang@golang.org> date: Mon Mar 03 15:18:57 2014 -0800 files: go/backend.h go/expressions.cc go/runtime.def description: compiler: Use backend interface for builtin calls. user: Chris Manghane <cmang@golang.org> date: Mon Mar 03 07:44:35 2014 -0800 files: go/expressions.cc go/expressions.h go/types.cc go/types.h description: compiler: Use backend interface for string info. user: Chris Manghane <cmang@golang.org> date: Fri Feb 28 10:45:55 2014 -0800 files: go/expressions.cc go/expressions.h go/gogo-tree.cc go/statements.cc description: compiler: Use backend interface for map indexing. user: Chris Manghane <cmang@golang.org> date: Wed Feb 26 14:13:10 2014 -0800 files: go/expressions.cc go/expressions.h description: compiler: Use backend interface for slice value expressions. user: Chris Manghane <cmang@golang.org> date: Wed Feb 26 13:12:19 2014 -0800 files: go/backend.h go/expressions.cc go/expressions.h go/gogo-tree.cc go/runtime.def go/statements.cc description: compiler: Use backend interface for interface values. user: Chris Manghane <cmang@golang.org> date: Mon Feb 24 12:30:13 2014 -0800 files: go/expressions.cc go/expressions.h go/parse.cc go/statements.cc description: compiler: Change Heap_composite_expression to Heap_expression. user: Chris Manghane <cmang@golang.org> date: Thu Feb 20 19:47:06 2014 -0800 files: go/expressions.cc go/expressions.h go/gogo-tree.cc go/gogo.cc go/gogo.h go/types.cc go/types.h description: compiler: Use backend interface for interface method table expressions. user: Chris Manghane <cmang@golang.org> date: Mon Feb 03 14:36:20 2014 -0800 files: go/expressions.cc go/expressions.h description: compiler: Add compound expressions to the frontend. * go-gcc.cc: Include "convert.h". (Gcc_backend::string_constant_expression): New function. (Gcc_backend::real_part_expression): Likewise. (Gcc_backend::imag_part_expression): Likewise. (Gcc_backend::complex_expression): Likewise. (Gcc_backend::constructor_expression): Likewise. (Gcc_backend::array_constructor_expression): Likewise. (Gcc_backend::pointer_offset_expression): Likewise. (Gcc_backend::array_index_expression): Likewise. (Gcc_backend::call_expression): Likewise. (Gcc_backend::exception_handler_statement): Likewise. (Gcc_backend::function_defer_statement): Likewise. (Gcc_backend::function_set_parameters): Likewise. (Gcc_backend::function_set_body): Likewise. (Gcc_backend::convert_expression): Handle various type conversions. From-SVN: r209393
2014-03-12libgo: Build math package with -ffp-contract=off on non-x86.Ian Lance Taylor2-0/+4
http://golang.org/issue/7074 shows that not using -ffp-contract=off produces the wrong result for math.Log2(1) on arm64. From-SVN: r208505
2014-03-07runtime: Fix GC bug caused by Entersyscall modifying reg.Ian Lance Taylor1-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. From-SVN: r208390