1. 31 Oct, 2019 8 commits
    • Brad Fitzpatrick's avatar
      strings: remove a redundant and flaky part of a test · d6f2f833
      Brad Fitzpatrick authored
      Fixes #35280
      
      Change-Id: I6fa3747ff7b92c6fcabdf8692d85e103de55859f
      Reviewed-on: https://go-review.googlesource.com/c/go/+/204598
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d6f2f833
    • Cuong Manh Le's avatar
      bufio: return the underlying error in ReadFrom if not nil · 48c0cef6
      Cuong Manh Le authored
      If a previous Write returned an error, any subsequent Write or ReadFrom
      must return that error before any operations.
      
      However, only Write behaved correctly and this change fixes that problem
      by making sure that ReadFrom firstly checks for the underlying error.
      
      Fixes #35194
      
      Change-Id: I31356a9e8bd945bc0168b2e3be470f3ae69d4813
      Reviewed-on: https://go-review.googlesource.com/c/go/+/204000
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      48c0cef6
    • Austin Clements's avatar
      runtime: atomically set span state and use as publication barrier · 7de15e36
      Austin Clements authored
      When everything is working correctly, any pointer the garbage
      collector encounters can only point into a fully initialized heap
      span, since the span must have been initialized before that pointer
      could escape the heap allocator and become visible to the GC.
      
      However, in various cases, we try to be defensive against bad
      pointers. In findObject, this is just a sanity check: we never expect
      to find a bad pointer, but programming errors can lead to them. In
      spanOfHeap, we don't necessarily trust the pointer and we're trying to
      check if it really does point to the heap, though it should always
      point to something. Conservative scanning takes this to a new level,
      since it can only guess that a word may be a pointer and verify this.
      
      In all of these cases, we have a problem that the span lookup and
      check can race with span initialization, since the span becomes
      visible to lookups before it's fully initialized.
      
      Furthermore, we're about to start initializing the span without the
      heap lock held, which is going to introduce races where accesses were
      previously protected by the heap lock.
      
      To address this, this CL makes accesses to mspan.state atomic, and
      ensures that the span is fully initialized before setting the state to
      mSpanInUse. All loads are now atomic, and in any case where we don't
      trust the pointer, it first atomically loads the span state and checks
      that it's mSpanInUse, after which it will have synchronized with span
      initialization and can safely check the other span fields.
      
      For #10958, #24543, but a good fix in general.
      
      Change-Id: I518b7c63555b02064b98aa5f802c92b758fef853
      Reviewed-on: https://go-review.googlesource.com/c/go/+/203286
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
      7de15e36
    • Austin Clements's avatar
      runtime: fully initialize span in alloc_m · a9b37ae0
      Austin Clements authored
      Currently, several important fields of a heap span are set by
      heapBits.initSpan, which happens after the span has already been
      published and returned from the locked region of alloc_m. In
      particular, allocBits is set very late, which makes mspan.isFree
      unsafe even if you were to lock the heap because it tries to access
      allocBits.
      
      This CL fixes this by populating these fields in alloc_m. The next CL
      builds on this to only publish the span once it is fully initialized.
      Together, they'll make it safe to check allocBits even if there is a
      race with alloc_m.
      
      For #10958, #24543, but a good fix in general.
      
      Change-Id: I7fde90023af0f497e826b637efa4d19c32840c08
      Reviewed-on: https://go-review.googlesource.com/c/go/+/203285
      Run-TryBot: Austin Clements <austin@google.com>
      Reviewed-by: default avatarCherry Zhang <cherryyz@google.com>
      Reviewed-by: default avatarMichael Knyszek <mknyszek@google.com>
      a9b37ae0
    • Cuong Manh Le's avatar
      bufio: save error from underlying ReadFrom · d5caea77
      Cuong Manh Le authored
      Updates #35194
      
      Change-Id: Ib854bc6250ddeb606d6ff6240179e23b98e4ac62
      Reviewed-on: https://go-review.googlesource.com/c/go/+/203999
      Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      d5caea77
    • Olivier Poitrey's avatar
      crypto/tls: send ec_points_format extension in ServerHello · 02a5502a
      Olivier Poitrey authored
      Follow the recommandation from RFC 8422, section 5.1.2 of sending back the
      ec_points_format extension when requested by the client. This is to fix
      some clients declining the handshake if omitted.
      
      Fixes #31943
      
      Change-Id: I7b04dbac6f9af75cda094073defe081e1e9a295d
      Reviewed-on: https://go-review.googlesource.com/c/go/+/176418
      Run-TryBot: Filippo Valsorda <filippo@golang.org>
      Reviewed-by: default avatarOlivier Poitrey <rs@rhapsodyk.net>
      Reviewed-by: default avatarFilippo Valsorda <filippo@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      02a5502a
    • Daniel Martí's avatar
      encoding/json: avoid work when unquoting strings, take 2 · 54697702
      Daniel Martí authored
      This is a re-submission of CL 151157, since it was reverted in CL 190909
      due to an introduced crash found by a fuzzer. The revert CL included
      regression tests, while this CL includes a fixed version of the original
      change.
      
      In particular, what we forgot in the original optimization was that we
      still need the length and trailing quote checks at the beginning of
      unquoteBytes. Without those, we could end up in a crash later on.
      
      We can work out how many bytes can be unquoted trivially in
      rescanLiteral, which already iterates over a string's bytes.
      
      Removing the extra loop in unquoteBytes simplifies the function and
      speeds it up, especially when decoding simple strings, which are common.
      
      While at it, we can remove the check that s[0]=='"', since all call
      sites already meet that condition.
      
      name           old time/op    new time/op    delta
      CodeDecoder-8    10.6ms ± 2%    10.5ms ± 1%  -1.01%  (p=0.004 n=20+10)
      
      name           old speed      new speed      delta
      CodeDecoder-8   183MB/s ± 2%   185MB/s ± 1%  +1.02%  (p=0.003 n=20+10)
      
      Updates #28923.
      
      Change-Id: I8c6b13302bcd86a364bc998d72451332c0809cde
      Reviewed-on: https://go-review.googlesource.com/c/go/+/190659
      Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarPeter Weinberger <pjw@google.com>
      54697702
    • Michael Munday's avatar
      runtime/internal/atomic: add tests for And8 and Or8 · 10855608
      Michael Munday authored
      Add some simple unit tests for these atomic operations. These can't
      catch all the bugs that are possible with these operations but at
      least they provide some coverage.
      
      Change-Id: I94b9f451fcc9fecdb2a1448c5357b019563ad275
      Reviewed-on: https://go-review.googlesource.com/c/go/+/204317
      Run-TryBot: Michael Munday <mike.munday@ibm.com>
      Reviewed-by: default avatarAustin Clements <austin@google.com>
      10855608
  2. 30 Oct, 2019 12 commits
  3. 29 Oct, 2019 20 commits