Commit Graph

891 Commits

Author SHA1 Message Date
Ian Lance Taylor f522b07d8d mksysinfo: fix in6_addr in mld_hdr_t for Solaris
Patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/60732

From-SVN: r251574
2017-08-31 20:07:55 +00:00
Ian Lance Taylor 53a36c2652 net/internal/socktest: build sys_unix.go on AIX
Reviewed-on: https://go-review.googlesource.com/59913

From-SVN: r251440
2017-08-29 21:56:31 +00:00
Ian Lance Taylor 6222bddc8e libgo: netinet/icmp6.h require netinet/in.h on AIX
Reviewed-on: https://go-review.googlesource.com/59912

From-SVN: r251439
2017-08-29 21:51:49 +00:00
Ian Lance Taylor 888a985425 libgo: fix Stat_t on AIX
Reviewed-on: https://go-review.googlesource.com/59911

From-SVN: r251436
2017-08-29 21:00:46 +00:00
Ian Lance Taylor 6fa7df983e runtime: make go-nosys.c compile with !HAVE_SYSCALL
Reviewed-on: https://go-review.googlesource.com/59910

From-SVN: r251435
2017-08-29 20:57:20 +00:00
Ian Lance Taylor a2aa807ef9 runtime: fix lfstack for 64-bit AIX
Reviewed-on: https://go-review.googlesource.com/57550

From-SVN: r251420
2017-08-29 18:59:04 +00:00
Ian Lance Taylor b66d36128f re PR go/81893 (compilation error in libgo starting with r251127)
PR go/81893
    runtime: only use PPC GNU/Linux register code on little endian
    
    Reportedly the current code builds on little endian but not big endian.
    
    Fixes https://gcc.gnu.org/PR81893.
    
    Reviewed-on: https://go-review.googlesource.com/57110

From-SVN: r251188
2017-08-18 20:17:26 +00:00
Ian Lance Taylor 419d55e8df misc/cgo/test: make cgo tests run on AIX
Reviewed-on: https://go-review.googlesource.com/56910

From-SVN: r251182
2017-08-18 14:05:52 +00:00
Ian Lance Taylor c32bd276c6 cmd/go: pass -funwind-tables when compiling C code
Using -funwind-tables is necessary to permit Go code to correctly
    throw a panic through C code.  This hasn't been necessary in the past
    as -funwind-tables is the default on x86.  However, it is not the
    default for PPC AIX.
    
    Reviewed-on: https://go-review.googlesource.com/56650

From-SVN: r251179
2017-08-18 04:40:42 +00:00
Ian Lance Taylor 098c217267 runtime: better implementation of netpoll for AIX
Reviewed-on: https://go-review.googlesource.com/54170

From-SVN: r251133
2017-08-16 20:58:26 +00:00
Ian Lance Taylor 450f20a899 runtime: improvements for signal registers
Fix dumpregs on i386, implement dumpregs for PPC Linux/AIX, get PC on AIX.
    
    Reviewed-on: https://go-review.googlesource.com/56170

From-SVN: r251127
2017-08-16 19:04:00 +00:00
Ian Lance Taylor a171ac0380 compiler: handle >32bit exponent in Ldexp
Libgo's implementation of math.Ldexp declared the libc "ldexp" as
    taking an 'int' exponent argument, which is not quite right for 64-bit
    platforms (exp arg is always int32); this could yield incorrect
    results for exponent values outside the range of Minint32/Maxint32.
    Fix by upating the type for the libc version of ldexp, and adding
    guards to screen for out-of-range exponents.
    
    Fixes #21323.
    
    Reviewed-on: https://go-review.googlesource.com/54250

From-SVN: r250992
2017-08-09 17:15:02 +00:00
Ian Lance Taylor 8ffe2be85e runtime: dump registers for Alpha
Patch from Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/53350

From-SVN: r250873
2017-08-04 13:46:39 +00:00
Ian Lance Taylor 194f08aeae re PR go/81617 (mksigtab.sh fails to resolve NSIG with glibc 2.26)
PR go/81617
    libgo: change mksigtab to recognize glibc 2.26 NSIG expression
    
    Fixes golang/go#21147
    Fixes GCC PR 81617
    
    Reviewed-on: https://go-review.googlesource.com/52611

From-SVN: r250858
2017-08-03 18:09:12 +00:00
Ian Lance Taylor 993323a14f runtime: handle Alpha GNU/Linux in getSiginfo
Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/51370

