Commit Graph

569 Commits

Author SHA1 Message Date
Ian Lance Taylor 5d51c2d70c debug/elf: add power64 support along with relocation test
Backport of https://codereview.appspot.com/125910043 from the
dev.power64 branch of the master repository.

From-SVN: r216813
2014-10-28 22:57:35 +00:00
Ian Lance Taylor 3a21b777bb libgo: Add consts for ioctl
TIOCSWINSZ_val, TCGETS_val, TCSETS_val

From-SVN: r216807
2014-10-28 18:18:39 +00:00
Ian Lance Taylor 50a504654d libgo: Update to Go 1.3.3 release.
From-SVN: r216746
2014-10-27 16:57:33 +00:00
Ian Lance Taylor 0f2aeaa817 compiler, runtime: Add type information to single object allocation.
From-SVN: r216490
2014-10-20 19:12:44 +00:00
Ian Lance Taylor 7b28fa2c6b reflect: allocate correct type in assignTo and cvtT2I
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-20 18:04:55 +00:00
Ian Lance Taylor 204b9fc2b8 configure: Quote some shell variables.
From Dominik Vogt.

From-SVN: r216355
2014-10-17 00:03:20 +00:00
Ian Lance Taylor 6c4ee063a5 runtime: Don't create threads with a small stack.
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-16 22:39:45 +00:00
Ian Lance Taylor 19d4baed57 re PR go/60406 (recover.go: test13reflect2 test failure)
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-08 14:03:13 +00:00
Ian Lance Taylor 22806403ec re PR go/61877 (reflect: cannot use []string as type string in Call)
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-03 15:51:38 +00:00
Ian Lance Taylor 60d9e9fc19 runtime: Check for CPU_COUNT itself, don't check glibc version.
Fixes issue 38.

From-SVN: r215832
2014-10-03 05:04:59 +00:00
Ian Lance Taylor a819231d57 libgo/configure: Use -Qunused-arguments for asm tests if supported.
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-29 23:37:27 +00:00
Ian Lance Taylor 76deefd0cd runtime: Mark runtime_goexit function as noinline.
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-22 21:14:43 +00:00
Ian Lance Taylor f0c1b5671a runtime: Restore copyright notice accidentally removed from mgc0.c.
From-SVN: r215423
2014-09-20 20:42:59 +00:00
Ian Lance Taylor 01c2fa9d53 runtime: Use the clone system call on GNU/Linux.
Without this we weren't supporting the standard Cloneflags
field of SysProcAttr.

From-SVN: r214972
2014-09-05 15:24:36 +00:00
Ian Lance Taylor a7188cc650 runtime: Use correct size for unsafe.Pointer GC instructions.
From-SVN: r214965
2014-09-05 14:43:24 +00:00
Chris Manghane f1d2ac4f84 compiler: Add precise type information on the heap.
* 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-09-03 22:56:09 +00:00
Ian Lance Taylor ab36d98dd2 runtime: Don't get confused if m changes during runtime_gc.
From-SVN: r214048
2014-08-15 22:16:55 +00:00
Ian Lance Taylor 798c183f7f compiler, runtime: Fix unexpected GC interfering with closure passing.
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-13 22:31:44 +00:00
Ian Lance Taylor d79fe5971a runtime: Add casts to mincore call to compile on Solaris.
Based on patch from Rainer Orth.

From-SVN: r213599
2014-08-04 17:54:09 +00:00
Ian Lance Taylor dc14e88e07 re PR other/61895 (libbacktrace crashes with bus error with empty file argv[0])
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-08-02 00:54:15 +00:00
Ian Lance Taylor d5d0580e64 runtime: remove unused variable
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-20 19:20:12 +00:00
Ian Lance Taylor aefa5ff4cf runtime: add a missing import
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-20 15:09:04 +00:00
Ian Lance Taylor 1c2afaca89 runtime: also disable split stacks for runtime_snprintf function under Clang
From-SVN: r212862
2014-07-20 09:24:16 +00:00
Ian Lance Taylor dffa732835 reflect, runtime: Use libffi closures to implement reflect.MakeFunc.
Keep using the existing 386 and amd64 code on those archs,
since it is more efficient.

