1
0
mirror of https://github.com/golang/go synced 2024-09-29 17:24:34 -06:00
go/test
Keith Randall af7eafd150 cmd/compile: convert 386 port to use addressing modes pass (take 2)
Retrying CL 222782, with a fix that will hopefully stop the random crashing.

The issue with the previous CL is that it does pointer arithmetic
in a way that may briefly generate an out-of-bounds pointer. If an
interrupt happens to occur in that state, the referenced object may
be collected incorrectly.

Suppose there was code that did s[x+c].  The previous CL had a rule
to the effect of ptr + (x + c) -> c + (ptr + x).  But ptr+x is not
guaranteed to point to the same object as ptr. In contrast,
ptr+(x+c) is guaranteed to point to the same object as ptr, because
we would have already checked that x+c is in bounds.

For example, strconv.trim used to have this code:
  MOVZX -0x1(BX)(DX*1), BP
  CMPL $0x30, AL
After CL 222782, it had this code:
  LEAL 0(BX)(DX*1), BP
  CMPB $0x30, -0x1(BP)

An interrupt between those last two instructions could see BP pointing
outside the backing store of the slice involved.

It's really hard to actually demonstrate a bug. First, you need to
have an interrupt occur at exactly the right time. Then, there must
be no other pointers to the object in question. Since the interrupted
frame will be scanned conservatively, there can't even be a dead
pointer in another register or on the stack. (In the example above,
a bug can't happen because BX still holds the original pointer.)
Then, the object in question needs to be collected (or at least
scanned?) before the interrupted code continues.

This CL needs to handle load combining somewhat differently than CL 222782
because of the new restriction on arithmetic. That's the only real
difference (other than removing the bad rules) from that old CL.

This bug is also present in the amd64 rewrite rules, and we haven't
seen any crashing as a result. I will fix up that code similarly to
this one in a separate CL.

Update #37881

Change-Id: I5f0d584d9bef4696bfe89a61ef0a27c8d507329f
Reviewed-on: https://go-review.googlesource.com/c/go/+/225798
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-27 18:54:45 +00:00
..
alias3.dir
bench
chan test/chan: fix trivial typos 2020-03-25 22:22:20 +00:00
closure3.dir
codegen cmd/compile: convert 386 port to use addressing modes pass (take 2) 2020-03-27 18:54:45 +00:00
ddd2.dir
dwarf
fixedbugs test: make runindir tests pass regardless of whether module mode is in use 2020-03-25 14:19:25 +00:00
import2.dir
import4.dir
interface test: add tests for runtime.itab.init 2019-11-06 09:09:59 +00:00
intrinsic.dir
ken
linkname.dir
method4.dir
oldescape_linkname.dir
retjmp.dir
runtime
stress
syntax cmd/compile/internal/syntax: better error when an assignment is used in value context 2020-02-21 22:57:52 +00:00
uintptrescapes.dir
64bit.go
235.go
alg.go
alias1.go
alias2.go
alias3.go
alias.go
align.go
append1.go
append.go
args.go
armimm.go
assign1.go
assign.go
atomicload.go
bigalg.go
bigmap.go
blank1.go
blank.go
bom.go
bombad.go
bounds.go
chancap.go
chanlinear.go
char_lit1.go
char_lit.go
checkbce.go
clearfat.go
closedchan.go
closure1.go
closure2.go
closure3.go
closure4.go
closure.go
cmp6.go
cmp.go
cmplx.go
cmplxdivide1.go
cmplxdivide.c
cmplxdivide.go
complit1.go
complit.go
compos.go
const1.go
const2.go
const3.go
const4.go
const5.go
const6.go
const.go
convert1.go
convert2.go
convert3.go
convert.go
convlit1.go
convlit.go
convT2X.go
copy1.go
copy.go
crlf.go
ddd1.go
ddd2.go
ddd.go
decl.go
declbad.go
defer.go
defererrcheck.go test: re-enable open-coded defer test on riscv64 2020-02-26 16:54:17 +00:00
deferfin.go
defernil.go cmd/compile: on Wasm and AIX, let deferred nil function panic at invocation 2019-10-16 00:05:37 +00:00
deferprint.go
deferprint.out
devirt.go
divide.go
divmod.go
empty.go
env.go
eof1.go
eof.go
escape2.go
escape2n.go
escape3.go
escape4.go
escape5.go
escape_array.go
escape_calls.go
escape_closure.go
escape_field.go
escape_goto.go
escape_hash_maphash.go hash/maphash: mark call into runtime hash function as not escaping 2019-11-16 20:31:45 +00:00
escape_iface.go
escape_indir.go
escape_level.go
escape_map.go
escape_param.go cmd/compile: reimplement parameter leak encoding 2019-10-07 18:50:14 +00:00
escape_runtime_atomic.go
escape_selfassign.go
escape_slice.go
escape_struct_param1.go
escape_struct_param2.go
escape_struct_return.go
escape_sync_atomic.go
escape_unsafe.go
escape.go
fibo.go
finprofiled.go
float_lit2.go
float_lit3.go
float_lit.go
floatcmp.go
for.go
func1.go
func2.go
func3.go
func4.go
func5.go
func6.go
func7.go
func8.go
func.go
funcdup2.go
funcdup.go
gc1.go
gc2.go
gc.go
gcgort.go
gcstring.go
goprint.go test: adjust a test to work with js/wasm's background goroutine 2019-10-10 19:38:06 +00:00
goprint.out
goto.go
heapsampling.go
helloworld.go
helloworld.out
if.go
import1.go
import2.go
import4.go
import5.go
import6.go
import.go
index0.go
index1.go
index2.go
index.go
indirect1.go
indirect.go
init1.go
init.go
initcomma.go
initempty.go cmd/compile: add test for skipping empty init functions 2019-11-04 20:19:15 +00:00
initialize.go
initializerr.go
initloop.go
inline_big.go cmd/compile: output cost while inlining function with Debug['m'] > 1 2020-02-26 14:44:24 +00:00
inline_caller.go
inline_callers.go
inline_literal.go
inline_math_bits_rotate.go
inline_sync.go test: re-enable atomic intrinsic related tests on riscv64 2020-03-25 01:11:15 +00:00
inline_variadic.go
inline.go
int_lit.go
intcvt.go
intrinsic_atomic.go test: re-enable atomic intrinsic related tests on riscv64 2020-03-25 01:11:15 +00:00
intrinsic.go
iota.go
label1.go
label.go
linkmain_run.go test: avoid writing temporary files to GOROOT 2019-11-18 14:40:07 +00:00
linkmain.go
linkname.go
linkobj.go
linkx_run.go
linkx.go [dev.link] all: clean up some TODOs 2019-11-01 20:13:05 +00:00
literal2.go
literal.go
live1.go
live2.go
live_syscall.go
live.go cmd/compile,cmd/link: fix and re-enable open-coded defers on riscv64 2020-01-29 16:34:44 +00:00
locklinear.go
loopbce.go
makechan.go
makemap.go
makenew.go
mallocfin.go
map1.go
map.go
mapclear.go
maplinear.go
mergemul.go
method1.go
method2.go
method3.go
method4.go
method5.go
method6.go
method7.go
method.go
named1.go
named.go
nil.go
nilcheck.go
nilptr2.go
nilptr3.go
nilptr4.go
nilptr5_aix.go
nilptr5_wasm.go
nilptr5.go
nilptr_aix.go
nilptr.go
nosplit.go test: adjust tests for riscv64 2020-01-25 16:30:26 +00:00
notinheap2.go
notinheap3.go
notinheap.go
nowritebarrier.go
nul1.go
opt_branchlikely.go
parentype.go
peano.go
phiopt.go
print.go
print.out
printbig.go
printbig.out
prove.go cmd/compile: remove Greater* and Geq* generic integer ops 2020-02-26 13:11:53 +00:00
range.go
README.md
recover1.go
recover2.go
recover3.go
recover4.go
recover5.go
recover.go
reflectmethod1.go
reflectmethod2.go
reflectmethod3.go
reflectmethod4.go
rename1.go
rename.go
reorder2.go
reorder.go
retjmp.go
return.go
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rotate.go
run.go test: make runindir tests pass regardless of whether module mode is in use 2020-03-25 14:19:25 +00:00
rune.go
runtime.go
shift1.go
shift2.go
sieve.go
sigchld.go
sigchld.out
simassign.go
sinit_run.go test: avoid writing temporary files to GOROOT 2019-11-18 14:40:07 +00:00
sinit.go
sizeof.go
slice3.go
slice3err.go
slicecap.go
sliceopt.go
solitaire.go
stack.go
stackobj2.go
stackobj3.go
stackobj.go
strcopy.go
strength.go
string_lit.go
stringrange.go
struct0.go
switch2.go
switch3.go
switch4.go
switch5.go
switch6.go
switch7.go
switch.go
tinyfin.go
torture.go
turing.go
typecheck.go
typecheckloop.go
typeswitch1.go
typeswitch2.go
typeswitch2b.go cmd/compile/internal/gc: reword "declared and not used" error message 2019-10-28 23:34:13 +00:00
typeswitch3.go
typeswitch.go
uintptrescapes2.go cmd/compile: fix //go:uintptrescapes for basic method calls 2019-11-05 00:26:30 +00:00
uintptrescapes3.go cmd/compile: fix //go:uintptrescapes for basic method calls 2019-11-05 00:26:30 +00:00
uintptrescapes.go
undef.go
utf.go
varerr.go
varinit.go
winbatch.go build: force all Windows batch files to CRLF 2020-03-22 08:42:38 +00:00
writebarrier.go
zerodivide.go

The test directory contains tests of the Go tool chain and runtime. It includes black box tests, regression tests, and error output tests. They are run as part of all.bash.

To run just these tests, execute:

../bin/go run run.go

Standard library tests should be written as regular Go tests in the appropriate package.

The tool chain and runtime also have regular Go tests in their packages. The main reasons to add a new test to this directory are:

  • it is most naturally expressed using the test runner; or
  • it is also applicable to gccgo and other Go tool chains.