From-SVN: r250588
2017-07-26 20:20:22 +00:00
Ian Lance Taylor 0901429d47 syscall: call f?statfs64 on GNU/Linux
We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we
    should unconditionally call the statfs64 and fstatfs64 functions.
    These functions should be available on all versions of GNU/Linux since 2.6.
    On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit
    systems they use the 64-bit data structures.
    
    Fixes golang/go#20922
    
    Reviewed-on: https://go-review.googlesource.com/50635

From-SVN: r250443
2017-07-21 20:25:13 +00:00
Ian Lance Taylor df206c6e77 runtime: don't use runtime_lock in __go_get_backtrace_state
If getSiginfo does not know how to determine the PC, it will call
    runtime_callers. That can happen in a thread that was started by
    non-Go code, in which case the TLS variable g will not be set, in
    which case runtime_lock will crash.
    
    Avoid the problem by using atomic operations for the lock. This is OK
    since creating a backtrace state is fast and never blocks.
    
    The test case is TestCgoExternalThreadSIGPROF in the runtime package
    on a system that getSiginfo doesn't handle specially.
    
    Updates golang/go#20931
    
    Reviewed-on: https://go-review.googlesource.com/50650

From-SVN: r250439
2017-07-21 18:27:35 +00:00
Ian Lance Taylor 0ab7176094 runtime: handle PPC/PPC64 GNU/Linux in getSiginfo
Updates golang/go#20931
    
    Reviewed-on: https://go-review.googlesource.com/50631

From-SVN: r250436
2017-07-21 18:08:01 +00:00
Ian Lance Taylor 048f0471d2 runtime: allocate more stack space in CgoCallbackGC test
Allocate enough stack space so that the test will work on a system
    that does not support split stacks.
    
    This test is actually not very meaningful for gccgo at present, but it
    doesn't hurt to keep running it.
    
    Updates golang/go#20931
    
    Reviewed-on: https://go-review.googlesource.com/50630

From-SVN: r250433
2017-07-21 17:50:14 +00:00
Ian Lance Taylor 9e45ca5f83 re PR go/81451 (missing futex check - libgo/runtime/thread-linux.c:12:0 futex.h:13:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘long’)
PR go/81451
    runtime: inline runtime_osinit
    
    We had two identical copies of runtime_osinit. They set runtime_ncpu,
    a variable that is no longer used. Removing that leaves us with two lines.
    Inline those two lines in the two places the function was called.
    
    This fixes GCC PR 81451.
    
    Reviewed-on: https://go-review.googlesource.com/48862

From-SVN: r250326
2017-07-18 23:14:29 +00:00
Ian Lance Taylor eb80664a39 re PR go/81324 (libgo does not build with glibc 2.18)
PR go/81324
    sysinfo.c: ignore ptrace_peeksiginfo_args from <linux/ptrace.h>
    
    With some versions of glibc and GNU/Linux ptrace_pseeksiginfo_args is
    defined in both <sys/ptrace.h> and <linux/ptrace.h>. We don't actually
    care about the struct, so use a #define to avoid a redefinition error.
    
    This fixes https://gcc.gnu.org/PR81324.
    
    Reviewed-on: https://go-review.googlesource.com/49290

From-SVN: r250324
2017-07-18 22:06:31 +00:00
Ian Lance Taylor f30d20915d libgo: don't copy semt into runtime.inc
https://gcc.gnu.org/PR81449 reports a problem with the definition semt
    in runtime.inc on some systems. Since the C code in libgo/runtime
    doesn't need semt, just don't copy it into runtime.inc.
    
    Reviewed-on: https://go-review.googlesource.com/48593

From-SVN: r250217
2017-07-14 22:25:26 +00:00
Ian Lance Taylor b9d36a8daf cmd/go: use gccSupportsFlag for -fsplit-stack
Don't assume that all (or only) 386/amd64 compilers support
    -fsplit-stack.
    
    Reviewed-on: https://go-review.googlesource.com/48592

From-SVN: r250216
2017-07-14 22:21:37 +00:00
Ian Lance Taylor 6eecb29326 re PR go/81393 (Bootstrap failure on s390x-linux while building libgo against recent glibc)
PR go/81393
    syscall: don't use GETREGS/SETREGS on s390
    
    They were removed in recent glibc.
    
    Patch by Andreas Krebbel for GCC PR 81393.
    
    Reviewed-on: https://go-review.googlesource.com/48231