From-SVN: r212853
2014-07-19 21:36:26 +00:00
Ian Lance Taylor 90fe3cc61f libgo: Bump version number.
From-SVN: r212840
2014-07-19 10:12:01 +00:00
Ian Lance Taylor 00d86ac99f libgo: Update to Go 1.3 release.
From-SVN: r212837
2014-07-19 08:53:52 +00:00
Ian Lance Taylor 2fa39ad859 runtime: Merge master revision 19185.
This revision renames several files in the runtime directory
from .c to .goc.

From-SVN: r212472
2014-07-12 00:01:09 +00:00
Ian Lance Taylor c14e64d4ca runtime: Rename iface.goc to go-iface.goc.
Rename in order to avoid confusion with the new
runtime/iface.goc file in the Go library master sources.

From-SVN: r212447
2014-07-11 00:39:03 +00:00
Ian Lance Taylor 2802d48b30 runtime: Drop reflectFlags tests.
The flags were used by the reflect package in the past, but
not for a couple of years now.

From-SVN: r212446
2014-07-11 00:26:25 +00:00
Ian Lance Taylor 9490fda67a re PR go/61620 (FAIL: go.test/test/fixedbugs/bug242.go execution, -O2 -g)
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-02 14:23:45 +00:00
Ian Lance Taylor ffa98da470 runtime: introduce build targets for running benchmarks
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-07-01 23:19:24 +00:00
Ian Lance Taylor 7b169c293d runtime: add missing benchmark input files to the repository
From-SVN: r211961
2014-06-24 23:52:47 +00:00
Ian Lance Taylor 2abacbaec7 re PR go/52583 (Several new go testsuite failues on Solaris)
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-13 13:56:14 +00:00
Ian Lance Taylor eec40eac83 re PR go/61498 (Many 64-bit Go tests SEGV in scanblock)
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-13 13:50:13 +00:00
Ian Lance Taylor 816002df70 runtime: Initialize variable to avoid compiler warning.
From-SVN: r211394
2014-06-10 00:36:38 +00:00
Ian Lance Taylor 6736ef96ea libgo: Merge to master revision 19184.
The next revision, 19185, renames several runtime files, and
will be handled in a separate change.

From-SVN: r211328
2014-06-06 22:37:27 +00:00
Ian Lance Taylor bae90c989c libgo: Merge from revision 18783:00cce3a34d7e of master library.
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-06-04 23:15:33 +00:00
Ian Lance Taylor 7480a39b77 runtime: Use _mm_pause rather than __builtin_ia32_pause.
Based on a patch from Peter Collingbourne.

From-SVN: r211081
2014-05-30 13:53:58 +00:00
Ian Lance Taylor 9a85ed03da runtime: add the --without-libatomic configure option
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-29 20:22:27 +00:00
Ian Lance Taylor d76a1885bd runtime: disable split stacks for runtime_printf function under Clang
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-29 00:03:30 +00:00
Ian Lance Taylor 93c521ea9c runtime: fix misc gcc-isms and undefined behavior
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-28 23:10:47 +00:00
Ian Lance Taylor 25e4b0497b libgo/runtime: fix unused-result warning
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-27 22:01:21 +00:00
Ian Lance Taylor 44d5790f7b mksysinfo: Define some more non-trivial TIOC constants.
From-SVN: r210192
2014-05-07 22:22:29 +00:00
Ian Lance Taylor d3b4df0b17 mksysinfo: Define CLONE flags.
From-SVN: r210189
2014-05-07 21:48:29 +00:00
Ian Lance Taylor 6c76a95d1b runtime: ask $GOC rather than $CC for the version and multi-os-directory
The Go compiler may have different values for these than the C compiler.

From-SVN: r209967
2014-05-01 00:35:58 +00:00
Ian Lance Taylor 9490b8da72 re PR go/60931 (libgo has issues when page size is not 4k)
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-25 04:29:07 +00:00
Ian Lance Taylor 5584c49a11 gofrontend: deduplicate C syscall function declarations
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-17 23:39:23 +00:00
Ian Lance Taylor e8ad3ca026 runtime: remove use of obsolete map deletion syntax
The use of this syntax was eliminated upstream in Go 992248b2adc2,
but this particular use slipped through somehow.

From-SVN: r209506
2014-04-17 23:27:31 +00:00
Ian Lance Taylor e315e8a5b9 gofrontend: avoid use of unsafe.Sizeof extension
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-17 23:13:39 +00:00
Ian Lance Taylor 73cc28d4e7 libgo: Remove Solaris 8 & 9 support.
From Rainer Orth.

From-SVN: r209448
2014-04-16 20:33:57 +00:00