1. 08 Sep, 2014 18 commits
    • Russ Cox's avatar
      syscall: keep allocated C string live across call to Syscall · cf622d75
      Russ Cox authored
      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://golang.org/cl/139360044
      cf622d75
    • Russ Cox's avatar
      runtime: run sighandler on g0 stack on windows · 201cfe4a
      Russ Cox authored
      The sighander has been run at the bottom of the
      currently executing goroutine stack, but it's in C,
      and we don't want C on our ordinary goroutine stacks.
      Worse, it does a lot of stuff, and it might need more
      stack space. There is scary code in traceback_windows.go
      that talks about stack splits during sighandler.
      Moving sighandler to g0 will eliminate the possibility
      of stack splits and such, and then we can delete
      traceback_windows.go entirely. Win win.
      
      On the builder, all.bat passes with GOARCH=amd64
      and all.bat gets most of the way with GOARCH=386
      except for a DLL-loading test that I think is unrelated.
      
      Fixes windows build.
      
      TBR=brainman, iant
      CC=golang-codereviews
      https://golang.org/cl/140380043
      201cfe4a
    • Keith Randall's avatar
      runtime: merge panic1.go back into panic.go · 3a3d47db
      Keith Randall authored
      LGTM=rsc
      R=rsc
      CC=golang-codereviews
      https://golang.org/cl/139370043
      3a3d47db
    • Russ Cox's avatar
      liblink, runtime: diagnose and fix C code running on Go stack · c81a0ed3
      Russ Cox authored
      This CL contains compiler+runtime changes that detect C code
      running on Go (not g0, not gsignal) stacks, and it contains
      corrections for what it detected.
      
      The detection works by changing the C prologue to use a different
      stack guard word in the G than Go prologue does. On the g0 and
      gsignal stacks, that stack guard word is set to the usual
      stack guard value. But on ordinary Go stacks, that stack
      guard word is set to ^0, which will make any stack split
      check fail. The C prologue then calls morestackc instead
      of morestack, and morestackc aborts the program with
      a message about running C code on a Go stack.
      
      This check catches all C code running on the Go stack
      except NOSPLIT code. The NOSPLIT code is allowed,
      so the check is complete. Since it is a dynamic check,
      the code must execute to be caught. But unlike the static
      checks we've been using in cmd/ld, the dynamic check
      works with function pointers and other indirect calls.
      For example it caught sigpanic being pushed onto Go
      stacks in the signal handlers.
      
      Fixes #8667.
      
      LGTM=khr, iant
      R=golang-codereviews, khr, iant
      CC=golang-codereviews, r
      https://golang.org/cl/133700043
      c81a0ed3
    • Keith Randall's avatar
      runtime: a few cleanups. · 52631983
      Keith Randall authored
      LGTM=bradfitz
      R=golang-codereviews, bradfitz
      CC=golang-codereviews
      https://golang.org/cl/134630043
      52631983
    • David Crawshaw's avatar
      androidtest.bash: adjustment for move from src/pkg to src · 4c05d32f
      David Crawshaw authored
      LGTM=rsc
      R=rsc
      CC=golang-codereviews
      https://golang.org/cl/142740043
      4c05d32f
    • Dave Cheney's avatar
      cmd/cc: fix undefined behaviour warning in bv.c · 4a40fb19
      Dave Cheney authored
      Fixes warning
      
      # _/home/dfc/go/misc/cgo/test/backdoor
      /home/dfc/go/src/cmd/cc/bv.c:43:11: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
      
      LGTM=rsc
      R=rsc
      CC=golang-codereviews
      https://golang.org/cl/136330043
      4a40fb19
    • Dave Cheney's avatar
      cmd/gc: fix undefined behaviour warning in subr.c · 6a2e844f
      Dave Cheney authored
      Fixes warning
      
      /home/dfc/go/src/cmd/gc/subr.c:3469:8: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64' (aka 'long'); cast to an unsigned type to negate this value to itself
      
      LGTM=rsc
      R=rsc
      CC=golang-codereviews
      https://golang.org/cl/141220043
      6a2e844f
    • Rob Pike's avatar
      doc/go1.4.txt: src/pkg directory is gone. · 31bd41e0
      Rob Pike authored
      CC=golang-codereviews
      https://golang.org/cl/139310043
      31bd41e0
    • Russ Cox's avatar
      build: more adjustments for move from src/pkg to src · de4964a7
      Russ Cox authored
      These were missed in CL 134570043.
      
      Fixes nacl, solaris builds.
      
      TBR=r
      CC=golang-codereviews
      https://golang.org/cl/136320043
      de4964a7
    • Russ Cox's avatar
      build: move package sources from src/pkg to src · c007ce82
      Russ Cox authored
      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.
      c007ce82
    • Russ Cox's avatar
      build: adjustments for move from src/pkg to src · 220a6de4
      Russ Cox authored
      This CL adjusts code referring to src/pkg to refer to src.
      
      Immediately after submitting this CL, I will submit
      a change doing 'hg mv src/pkg/* src'.
      That change will be too large to review with Rietveld
      but will contain only the 'hg mv'.
      
      This CL will break the build.
      The followup 'hg mv' will fix it.
      
      For more about the move, see golang.org/s/go14nopkg.
      
      LGTM=r
      R=r
      CC=golang-codereviews
      https://golang.org/cl/134570043
      220a6de4
    • Brad Fitzpatrick's avatar
      doc: add a few http items to go1.4.txt · 36ca636f
      Brad Fitzpatrick authored
      CC=golang-codereviews
      https://golang.org/cl/132670045
      36ca636f
    • Brad Fitzpatrick's avatar
      net/http: add Transport.DialTLS hook · ae47e044
      Brad Fitzpatrick authored
      Per discussions out of https://golang.org/cl/128930043/
      and golang-nuts threads and with agl.
      
      Fixes #8522
      
      LGTM=agl, adg
      R=agl, c, adg
      CC=c, golang-codereviews
      https://golang.org/cl/137940043
      ae47e044
    • Russ Cox's avatar
      runtime: implement time.now in assembly on plan9, solaris, windows · 13d0b82b
      Russ Cox authored
      These all used a C implementation that contained 64-bit divide by 1000000000.
      On 32-bit systems that ends up in the 64-bit C divide support, which makes
      other calls and ends up using a fair amount of stack. We could convert them
      to Go but then they'd still end up in software 64-bit divide code. That would
      be okay, because Go code can split the stack, but it's still unnecessary.
      
      Write time·now in assembly, just like on all the other systems, and use the
      actual hardware support for 64/32 -> 64/32 division. This cuts the software
      routines out entirely.
      
      The actual code to do the division is copied and pasted from the sys_darwin_*.s files.
      
      LGTM=alex.brainman
      R=golang-codereviews, alex.brainman
      CC=aram, golang-codereviews, iant, khr, r
      https://golang.org/cl/136300043
      13d0b82b
    • Russ Cox's avatar
      net/http/httptest: delete TestIssue7264 · 50fc0f1a
      Russ Cox authored
      Now it's failing on Windows:
      
      panic: httptest: failed to listen on a port: listen tcp 127.0.0.1:0:
      listen: An operation on a socket could not be performed because the
      system lacked sufficient buffer space or because a queue was full.
      
      Since we can't seem to understand what the test is trying to test,
      and because it is causing problems on multiple systems,
      delete it.
      
      Fixes #7264.
      
      TBR=bradfitz
      CC=brainman, golang-codereviews
      https://golang.org/cl/141210043
      50fc0f1a
    • Russ Cox's avatar
      runtime: fix semacquire->acquireSudog->malloc->gogc->semacquire loop · 71de7e75
      Russ Cox authored
      This is what broke the build at
      http://build.golang.org/log/d9c6d334be16cbab85e99fddc6b4ba034319bd4e
      
      LGTM=iant
      R=golang-codereviews, iant
      CC=dvyukov, golang-codereviews, khr, r
      https://golang.org/cl/135580043
      71de7e75
    • Russ Cox's avatar
      net/http/httptest: fix deadlock in TestIssue7264 · 902f8d9c
      Russ Cox authored
      I am seeing deadlocks waiting on <-inHandler.
      It seems to me that there is no guarantee that the
      handler actually runs, if the client does
      
              write header
              close connection
      
      fast enough. The server might see the EOF on the
      connection before it manages to invoke the handler.
      
      This change fixes the deadlock, but it may make
      the test not actually test anything. Not sure.
      
      LGTM=bradfitz
      R=bradfitz, dvyukov
      CC=golang-codereviews
      https://golang.org/cl/140970043
      902f8d9c
  2. 07 Sep, 2014 10 commits
    • Russ Cox's avatar
      runtime: save g to TLS more aggressively · b4bfa6c9
      Russ Cox authored
      This is one of those "how did this ever work?" bugs.
      The current build failures are happening because
      a fault comes up while executing on m->curg on a
      system-created thread using an m obtained from needm,
      but TLS is set to m->g0, not m->curg. On fault,
      sigtramp starts executing, assumes r10 (g) might be
      incorrect, reloads it from TLS, and gets m->g0, not
      m->curg. Then sighandler dutifully pushes a call to
      sigpanic onto the stack and returns to it.
      We're now executing on the m->curg stack but with
      g=m->g0. Sigpanic does a stack split check, sees that
      the SP is not in range (50% chance depending on relative
      ordering of m->g0's and m->curg's stacks), and then
      calls morestack. Morestack sees that g=m->g0 and
      crashes the program.
      
      The fix is to replace every change of g in asm_arm.s
      with a call to a function that both updates g and
      saves the updated g to TLS.
      
      Why did it start happening? That's unclear.
      Unfortunately there were other bugs in the initial
      checkin that mask exactly which of a sequence of
      CLs started the behavior where sigpanic would end
      up tripping the stack split.
      
      Fixes arm build.
      Fixes #8675.
      
      LGTM=iant
      R=golang-codereviews, iant
      CC=dave, golang-codereviews, khr, minux, r
      https://golang.org/cl/135570043
      b4bfa6c9
    • Russ Cox's avatar
      crypto/tls: print unexpected error in test · 2c14dbe4
      Russ Cox authored
      Maybe will help us understand Solaris build failure.
      
      TBR=aram
      CC=golang-codereviews
      https://golang.org/cl/139290043
      2c14dbe4
    • Russ Cox's avatar
      liblink: fix arm wrapper prologue · fb818eab
      Russ Cox authored
      Fixes arm build.
      
      TBR=khr
      CC=golang-codereviews
      https://golang.org/cl/132700043
      fb818eab
    • Russ Cox's avatar
      build: fix windows make.bat · 2034dae9
      Russ Cox authored
      The Unix make.bash builds cmd/dist from *.c.
      make.bat apparently does not.
      
      TBR=r
      CC=golang-codereviews
      https://golang.org/cl/137280043
      2034dae9
    • Russ Cox's avatar
      cmd/dist: remove goc2c · c0951701
      Russ Cox authored
      After the three pending CLs listed below, there will be no more .goc files.
      
      134580043	runtime: move stubs.goc code into runtime.c
      133670043	runtime: fix windows syscalls for copying stacks
      141180043	runtime: eliminate Go -> C -> block paths for Solaris
      
      LGTM=bradfitz
      R=golang-codereviews, bradfitz, dave
      CC=golang-codereviews, iant, r
      https://golang.org/cl/132680043
      c0951701
    • Russ Cox's avatar
      runtime: fix nacl/amd64p32 build · 8a7597fd
      Russ Cox authored
      Update #8675
      Fixes nacl/amd64p32 build.
      
      TBR=khr
      CC=golang-codereviews
      https://golang.org/cl/141140045
      8a7597fd
    • Russ Cox's avatar
      runtime: fix windows syscalls for copying stacks · 59dd20f4
      Russ Cox authored
      Syscall and everything it calls must be nosplit:
      we cannot split a stack once Syscall has been invoked,
      because we don't know which of its arguments are
      pointers.
      
      LGTM=khr, r, alex.brainman
      R=dvyukov, iant, khr, r, bradfitz, alex.brainman
      CC=golang-codereviews
      https://golang.org/cl/133670043
      59dd20f4
    • Russ Cox's avatar
      runtime: eliminate Go -> C -> block paths for Solaris · c01c2c88
      Russ Cox authored
      LGTM=aram, r
      R=golang-codereviews, aram, r
      CC=golang-codereviews, iant, khr
      https://golang.org/cl/141180043
      c01c2c88
    • Russ Cox's avatar
      runtime: increase stack split limit again · b6951bcc
      Russ Cox authored
      Increase NOSPLIT reservation from 192 to 384 bytes.
      The problem is that the non-Unix systems (Solaris and Windows)
      just can't make system calls in a small amount of space,
      and then worse they do things that are complex enough
      to warrant calling runtime.throw on failure.
      We don't have time to rewrite the code to use less stack.
      
      I'm not happy about this, but it's still a small amount.
      
      The good news is that we're doing this to get to only
      using copying stacks for stack growth. Once that is true,
      we can drop the default stack size from 8k to 4k, which
      should more than make up for the bytes we're losing here.
      
      LGTM=r
      R=iant, r, bradfitz, aram.h
      CC=golang-codereviews
      https://golang.org/cl/140350043
      b6951bcc
    • Russ Cox's avatar
      misc/makerelease: make goimports-safe · 7230db9e
      Russ Cox authored
      LGTM=bradfitz
      R=adg, bradfitz, minux
      CC=golang-codereviews
      https://golang.org/cl/140310045
      7230db9e
  3. 06 Sep, 2014 8 commits
  4. 05 Sep, 2014 4 commits