1. 11 Apr, 2019 3 commits
    • Cherry Zhang's avatar
      runtime: set itab.fun[0] only on successful conversion · 8d86ef22
      Cherry Zhang authored
      For a failed interface conversion not in ",ok" form, getitab
      calls itab.init to get the name of the missing method for the
      panic message. itab.init will try to find the methods, populate
      the method table as it goes. When some method is missing, it sets
      itab.fun[0] to 0 before return. There is a small window that
      itab.fun[0] could be non-zero.
      
      If concurrently, another goroutine tries to do the same interface
      conversion, it will read the same itab's fun[0]. If this happens
      in the small window, it sees a non-zero fun[0] and thinks the
      conversion succeeded, which is bad.
      
      Fix the race by setting fun[0] to non-zero only when we know the
      conversion succeeds. While here, also simplify the syntax
      slightly.
      
      Fixes #31419.
      
      Change-Id: Ied34d3043079eb933e330c5877b85e13f98f1916
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171759
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      8d86ef22
    • Keith Randall's avatar
      syscall: enforce minimum buffer size to call ReadDirent · 770f2a17
      Keith Randall authored
      freebsd and netbsd require a minimum buffer size of 1K.
      
      Note this doesn't quite fix freebsd, it has other bugs,
      I'll file a separate issue.
      
      Fixes #31403
      
      Change-Id: I9d7e78f6d30859b34715afadc4b8bd3b1ecc606b
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171757
      Run-TryBot: Keith Randall <khr@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      770f2a17
    • Aman Gupta's avatar
      cmd/link/internal/ld: fix c-archive mach-o compatibility · 3cb92fcb
      Aman Gupta authored
      These workarounds predate proper DWARF support
      and are no longer necessary.
      
      Before this patch, running `/usr/bin/symbols go.o`
      using the object in the c-archive would fail, causing
      App Store rejections.
      
      Fixes #31022 #28997
      
      Change-Id: I6a210b6369c13038777c6e21e874e81afcb50c2f
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170377
      Run-TryBot: Ian Lance Taylor <iant@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
      3cb92fcb
  2. 10 Apr, 2019 10 commits
  3. 09 Apr, 2019 8 commits
    • Cherry Zhang's avatar
      cmd/internal/obj/x86: allow non-zero offset in TLS reference · 68c66414
      Cherry Zhang authored
      An instruction that references TLS, e.g.
      
      MOVQ	0(TLS), AX
      
      on some platforms (e.g. Android), or in shared mode, may be
      translated to (assuming TLS offset already loaded to CX)
      
      MOVQ	0(CX)(TLS*1), AX
      
      which in turns translates to
      
      movq	%fs:(%rcx), %rax
      
      We have rejected non-zero offset for TLS reference, like 16(TLS).
      Actually, the instruction can take offset, i.e. it is a valid
      instruction for, e.g.,
      
      movq	%fs:16(%rcx),%rcx
      
      So, allow offset in TLS reference.
      
      Change-Id: Iaf1996bad7fe874e0c298ea441af5acb136a4028
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171151
      Run-TryBot: Cherry Zhang <cherryyz@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      68c66414
    • Tobias Klauser's avatar
      strings: add TestIndexByte · 016625c2
      Tobias Klauser authored
      Add TestIndexByte to package strings similar to the already existing
      TestIndexByte in package bytes.
      
      Change-Id: Ib60695cb326156a4fe48138c66393ebbd11e4a25
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171197
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      016625c2
    • Tobias Klauser's avatar
      strings: use Go style character range comparison in ToUpper/ToLower · 78175474
      Tobias Klauser authored
      As noted by Brad in CL 170954 for package bytes.
      
      Change-Id: I2772a356299e54ba5b7884d537e6649039adb9be
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171198
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      78175474
    • Andrei Vagin's avatar
      runtime: preempt a goroutine which calls a lot of short system calls · 4166ff42
      Andrei Vagin authored
      A goroutine should be preempted if it runs for 10ms without blocking.
      We found that this doesn't work for goroutines which call short system calls.
      
      For example, the next program can stuck for seconds without this fix:
      
      $ cat main.go
      package main
      
      import (
      	"runtime"
      	"syscall"
      )
      
      func main() {
      	runtime.GOMAXPROCS(1)
      	c := make(chan int)
      	go func() {
      		c <- 1
      		for {
      			t := syscall.Timespec{
      				Nsec: 300,
      			}
      			if true {
      				syscall.Nanosleep(&t, nil)
      			}
      		}
      	}()
      	<-c
      }
      
      $ time go run main.go
      
      real	0m8.796s
      user	0m0.367s
      sys	0m0.893s
      
      Updates #10958
      
      Change-Id: Id3be54d3779cc28bfc8b33fe578f13778f1ae2a2
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170138Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      4166ff42
    • Tobias Klauser's avatar
      bytes: optimize ToLower and ToUpper for ASCII-only case · 08e1823a
      Tobias Klauser authored
      Follow what CL 68370 and CL 76470 did for the respective functions in
      package strings.
      
      Also adjust godoc strings to match the respective strings functions and
      mention the special case for ASCII-only byte slices which don't need
      conversion.
      
      name                                       old time/op  new time/op  delta
      ToUpper/#00-8                              9.35ns ± 3%  6.08ns ± 2%  -35.04%  (p=0.000 n=9+9)
      ToUpper/ONLYUPPER-8                        77.7ns ± 1%  16.9ns ± 2%  -78.22%  (p=0.000 n=10+10)
      ToUpper/abc-8                              36.5ns ± 1%  22.1ns ± 1%  -39.43%  (p=0.000 n=10+8)
      ToUpper/AbC123-8                           56.9ns ± 2%  28.2ns ± 2%  -50.54%  (p=0.000 n=8+10)
      ToUpper/azAZ09_-8                          62.3ns ± 1%  26.9ns ± 1%  -56.82%  (p=0.000 n=9+10)
      ToUpper/longStrinGwitHmixofsmaLLandcAps-8   219ns ± 2%    63ns ± 2%  -71.17%  (p=0.000 n=10+10)
      ToUpper/longɐstringɐwithɐnonasciiⱯchars-8   367ns ± 2%   374ns ± 3%   +2.05%  (p=0.000 n=9+10)
      ToUpper/ɐɐɐɐɐ-8                             200ns ± 1%   206ns ± 1%   +2.49%  (p=0.000 n=10+10)
      ToUpper/a\u0080\U0010ffff-8                90.4ns ± 1%  93.8ns ± 0%   +3.82%  (p=0.000 n=10+7)
      ToLower/#00-8                              9.59ns ± 1%  6.13ns ± 2%  -36.08%  (p=0.000 n=10+10)
      ToLower/abc-8                              36.4ns ± 1%  10.4ns ± 1%  -71.50%  (p=0.000 n=10+10)
      ToLower/AbC123-8                           55.8ns ± 1%  27.5ns ± 1%  -50.61%  (p=0.000 n=10+10)
      ToLower/azAZ09_-8                          61.7ns ± 1%  30.2ns ± 1%  -50.98%  (p=0.000 n=8+10)
      ToLower/longStrinGwitHmixofsmaLLandcAps-8   226ns ± 1%    64ns ± 1%  -71.53%  (p=0.000 n=10+9)
      ToLower/LONGⱯSTRINGⱯWITHⱯNONASCIIⱯCHARS-8   354ns ± 0%   361ns ± 0%   +2.18%  (p=0.000 n=10+10)
      ToLower/ⱭⱭⱭⱭⱭ-8                             180ns ± 1%   186ns ± 0%   +3.45%  (p=0.000 n=10+9)
      ToLower/A\u0080\U0010ffff-8                91.7ns ± 0%  94.5ns ± 0%   +2.99%  (p=0.000 n=10+10)
      
      Change-Id: Ifdb8ae328ff9feacd1c170db8eebbf98c399e204
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170954
      Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarKeith Randall <khr@golang.org>
      08e1823a
    • Mikio Hara's avatar
      syscall: gofmt -w -s · 2ab75c0f
      Mikio Hara authored
      Change-Id: Ib46f1a528e16cd0c2617defbf4dcd1f1b582cdc2
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171101
      Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      2ab75c0f
    • Mikio Hara's avatar
      cmd/cover: rename temporary directory prefix for consistency · 7ea4cd3f
      Mikio Hara authored
      This change renames the temporary directory prefix for testing to
      go-testcover from gotestcover. It looks like other packages have the
      "go-" prefix for temporary directories, such as go-build, go-tool-dist
      and go-nettest.
      
      Change-Id: I91ab570d33c4c1bb48e6e01451a811272f6f8b77
      Reviewed-on: https://go-review.googlesource.com/c/go/+/171100Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      7ea4cd3f
    • Neven Sajko's avatar
      all: change the old assembly style AX:CX to CX, AX · 7756a72b
      Neven Sajko authored
      Assembly files with "/vendor/" or "testdata" in their paths were ignored.
      
      Change-Id: I3882ff07eb4426abb9f8ee96f82dff73c81cd61f
      GitHub-Last-Rev: 51ae8c324d72a12a059272fcf8568e670bfaf21b
      GitHub-Pull-Request: golang/go#31166
      Reviewed-on: https://go-review.googlesource.com/c/go/+/170197Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
      Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
      Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      7756a72b
  4. 08 Apr, 2019 17 commits
  5. 07 Apr, 2019 2 commits