From-SVN: r250174
2017-07-13 03:44:14 +00:00
Ian Lance Taylor 8ff22ea5a8 misc/cgo/testcarchive: fix test to work for gccgo
This test is not yet run, but it will be soon.
    
    Reviewed-on: https://go-review.googlesource.com/47038

From-SVN: r249795
2017-06-29 15:17:20 +00:00
Ian Lance Taylor 1a7ad6ad66 cmd/go: fix -buildmode={c-archive,c-shared,pie} for gccgo
The tests are misc/cgo tests that are not currently run but will be
    run soon.
    
    Reviewed-on: https://go-review.googlesource.com/47037

From-SVN: r249794
2017-06-29 15:14:05 +00:00
Ian Lance Taylor 7fd19291a5 runtime: adapt memory management to AIX mmap
On AIX:
    * mmap does not allow to map an already mapped range,
    * mmap range start at 0x30000000 for 32 bits processes,
    * mmap range start at 0x70000000_00000000 for 64 bits processes
    
    This is adapted from change 37845.
    
    Issue golang/go#19200
    
    Reviewed-on: https://go-review.googlesource.com/46772

From-SVN: r249713
2017-06-27 22:36:48 +00:00
Ian Lance Taylor f9dedc3f21 syscall: ptrace fixes for s390
Fixes required now that we #include <linux/ptrace.h> in sysinfo.c.
    
    Patch by Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/46839

From-SVN: r249712
2017-06-27 21:51:50 +00:00
Ian Lance Taylor 936615752a libgo: add misc/cgo files
Copy all the misc/cgo files from the gc toolchain into libgo/misc.
    
    These will be used for testing purposes by later changes to the
    gotools directory.
    
    Reviewed-on: https://go-review.googlesource.com/46721

From-SVN: r249674
2017-06-27 04:21:40 +00:00
Ian Lance Taylor b5df99f741 syscall: don't define PtraceRegs for Alpha
It's now defined by mksysinfo.sh.
    
    Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/46712

From-SVN: r249663
2017-06-26 17:59:12 +00:00
Ian Lance Taylor 0bcce674a7 libgo: redefine ia64 struct names around linux/ptrace.h
Avoid https://sourceware.org/bugzilla/show_bug.cgi?id=762.
    
    Patch by Andreas Schwab.
    
    Reviewed-on: https://go-review.googlesource.com/46711

From-SVN: r249662
2017-06-26 17:56:14 +00:00
Ian Lance Taylor f1857c6369 runtime: complete defer handling in CgocallBackDone
When C code calls a Go function, it actually calls a function
    generated by cgo. That function is written in Go, and, among other
    things, it calls the real Go function like this:
            CgocallBack()
            defer CgocallBackDone()
            RealGoFunction()
    The deferred CgocallBackDone function enters syscall mode as we return
    to C. Typically the C function will then eventually return to Go.
    
    However, in the case where the C function is running on a thread
    created in C, it will not return to Go. For that case we will have
    allocated an m struct, with an associated g struct, for the duration
    of the Go code, and when the Go is complete we will return the m and g
    to a free list.
    
    That all works, but we are running in a deferred function, which means
    that we have been invoked by deferreturn, and deferreturn expects to
    do a bit of cleanup to record that the defer has been completed. Doing
    that cleanup while using an m and g that have already been returned to
    the free list is clearly a bad idea. It was kind of working because
    deferreturn was holding the g pointer in a local variable, but there
    were races with some other thread picking up and using the newly freed g.
    It was also kind of working because of a special check in freedefer;
    that check is no longer necessary.
    
    This patch changes the special case of releasing the m and g to do the
    defer cleanup in CgocallBackDone itself.
    
    This patch also checks for the special case of a panic through
    CgocallBackDone. In that special case, we don't want to release the m
    and g. Since we are returning to C code that was not called by Go
    code, we know that the panic is not going to be caught and we are
    going to exit the program. So for that special case we keep the m and
    g structs so that the rest of the panic code can use them.
    
    Reviewed-on: https://go-review.googlesource.com/46530

From-SVN: r249611
2017-06-23 20:19:40 +00:00
Ian Lance Taylor 0f0d0eaae5 cmd/go: don't require GOROOT to exist for gccgo
Reviewed-on: https://go-review.googlesource.com/46590

