go/test
Keith Randall 1b4cf43e42 runtime: size maps.Clone destination bucket array safely
In rare situations, like during same-sized grows, the source map for
maps.Clone may be overloaded (has more than 6.5 entries per
bucket). This causes the runtime to allocate a larger bucket array for
the destination map than for the source map. The maps.Clone code
walks off the end of the source array if it is smaller than the
destination array.

This is a pretty simple fix, ensuring that the destination bucket
array is never longer than the source bucket array. Maybe a better fix
is to make the Clone code handle shorter source arrays correctly, but
this fix is deliberately simple to reduce the risk of backporting this
fix.

Fixes #69110

Change-Id: I824c93d1db690999f25a3c43b2816fc28ace7509
Reviewed-on: https://go-review.googlesource.com/c/go/+/609757
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2024-09-04 16:06:05 +00:00
..
abi
alias3.dir
arenas
asmhdr.dir
chan
closure3.dir cmd/compile: add "deadlocals" pass to remove unused locals 2024-07-30 15:46:27 +00:00
closure5.dir
codegen cmd/compile/internal/ssa: combine shift and addition for riscv64 rva22u64 2024-08-28 13:46:24 +00:00
ddd2.dir
dwarf
fixedbugs runtime: size maps.Clone destination bucket array safely 2024-09-04 16:06:05 +00:00
import2.dir
import4.dir
interface
intrinsic.dir runtime,internal: move runtime/internal/sys to internal/runtime/sys 2024-07-23 19:05:35 +00:00
ken
linkname.dir
linknameasm.dir cmd/compile: generate args_stackmap for ABI0 assembly func regardless of linkname 2024-06-07 15:22:22 +00:00
method4.dir
retjmp.dir
runtime
stress test/stress: fix typo in comment 2024-03-25 19:21:35 +00:00
syntax
typeparam cmd/compile: export/import materialized aliases 2024-04-05 16:29:58 +00:00
uintptrescapes.dir
64bit.go
235.go
alg.go
alias.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
alias1.go
alias2.go cmd/compile/internal/noder: enable type aliases in type checker 2024-05-15 15:09:14 +00:00
alias3.go
align.go
append.go
append1.go
args.go
armimm.go cmd/internal/obj: continue to optimize ARM's constant pool 2017-05-11 13:53:54 +00:00
asmhdr.go
assign.go
assign1.go test: [a-c]: add introductory comments to tests 2012-02-19 13:19:43 +11:00
atomicload.go
bigalg.go
bigmap.go runtime: handle and test large map values 2012-05-24 22:41:07 -04:00
blank.go test: revert changes made for Go SSA interpreter test. 2013-10-08 14:36:20 -04:00
blank1.go
bom.go
bombad.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
bounds.go
cannotassign.go [dev.typeparams] test: add scaffolding to run.go to check compiler with -G flag 2020-12-01 21:49:31 +00:00
chancap.go
chanlinear.go
char_lit.go
char_lit1.go
checkbce.go cmd/compile: rewrite the constant parts of the prove pass 2024-08-07 16:07:33 +00:00
clear.go
clearfat.go
closedchan.go
closure.go test: enforce 1 proc in the test 2012-07-01 21:59:50 +04:00
closure1.go
closure2.go cmd/compile: experimental loop iterator capture semantics change 2023-03-06 18:34:24 +00:00
closure3.go
closure4.go cmd/compile/internal/gc: add nil check for closure call on wasm 2018-08-14 09:19:38 +00:00
closure5.go [dev.regabi] cmd/compile: exporting, importing, and inlining functions with OCLOSURE 2021-01-20 22:53:32 +00:00
closure6.go
closure7.go [dev.regabi] test: add a test for inlining closures 2021-02-01 18:28:05 +00:00
cmp.go Fix several out of date references to 4g/5g/6g/8g/9g. 2015-06-26 03:38:21 +00:00
cmp6.go [dev.typeparams] test: add scaffolding to run.go to check compiler with -G flag 2020-12-01 21:49:31 +00:00
cmplx.go
cmplxdivide.c
cmplxdivide.go
cmplxdivide1.go
complit.go
complit1.go test: fix error check messages for 2 types2 tests 2021-06-02 05:14:45 +00:00
compos.go
const.go cmd/compile: apply constant folding to ORUNESTR 2019-09-26 23:54:29 +00:00
const1.go
const2.go [dev.typeparams] test: add scaffolding to run.go to check compiler with -G flag 2020-12-01 21:49:31 +00:00
const3.go
const4.go all: link to https instead of http 2015-07-11 14:36:33 +00:00
const5.go
const6.go
const7.go
const8.go
convert.go
convert1.go
convert2.go go/types, types2: implement slice-to-array conversions 2022-09-08 15:55:44 +00:00
convert3.go test: [a-c]: add introductory comments to tests 2012-02-19 13:19:43 +11:00
convert4.go cmd/compile: implement slice-to-array conversions 2022-09-19 18:58:26 +00:00
convinline.go
convlit.go
convlit1.go test: [a-c]: add introductory comments to tests 2012-02-19 13:19:43 +11:00
convT2X.go cmd/gc: cache itab lookup in convT2I. 2012-07-03 09:09:05 +10:00
copy.go test: ensure all failing tests exit nonzero. 2013-02-12 13:17:49 -05:00
copy1.go
crlf.go test: use testlib in a few more cases (part 2) 2012-04-20 23:45:43 +08:00
ddd.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
ddd1.go cmd/compile: use "cannot use %s as %s value in %s: %s" error message 2022-09-28 22:28:39 +00:00
ddd2.go
decl.go
declbad.go cmd/compile: rewrite a, b = f() to use temporaries when type not identical 2021-06-14 07:12:37 +00:00
defer.go
defererrcheck.go test: add open-coded defer tests for too many exits path 2024-07-29 14:30:07 +00:00
deferfin.go [dev.regabi] test: enable finalizer tests on !amd64 2021-01-05 21:11:31 +00:00
defernil.go
deferprint.go
deferprint.out
devirt.go [dev.typeparams] cmd/compile: simplify interface conversions 2021-08-09 16:10:20 +00:00
directive.go
directive2.go
divide.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
divmod.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
embedfunc.go cmd/compile: require 'go 1.16' go.mod line for //go:embed 2021-01-19 20:07:52 +00:00
embedvers.go
empty.go test: explanatory comments [c-g]* 2012-02-19 14:28:53 +11:00
env.go
eof.go
eof1.go
escape.go
escape2.go all: remove newline characters after return statements 2023-12-14 17:22:18 +00:00
escape2n.go all: remove newline characters after return statements 2023-12-14 17:22:18 +00:00
escape3.go
escape4.go cmd/compile: retire "IsHiddenClosure" and "IsDeadcodeClosure" 2024-07-22 21:27:37 +00:00
escape5.go cmd/compile/internal/noder: stop preserving original const strings 2023-09-08 18:50:24 +00:00
escape_array.go
escape_calls.go cmd/compile: fix escape analysis of string min/max 2023-12-05 22:06:07 +00:00
escape_closure.go cmd/compile: retire "IsHiddenClosure" and "IsDeadcodeClosure" 2024-07-22 21:27:37 +00:00
escape_field.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_goto.go [dev.typeparams] test: rename blank functions 2021-07-28 21:41:07 +00:00
escape_hash_maphash.go
escape_iface.go
escape_indir.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_level.go
escape_map.go cmd/compile: use clearer error message for stuct literal 2020-09-12 08:31:49 +00:00
escape_mutations.go
escape_param.go [dev.typeparams] cmd/compile: simplify ~r/~b naming 2021-05-26 23:50:32 +00:00
escape_reflect.go cmd/compile/internal/noder: stop preserving original const strings 2023-09-08 18:50:24 +00:00
escape_runtime_atomic.go runtime: migrate internal/atomic to internal/runtime 2024-03-25 19:53:03 +00:00
escape_selfassign.go
escape_slice.go cmd/compile/internal/noder: stop preserving original const strings 2023-09-08 18:50:24 +00:00
escape_struct_param1.go
escape_struct_param2.go
escape_struct_return.go
escape_sync_atomic.go runtime/internal/atomic: remove bad go:noescape annotations on Loadp 2019-04-17 19:09:15 +00:00
escape_unsafe.go test: fix typo in escape_unsafe.go 2022-09-07 17:25:59 +00:00
fibo.go
finprofiled.go test: ignore MemProfileRecords with no live objects in finprofiled.go 2023-11-16 05:48:00 +00:00
float_lit.go test: ensure all failing tests exit nonzero. 2013-02-12 13:17:49 -05:00
float_lit2.go
float_lit3.go
floatcmp.go
for.go
func.go test: explanatory comments [c-g]* 2012-02-19 14:28:53 +11:00
func1.go
func2.go
func3.go test: explanatory comments [c-g]* 2012-02-19 14:28:53 +11:00
func4.go
func5.go
func6.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
func7.go
func8.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
funcdup.go
funcdup2.go [dev.typeparams] test: enable some more errorcheck tests 2020-12-04 21:22:23 +00:00
fuse.go cmd/compile: handle boolean and pointer relations 2024-08-07 16:07:55 +00:00
gc.go test: explanatory comments [c-g]* 2012-02-19 14:28:53 +11:00
gc1.go
gc2.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 test/heapsampling.go: slow down allocation rate and reduce iterations 2022-05-27 21:36:06 +00:00
helloworld.go
helloworld.out
if.go
import.go test: commentary for [h-m]*.go 2012-02-23 18:47:26 +11:00
import1.go
import2.go
import4.go
import5.go cmd/compile: be slightly more tolerant in case of certain syntax errors 2017-03-24 20:07:15 +00:00
import6.go
index.go all: fix typos 2019-09-08 17:28:20 +00:00
index0.go
index1.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
index2.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
indirect.go
indirect1.go test: commentary for [h-m]*.go 2012-02-23 18:47:26 +11:00
init.go [dev.typeparams] merge: merge branch 'dev.regabi' into 'dev.typeparams' 2020-12-14 12:13:36 -08:00
init1.go
initcomma.go test/initcomma.go: restore what it's supposed to be testing 2012-02-20 07:44:24 +11:00
initexp.go cmd/compile: use "init... cycle" instead of "init... loop" in error messages 2022-09-23 20:27:09 +00:00
initialize.go
initializerr.go test: re-enable most go/tests that were disabled because of types2 differences 2022-01-11 02:26:58 +00:00
initloop.go
inline.go cmd/compile: add "deadlocals" pass to remove unused locals 2024-07-30 15:46:27 +00:00
inline_big.go
inline_caller.go runtime: make FuncForPC return the innermost inlined frame 2019-01-08 21:54:04 +00:00
inline_callers.go
inline_endian.go
inline_literal.go
inline_math_bits_rotate.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
inline_sync.go sync: use atomic.Uint32 in Once 2023-10-06 21:01:50 +00:00
inline_variadic.go
int_lit.go test: commentary for [h-m]*.go 2012-02-23 18:47:26 +11:00
intcvt.go
intrinsic.go
intrinsic_atomic.go
iota.go
label.go
label1.go
linkmain.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
linkmain_run.go
linkname.go
linkname3.go cmd/compile: disallow linkname referring to instantiations 2024-05-15 19:27:25 +00:00
linknameasm.go cmd/compile: generate args_stackmap for ABI0 assembly func regardless of linkname 2024-06-07 15:22:22 +00:00
linkobj.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
linkx.go
linkx_run.go
literal.go
literal2.go
live.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live1.go
live2.go cmd/compile/internal/reflectdata: share hmap and hiter types 2023-08-21 23:29:33 +00:00
live_noswiss.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live_regabi.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live_regabi_noswiss.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live_regabi_swiss.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live_swiss.go cmd/compile,runtime: disable swissmap fast variants 2024-08-02 16:47:38 +00:00
live_uintptrkeepalive.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
loopbce.go cmd/compile: rewrite the constant parts of the prove pass 2024-08-07 16:07:33 +00:00
mainsig.go
makechan.go all: fix some comments 2024-04-04 14:29:45 +00:00
makemap.go
makenew.go [dev.typeparams] test: enable some more errorcheck tests 2020-12-04 21:22:23 +00:00
makeslice.go cmd/compile: optimize make+copy pattern to avoid memclr 2020-05-07 17:50:24 +00:00
mallocfin.go test: commentary for [h-m]*.go 2012-02-23 18:47:26 +11:00
map.go
map1.go
mapclear.go
maplinear.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
maymorestack.go cmd/{asm,compile,internal/obj}: add "maymorestack" support 2021-11-05 00:52:06 +00:00
mergemul.go cmd/compile: combine x*n - y*n into (x-y)*n 2017-09-03 14:29:38 +00:00
method.go test: a number of fixes. 2013-02-11 18:20:52 -05:00
method1.go cmd/compile: use "method T.m already declared" for method redeclaration errors 2022-09-27 21:59:19 +00:00
method2.go go/types, types2: better error message when using *interface instead of interface 2022-01-10 22:48:40 +00:00
method3.go test: commentary for [h-m]*.go 2012-02-23 18:47:26 +11:00
method4.go
method5.go
method6.go
method7.go [dev.typeparams] cmd/compile: fix MethodExpr handling with embedded fields 2021-01-26 17:05:06 +00:00
named.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
named1.go
newinline.go cmd/compile: add "deadlocals" pass to remove unused locals 2024-07-30 15:46:27 +00:00
nil.go
nilcheck.go
nilptr.go
nilptr2.go test: use a real use function in nilptr2.go 2019-05-11 03:02:33 +00:00
nilptr3.go
nilptr4.go
nilptr5.go
nilptr5_aix.go
nilptr5_wasm.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
nilptr_aix.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
noinit.go
nosplit.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
nowritebarrier.go cmd/compile: redo IsRuntimePkg/IsReflectPkg predicate 2023-08-22 19:18:21 +00:00
nul1.go
opt_branchlikely.go
parentype.go test/[n-r]*.go: add documentation 2012-02-24 10:30:39 +11:00
peano.go all: skip unsupported tests for js/wasm 2018-04-30 19:39:18 +00:00
phiopt.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
print.go
print.out
printbig.go
printbig.out
prove.go cmd/compile: compute Negation's limits from argument's limits 2024-09-03 21:12:20 +00:00
prove_constant_folding.go cmd/compile: rewrite the constant parts of the prove pass 2024-08-07 16:07:33 +00:00
prove_invert_loop_with_unused_iterators.go
range.go
range2.go all: rename GOEXPERIMENT=range to rangefunc 2023-11-08 15:32:14 +00:00
range3.go cmd/compile: fix typecheck range over rune literal 2023-12-01 17:20:08 +00:00
range4.go cmd/compile: handle defined iter func type correctly 2024-01-08 16:00:53 +00:00
rangegen.go test: skip rangegen.go on 32-bit platforms 2023-12-18 23:35:19 +00:00
README.md
recover.go
recover1.go
recover2.go
recover3.go
recover4.go
recover5.go cmd/compile: more error position tests for the typechecker 2017-04-24 12:37:49 +00:00
reflectmethod1.go
reflectmethod2.go cmd/compile: track reflect.Type.Method in deadcode 2016-03-11 21:19:20 +00:00
reflectmethod3.go
reflectmethod4.go
reflectmethod5.go cmd/compile: when marking REFLECTMETHOD, check for reflect package itself 2020-04-19 03:12:32 +00:00
reflectmethod6.go
reflectmethod7.go all: use reflect.{Pointer,PointerTo} 2021-10-26 14:24:17 +00:00
reflectmethod8.go
rename.go
rename1.go
reorder.go [dev.regabi] cmd/compile: cleanup OAS2FUNC ordering 2021-01-16 23:19:26 +00:00
reorder2.go
retjmp.go cmd/asm: fix assembling return jump 2018-03-01 21:11:16 +00:00
return.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
rotate.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
rotate0.go
rotate1.go
rotate2.go
rotate3.go
rune.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
runtime.go [dev.typeparams] cmd/compile/internal/types2: adjusted qualified identifier error message for compiler 2020-12-09 23:56:19 +00:00
shift1.go
shift2.go
shift3.go cmd/compile: adjust types2 shift check to match go/types (cleanup) 2022-04-07 17:19:55 +00:00
sieve.go
sigchld.go test: migrate remaining files to go:build syntax 2023-10-19 23:33:25 +00:00
sigchld.out
simassign.go test/[n-z]*.go: add documentation 2012-02-24 11:48:19 +11:00
sizeof.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
slice3.go
slice3err.go
slicecap.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
sliceopt.go
solitaire.go
stack.go
stackobj.go
stackobj2.go
stackobj3.go cmd/compile,runtime: remove ambiguously live logic 2018-10-03 19:54:16 +00:00
strcopy.go
strength.go
string_lit.go
stringrange.go all: make Unicode surrogate halves illegal as UTF-8 2012-08-08 14:01:23 -07:00
struct0.go
switch.go
switch2.go
switch3.go [dev.typeparams] cmd/compile/internal/types2: report error for invalid (but empty) expr switch 2020-12-15 19:43:32 +00:00
switch4.go cmd/gc: disallow fallthrough in final case of switch 2013-03-15 00:35:09 -04:00
switch5.go
switch6.go
switch7.go
tighten.go
tinyfin.go runtime: fix finalization and profiling of tiny allocations 2015-11-03 18:57:18 +00:00
torture.go
turing.go
typecheck.go test: re-enable most go/tests that were disabled because of types2 differences 2022-01-11 02:26:58 +00:00
typecheckloop.go cmd/compile: use "init... cycle" instead of "init... loop" in error messages 2022-09-23 20:27:09 +00:00
typeswitch.go
typeswitch1.go
typeswitch2.go
typeswitch2b.go go/types, types2: use "and not used" instead of "but not used" in error messages 2022-09-27 21:10:19 +00:00
typeswitch3.go
uintptrescapes.go
uintptrescapes2.go [dev.typeparams] cmd/compile: skip escape analysis diagnostics for wrappers 2021-06-24 18:24:24 +00:00
uintptrescapes3.go
uintptrkeepalive.go
undef.go all: make copyright headers consistent with one space after period 2016-05-02 13:43:18 +00:00
unsafe_slice_data.go cmd/compile: add support for unsafe.{String,StringData,SliceData} 2022-08-31 17:15:15 +00:00
unsafe_string.go
unsafe_string_data.go
unsafebuiltins.go cmd/compile: add support for unsafe.{String,StringData,SliceData} 2022-08-31 17:15:15 +00:00
used.go [dev.typeparams] all: merge dev.regabi (07569da) into dev.typeparams 2020-12-28 00:39:17 -08:00
utf.go test/[n-z]*.go: add documentation 2012-02-24 11:48:19 +11:00
varerr.go [dev.typeparams] test: enable some more errorcheck tests 2020-12-04 21:22:23 +00:00
varinit.go
wasmexport.go cmd/compile: add basic wasmexport support 2024-08-09 20:07:54 +00:00
wasmexport2.go test: add test case for wasmexport parameter types 2024-08-13 16:25:24 +00:00
winbatch.go
writebarrier.go
zerodivide.go all: use bytes.Cut, strings.Cut 2021-10-06 15:53:04 +00:00
zerosize.go cmd/link: put zero-sized data symbols at same address as runtime.zerobase 2023-04-28 18:35:43 +00:00

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 test cmd/internal/testdir

To run just tests from specified files in this directory, execute:

../bin/go test cmd/internal/testdir -run='Test/(file1.go|file2.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.