1. 03 Dec, 2018 3 commits
    • Keith Randall's avatar
      cmd/compile: fix static initializer · 4a1a783d
      Keith Randall authored
      staticcopy of a struct or array should recursively call itself, not
      staticassign.
      
      This fixes an issue where a struct with a slice in it is copied during
      static initialization. In this case, the backing array for the slice
      is duplicated, and each copy of the slice refers to a different
      backing array, which is incorrect.  That issue has existed since at
      least Go 1.2.
      
      I'm not sure why this was never noticed. It seems like a pretty
      obvious bug if anyone modifies the resulting slice.
      
      In any case, we started to notice when the optimization in CL 140301
      landed.  Here is basically what happens in issue29013b.go:
      1) The error above happens, so we get two backing stores for what
         should be the same slice.
      2) The code for initializing those backing stores is reused.
         But not duplicated: they are the same Node structure.
      3) The order pass allocates temporaries for the map operations.
         For the first instance, things work fine and two temporaries are
         allocated and stored in the OKEY nodes. For the second instance,
         the order pass decides new temporaries aren't needed, because
         the OKEY nodes already have temporaries in them.
         But the order pass also puts a VARKILL of the temporaries between
         the two instance initializations.
      4) In this state, the code is technically incorrect. But before
         CL 140301 it happens to work because the temporaries are still
         correctly initialized when they are used for the second time. But then...
      5) The new CL 140301 sees the VARKILLs and decides to reuse the
         temporary for instance 1 map 2 to initialize the instance 2 map 1
         map. Because the keys aren't re-initialized, instance 2 map 1
         gets the wrong key inserted into it.
      
      Fixes #29013
      
      Change-Id: I840ce1b297d119caa706acd90e1517a5e47e9848
      Reviewed-on: https://go-review.googlesource.com/c/152081
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
      4a1a783d
    • Carlo Alberto Ferraris's avatar
      net: enable TCP keepalives by default · 5bd7e9c5
      Carlo Alberto Ferraris authored
      This is just the first step in attempting to make all network connection have
      timeouts as a "safe default". TCP keepalives only protect against certain
      classes of network and host issues (e.g. server/OS crash), but do nothing
      against application-level issues (e.g. an application that accepts connections
      but then fails to serve requests).
      
      The actual keep-alive duration (15s) is chosen to cause broken connections
      to be closed after 2~3 minutes (depending on the OS, see #23549 for details).
      We don't make the actual default value part of the public API for a number of
      reasons:
      - because it's not very useful by itself: as discussed in #23549 the actual
        "timeout" after which the connection is torn down is duration*(KEEPCNT+1),
        and we use the OS-wide value for KEEPCNT because there's currently no way
        to set it from Go.
      - because it may change in the future: if users need to rely on a specific
        value they should explicitly set this value instead of relying on the default.
      
      Fixes #23459
      
      Change-Id: I348c03be97588d5001e6de0f377e7a93b51957fd
      Reviewed-on: https://go-review.googlesource.com/c/107196
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      5bd7e9c5
    • Leon Klingele's avatar
      net/http: add StatusTooEarly (425) · 1adbb2bb
      Leon Klingele authored
      StatusTooEarly can be returned to indicate that a server is unwilling
      to accept early data as introduced in TLS 1.3.
      The status code was specified in RFC 8470, section 5.2.
      
      Major supported browsers are:
      - Firefox as of version 58
        https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425#Browser_compatibility
      - Chromium as of version 73.0.3628.1
        https://chromium.googlesource.com/chromium/src/+/58097ec3823e0f340ab5abfcaec1306e1d954c5a
      
      Change-Id: I3f62f4193bae198994d08fde7e92e0ccd080e59a
      GitHub-Last-Rev: fa885040eaf80e0e33b571567108d8a9ded67801
      GitHub-Pull-Request: golang/go#29073
      Reviewed-on: https://go-review.googlesource.com/c/152118Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      1adbb2bb
  2. 02 Dec, 2018 2 commits
  3. 01 Dec, 2018 6 commits
  4. 30 Nov, 2018 10 commits
  5. 29 Nov, 2018 19 commits
    • Keith Randall's avatar
      cmd/compile: eliminate write barriers when writing non-heap ptrs · 2140975e
      Keith Randall authored
      We don't need a write barrier if:
      1) The location we're writing to doesn't hold a heap pointer, and
      2) The value we're writing isn't a heap pointer.
      
      The freshly returned value from runtime.newobject satisfies (1).
      Pointers to globals, and the contents of the read-only data section satisfy (2).
      
      This is particularly helpful for code like:
      p := []string{"abc", "def", "ghi"}
      
      Where the compiler generates:
         a := new([3]string)
         move(a, statictmp_)  // eliminates write barriers here
         p := a[:]
      
      For big slice literals, this makes the code a smaller and faster to
      compile.
      
      Update #13554. Reduces the compile time by ~10% and RSS by ~30%.
      
      Change-Id: Icab81db7591c8777f68e5d528abd48c7e44c87eb
      Reviewed-on: https://go-review.googlesource.com/c/151498
      Run-TryBot: Keith Randall <khr@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarAustin Clements <austin@google.com>
      Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
      2140975e
    • Austin Clements's avatar
      runtime: check more work flushing races · 438b9544
      Austin Clements authored
      This adds several new checks to help debug #27993. It adds a mechanism
      for freezing write barriers and gcWork puts during the mark completion
      algorithm. This way, if we do detect mark completion, we can catch any
      puts that happened during the completion algorithm. Based on build
      dashboard failures, this seems to be the window of time when these are
      happening.
      
      This also double-checks that all work buffers are empty immediately
      upon entering mark termination (much earlier than the current check).
      This is unlikely to trigger based on the current failures, but is a
      good safety net.
      
      Change-Id: I03f56c48c4322069e28c50fbc3c15b2fee2130c2
      Reviewed-on: https://go-review.googlesource.com/c/151797
      Run-TryBot: Austin Clements <austin@google.com>
      Reviewed-by: 's avatarMichael Knyszek <mknyszek@google.com>
      438b9544
    • Ian Lance Taylor's avatar
      cmd/cgo: use field alignment when setting field offset · fbdaa965
      Ian Lance Taylor authored
      The old code ignored the field alignment, and only looked at the field
      offset: if the field offset required padding, cgo added padding. But
      while that approach works for Go (at least with the gc toolchain) it
      doesn't work for C code using packed structs. With a packed struct the
      added padding may leave the struct at a misaligned position, and the
      inserted alignment, which cgo is not considering, may introduce
      additional, unexpected, padding. Padding that ignores alignment is not
      a good idea when the struct is not packed, and Go structs are never
      packed. So don't ignore alignment.
      
      Fixes #28896
      
      Change-Id: Ie50ea15fa6dc35557497097be9fecfecb11efd8a
      Reviewed-on: https://go-review.googlesource.com/c/150602
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      fbdaa965
    • Agniva De Sarker's avatar
      go/doc: convert to unicode quotes for ToText and Synopsis · 81a5c9c3
      Agniva De Sarker authored
      We refactor the conversion of quotes to their unicode equivalent
      to a separate function so that it can be called from ToText and Synopsis.
      
      And we introduce a temp buffer to write the escaped HTML and convert
      the unicode quotes back to html escaped entities. This simplifies the logic
      and gets rid of the need to track the index of the escaped text.
      
      Fixes #27759
      
      Change-Id: I71cf47ddcd4c6794ccdf2898ac25539388b393c1
      Reviewed-on: https://go-review.googlesource.com/c/150377
      Run-TryBot: Robert Griesemer <gri@golang.org>
      Reviewed-by: 's avatarRobert Griesemer <gri@golang.org>
      81a5c9c3
    • Gergely Brautigam's avatar
      runtime: node ordering in mTreap; adjust code to reflect description. · 689fae2d
      Gergely Brautigam authored
      Adjust mTreap ordering logic to reflect the description of mTreap ordering.
      Before it was using unsafe.Pointer in order to gather the base address of
      a span. This has been changed to use base, which is the startAddress of a
      span as the description is telling us in mgclarge.go.
      
      Fixes: golang/go#28805
      
      Change-Id: Ib3cd94a0757e23d135b5d41830f38fc08bcf16a3
      GitHub-Last-Rev: 93f749b6700b1e179de16607a18395d5e162ecc1
      GitHub-Pull-Request: golang/go#28973
      Reviewed-on: https://go-review.googlesource.com/c/151499Reviewed-by: 's avatarMichael Knyszek <mknyszek@google.com>
      Run-TryBot: Michael Knyszek <mknyszek@google.com>
      689fae2d
    • Bryan C. Mills's avatar
      cmd/doc: treat any non-empty GOMOD as module mode · ec4de31c
      Bryan C. Mills authored
      Previously, we were looking for the string go.mod specifically, but
      the module-mode-outside-a-module logic added in CL 148517 sets GOMOD
      to os.DevNull
      
      Updates #28992
      
      Change-Id: I62a4baaa911a495350294d78bae96be3fe4866cb
      Reviewed-on: https://go-review.googlesource.com/c/151617
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      ec4de31c
    • Bryan C. Mills's avatar
      cmd/go/internal/modfetch: document DownloadDir · c37b6ecc
      Bryan C. Mills authored
      Change-Id: I4717964234fca0c8c5889ed710b66f39eb53a809
      Reviewed-on: https://go-review.googlesource.com/c/151562
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      c37b6ecc
    • Bryan C. Mills's avatar
      cmd/go/testdata/mod: remove unused research.swtch.com/vgo-tour · 20950dba
      Bryan C. Mills authored
      The test that used that module was removed in
      https://golang.org/cl/128900.
      
      Change-Id: Id96270a52398c8ccc09821efb2a6a6b4764f44d9
      Reviewed-on: https://go-review.googlesource.com/c/151560
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      20950dba
    • Bryan C. Mills's avatar
      cmd/go/internal/load: remove redundant assignment to BinDir · aab0b704
      Bryan C. Mills authored
      This assignment became a no-op in CL 36196, where both it and the
      preceding assignment were changed to cfg.GOROOTbin (from gorootBin and
      gobin respectively).
      
      Change-Id: If74969c4cc3ffc5d8394ff9d8e8bcec9e0a4e3b0
      Reviewed-on: https://go-review.googlesource.com/c/151561
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      aab0b704
    • Bryan C. Mills's avatar
      cmd/go/internal/modcmd: check for errors in Download · 365a1877
      Bryan C. Mills authored
      Also test that Download restores deleted files.
      
      Updates #27783
      
      Change-Id: If50074dbcffd74ff08fbaa9ad8c314cfdce0b02d
      Reviewed-on: https://go-review.googlesource.com/c/151559
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      365a1877
    • Bryan C. Mills's avatar
      cmd/go: enable module mode without a main module when GO111MODULE=on · cdbd4d49
      Bryan C. Mills authored
      This is as minimal a change as I could comfortably make to enable 'go
      get' outside of a module for 1.12.
      
      In general, commands invoked in module mode while outside of a module
      operate as though they are in a module with an initially-empty go.mod
      file. ('go env GOMOD' reports os.DevNull.)
      
      Commands that operate on the current directory (such as 'go list' and
      'go get -u' without arguments) fail: without a module definition, we
      don't know the package path. Likewise, commands whose sole purpose is
      to write files within the main module (such as 'go mod edit' and 'go
      mod vendor') fail, since we don't know where to write their output.
      
      Since the go.sum file for the main module is authoritative, we do not
      check go.sum files when operating outside of a module. I plan to
      revisit that when the tree opens for 1.13.
      
      We may also want to revisit the behavior of 'go list': it would be
      useful to be able to query individual packages (and dependencies of
      those packages) within versioned modules, but today we only allow
      versioned paths in conjunction with the '-m' flag.
      
      Fixes #24250
      
      RELNOTE=yes
      
      Change-Id: I028c323ddea27693a92ad0aa4a6a55d5e3f43f2c
      Reviewed-on: https://go-review.googlesource.com/c/148517
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      cdbd4d49
    • Bryan C. Mills's avatar
      cmd/go/internal/modfetch/codehost: add lockfiles for repos · a2b4ac6c
      Bryan C. Mills authored
      The lockfile guards calls that may change the repo's filesystem contents.
      
      We don't know how robust VCS implementations are to running
      simultaneous commands, and this way we don't need to care: only one
      'go' command at a time will modify any given repository.
      
      If we can guarantee that particular VCS implementations are robust
      enough across all of the VCS tool versions we support, we may be able
      to remove some of this locking to improve parallelism.
      
      Updates #26794
      
      Change-Id: I578524974f5015629239cef43d3793aee2b9075c
      Reviewed-on: https://go-review.googlesource.com/c/146381
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      a2b4ac6c
    • Bryan C. Mills's avatar
      cmd/go/internal/{modcmd,modload}: lock edits to go.mod · 143c1c82
      Bryan C. Mills authored
      Use an arbitrary lockfile to serialize edits, and use atomic renames
      to actually write the go.mod file so that we never drop version
      requirements due to a command failing partway through a write.
      
      Multiple invocations of the 'go' command may read the go.mod file
      concurrently, and will see some consistent version even if some other
      invocation changes it concurrently.
      
      Multiple commands may attempt to write the go.mod file concurrently.
      One writer will succeed and write a consistent, complete go.mod file.
      The others will detect the changed contents and fail explicitly: it is
      not, in general, possible to resolve two conflicting changes to module
      requirements, so we surface the problem to the user rather than trying
      to solve the problem heuristically.
      
      Updates #26794
      
      Change-Id: Ia1a06a01ef93fa9be664f560eb83bb86b0207443
      Reviewed-on: https://go-review.googlesource.com/c/146380
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      143c1c82
    • Bryan C. Mills's avatar
      cmd/go/internal/modfetch: lock files and directories · 04e12a5b
      Bryan C. Mills authored
      We employ the following new locking mechanisms:
      
      • Zip files and list files within the module cache are written using
        atomic renames of temporary files, so that GOPROXY servers reading
        from the cache will never serve incomplete content.
      
      • A lock file for each module version guards downloading and extraction of
        (immutable) module contents.
      
      • A lock file alongside each version list (named 'list.lock')
        guards updates to the list.
      
      • A single lock file in the module cache guards updates to all go.sum
        files. The go.sum files themselves are written using an atomic
        rename to ensure that we never accidentally discard existing sums.
      
      Updates #26794
      
      RELNOTE=yes
      
      Change-Id: I16ef8b06ee4bd7b94d0c0a6f5d17e1cecc379076
      Reviewed-on: https://go-review.googlesource.com/c/146382
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      04e12a5b
    • Bryan C. Mills's avatar
      cmd/go/internal/modfetch: make Repo.Zip write to an io.Writer instead of a temporary file · ba2e8f65
      Bryan C. Mills authored
      This will be used to eliminate a redundant copy in CL 145178.
      
      (It also decouples two design points that were previously coupled: the
      destination of the zip output and the program logic to write that
      output.)
      
      Updates #26794
      
      Change-Id: I6cfd5a33c162c0016a1b83a278003684560a3772
      Reviewed-on: https://go-review.googlesource.com/c/151341
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      ba2e8f65
    • Bryan C. Mills's avatar
      cmd/go/internal/{clean,test}: lock testexpire.txt · c124a919
      Bryan C. Mills authored
      Also check to make sure we don't overwrite a newer timestamp with an
      older one.
      
      testexpire.txt may be written concurrently, and a partially-written
      timestamp may appear much older than the actual intended one. We don't
      want to re-run tests that should still be cached.
      
      Updates #26794
      
      Change-Id: If56348e799f0e7be3c5bc91b4a336e23ad99f791
      Reviewed-on: https://go-review.googlesource.com/c/146379
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      c124a919
    • Bryan C. Mills's avatar
      cmd/go/internal/lockedfile: add package and support library · 47dc9282
      Bryan C. Mills authored
      lockedfile.File passes through to os.File, with Open, Create, and OpenFile
      functions that mimic the corresponding os functions but acquire locks
      automatically, releasing them when the file is closed.
      
      lockedfile.Sentinel is a simplified wrapper around lockedfile.OpenFile for the
      common use-case of files that signal the status of idempotent tasks.
      
      lockedfile.Mutex is a Mutex-like synchronization primitive implemented in terms
      of file locks.
      
      lockedfile.Read is like ioutil.Read, but obtains a read-lock.
      
      lockedfile.Write is like ioutil.Write, but obtains a write-lock and can be used
      for read-only files with idempotent contents.
      
      Updates #26794
      
      Change-Id: I50f7132c71d2727862eed54411f3f27e1af55cad
      Reviewed-on: https://go-review.googlesource.com/c/145178
      Run-TryBot: Bryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      47dc9282
    • Keith Randall's avatar
      doc: add relnotes for stack objects and mid-stack inlining · a30f8d1e
      Keith Randall authored
      Change-Id: Ief11612b67def93311707165910124d3ce28fb89
      Reviewed-on: https://go-review.googlesource.com/c/151777Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
      a30f8d1e
    • Bryan C. Mills's avatar
      cmd/go/internal/cache: write shared mutable files atomically · 68f49694
      Bryan C. Mills authored
      Updates #26794
      
      Change-Id: I2a50e3b756ff6a2bbaee4737ca7ed053b01c8d0e
      Reviewed-on: https://go-review.googlesource.com/c/146378Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
      68f49694