From-SVN: r249609
2017-06-23 20:11:27 +00:00
Ian Lance Taylor 3c76bd9257 os: align siginfo argument to waitid
Backport https://golang.org/cl/46511 from gc trunk, as it may fix a
    bug reported for gccgo running on MIPS
    (https://groups.google.com/d/msg/golang-dev/sDg-t1_DPw0/-AJmLxgPBQAJ).
    
    Reviewed-on: https://go-review.googlesource.com/46571

From-SVN: r249599
2017-06-23 17:10:18 +00:00
Ian Lance Taylor bb96aa6726 runtime: don't crash if no p in kickoff
The kickoff function for g0 can be invoked without a p, for example
    from mcall(exitsyscall0) in exitsyscall after exitsyscall has cleared
    the p field. The assignment gp.param = nil will invoke a write barrier.
    If gp.param is not already nil, this will require a p. Avoid the problem
    for a specific case that is known to be OK: when the value in gp.param
    is a *g.
    
    Reviewed-on: https://go-review.googlesource.com/46512

From-SVN: r249595
2017-06-23 16:05:44 +00:00
Ian Lance Taylor 54357b3b84 runtime: improve handling of panic during deferred function
When a panic occurs while processing a deferred function that
    recovered an earlier panic, we shouldn't report the recovered panic
    in the panic stack trace. Stop doing so by keeping track of the panic
    that triggered a defer, marking it as aborted if we see the defer again,
    and discarding aborted panics when a panic is recovered. This is what
    the gc runtime does.
    
    The test for this is TestRecursivePanic in runtime/crash_test.go.
    We don't run that test yet, but we will soon.
    
    Reviewed-on: https://go-review.googlesource.com/46461

From-SVN: r249590
2017-06-23 13:45:36 +00:00
Ian Lance Taylor c8a0d1c344 runtime: uncomment check for gchelper on g0 stack
Now that systemstack changes to the g0 stack, this check passes.
    
    Reviewed-on: https://go-review.googlesource.com/46460

From-SVN: r249578
2017-06-22 22:12:50 +00:00
Ian Lance Taylor b34391e08e runtime: mark dropm and callees nowritebarrierrec
The CgocallbackDone function calls dropm after it calls entersyscall,
    which means that dropm must not have any write barriers. Mark it
    accordingly.
    
    Reviewed-on: https://go-review.googlesource.com/46464

From-SVN: r249577
2017-06-22 22:11:01 +00:00
Ian Lance Taylor f384e12acc runtime: export getm function
Use go:linkname to export the getm function. This makes it visible to
    runtime/testdata/testprogcgo/dropm_stub.go, which uses it as part of
    the TestEnsureDropM test in runtime/crash_cgo_test.go. That test is
    not run today, but it will be soon.
    
    Reviewed-on: https://go-review.googlesource.com/46462

From-SVN: r249576
2017-06-22 22:08:50 +00:00
Ian Lance Taylor 61fbdfbe1b runtime: fix type cast in assignment to gcnextsp in C code
Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/46459

From-SVN: r249575
2017-06-22 19:52:11 +00:00
Ian Lance Taylor 47f68dc231 runtime: make NumGoroutine wait for system goroutines to register
In libgo system goroutines register themselves after they start.
    That means that there is a small race between the goroutine being
    seen by the scheduler and the scheduler knowing that the goroutine
    is a system goroutine. That in turn means that runtime.NumGoroutines
    can overestimate the number of goroutines at times.
    
    This patch fixes the overestimate by counting the number of system
    goroutines waiting to start, and pausing NumGoroutines until those
    goroutines have all registered.
    
    This is kind of a lot of mechanism for this not very important
    problem, but I couldn't think of a better approach.
    
    The test for this is TestNumGoroutine in runtime/proc_test.go.
    The test is not currently run, but it will be soon.
    
    Reviewed-on: https://go-review.googlesource.com/46457

From-SVN: r249565
2017-06-22 15:46:47 +00:00
Ian Lance Taylor c016fd32fe runtime: don't assume that _ = *s will panic if s is nil
With the gc toolchain apparently
            var s *string
            _ = *s
    is enough to panic with a nil pointer dereference. The gccgo compiler
    will simply discard the dereference, which I think is a reasonable and
    acceptable optimization. Change the tests to use an exported variable
    instead. The tests are not currently run, but they will be with a
    later patch to gotools.
    
    Reviewed-on: https://go-review.googlesource.com/46450

From-SVN: r249562
2017-06-22 14:46:12 +00:00
Ian Lance Taylor 3b0ddadf74 runtime: change some stack fields to uintptr
Because of how gccgo implements cgo calls, the code in dropm may not
    have any write barriers.  As a step toward implementing that, change
    the gcstack, gcnextsegment, and gcnextsp fields of the g struct to
    uintptr, so that assignments to them do not require write barriers.
    The gcinitialsp field remains unsafe.Pointer, as on 32-bit systems
    that do not support split stack it points to a heap allocated space
    used for the goroutine stack.
    
    The test for this is runtime tests like TestCgoCallbackGC, which are
    not run today but will be run with a future gotools patch.
    
    Reviewed-on: https://go-review.googlesource.com/46396

From-SVN: r249561
2017-06-22 14:44:30 +00:00
Ian Lance Taylor c8a47c4877 runtime: avoid write barriers when calling deferred function
Calling a deferred function currently requires changing from a uintptr
    to the function code to a Go function value. That is done by setting
    the value of a func local variable using unsafe.Pointer. The local
    variable will always be on the stack. Adjust the code that sets the
    local variable to avoid generating a write barrier.
    
    A write barrier is never needed here. Also, for deferreturn, we must
    avoid write barriers entirely when called from a cgo function; that
    requires more than just this, but this is a start.
    
    The test for this is runtime tests that use the go tool; these are not
    currently run, but they will be in the future.
    
    Reviewed-on: https://go-review.googlesource.com/46455

From-SVN: r249559
2017-06-22 14:33:13 +00:00
Ian Lance Taylor b92e4dff0a runtime: rename _defer struct _panic field to panicStack
The gc version of the _defer struct has a _panic field that has a
    completely different meaning. We are going to want that bring that new
    meaning into the gofrontend to improve panic reports with nested
    panic calls. Simplify that by first renaming the existing _panic field.
    
    Reviewed-on: https://go-review.googlesource.com/46454

From-SVN: r249558
2017-06-22 14:31:16 +00:00
Ian Lance Taylor ed99905e1d runtime: adjust tests for gofrontend
- don't run tests that depend on SetCgoTraceback
    - don't expect a '(' after the function name in a traceback
    - change the expected name of nested functions in a traceback
    
    These tests are not currently run, but they will be soon.
    
    Reviewed-on: https://go-review.googlesource.com/46453

From-SVN: r249557
2017-06-22 14:28:57 +00:00
Ian Lance Taylor 2a208bc257 runtime: don't build test files that use SetCgoTraceback for gccgo
The gofrontend doesn't support the runtime.SetCgoTraceback function,
    which is specifically for handling mixed Go and C tracebacks.
    Use a build tag to avoid compiling the runtime/testdata/testprogcgo
    files that refer to SetCgoTraceback. These files are not currently
    compiled anyhow, but they will be with a future gotools patch.
    
    Reviewed-on: https://go-review.googlesource.com/46452

From-SVN: r249556
2017-06-22 14:27:09 +00:00
Ian Lance Taylor 7d8c7b26c8 runtime: build testprogcgo with -pthread
Building this test with gccgo requires an explicit -pthread option to
    be passed to the C compiler, so that it links against -lpthread.
    This test is not built today, but it will be soon with a future patch.
    
    Reviewed-on: https://go-review.googlesource.com/46451

From-SVN: r249555
2017-06-22 14:23:54 +00:00
Ian Lance Taylor c83c219a63 runtime: in traceback, print panic rather than runtime.gopanic
The gc toolchain does the same thing, in gentraceback in
    runtime/traceback.go.
    
    The test for this is TestPanicTraceback in runtime/crash_test.go.  We
    don't yet run that test, but we will in a future change.
    
    Reviewed-on: https://go-review.googlesource.com/46397

From-SVN: r249495
2017-06-22 04:16:23 +00:00
Ian Lance Taylor 55ea0ea07d compiler, runtime: better stack trace for `go f()` where f is nil
The test for this is TestGoNil in the runtime package, which we don't
    run yet but will run with a subsequent gotools patch.
    
    Updates golang/go#8045
    
    Reviewed-on: https://go-review.googlesource.com/46392

From-SVN: r249494
2017-06-22 04:13:36 +00:00