Linux 120.141.167.72.host.secureserver.net 4.18.0-553.150.1.el8_10.x86_64 #1 SMP Fri Jul 31 15:23:31 EDT 2026 x86_64
Apache
: 72.167.141.120 | : 216.73.217.14
808 Domain
7.4.33
bestseocompany
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
usr /
local /
go /
test /
[ HOME SHELL ]
Name
Size
Permission
Action
abi
[ DIR ]
drwxr-xr-x
alias3.dir
[ DIR ]
drwxr-xr-x
arenas
[ DIR ]
drwxr-xr-x
asmhdr.dir
[ DIR ]
drwxr-xr-x
chan
[ DIR ]
drwxr-xr-x
closure3.dir
[ DIR ]
drwxr-xr-x
closure5.dir
[ DIR ]
drwxr-xr-x
codegen
[ DIR ]
drwxr-xr-x
ddd2.dir
[ DIR ]
drwxr-xr-x
dwarf
[ DIR ]
drwxr-xr-x
fixedbugs
[ DIR ]
drwxr-xr-x
import2.dir
[ DIR ]
drwxr-xr-x
import4.dir
[ DIR ]
drwxr-xr-x
interface
[ DIR ]
drwxr-xr-x
intrinsic.dir
[ DIR ]
drwxr-xr-x
ken
[ DIR ]
drwxr-xr-x
linkname.dir
[ DIR ]
drwxr-xr-x
linknameasm.dir
[ DIR ]
drwxr-xr-x
method4.dir
[ DIR ]
drwxr-xr-x
retjmp.dir
[ DIR ]
drwxr-xr-x
runtime
[ DIR ]
drwxr-xr-x
stress
[ DIR ]
drwxr-xr-x
syntax
[ DIR ]
drwxr-xr-x
typeparam
[ DIR ]
drwxr-xr-x
uintptrescapes.dir
[ DIR ]
drwxr-xr-x
235.go
1.56
KB
-rw-r--r--
64bit.go
24.83
KB
-rw-r--r--
README.md
731
B
-rw-r--r--
alg.go
822
B
-rw-r--r--
alias.go
588
B
-rw-r--r--
alias1.go
803
B
-rw-r--r--
alias2.go
2.47
KB
-rw-r--r--
alias3.go
187
B
-rw-r--r--
align.go
603
B
-rw-r--r--
append.go
9.09
KB
-rw-r--r--
append1.go
856
B
-rw-r--r--
args.go
374
B
-rw-r--r--
armimm.go
3.85
KB
-rw-r--r--
asmhdr.go
237
B
-rw-r--r--
assign.go
1.01
KB
-rw-r--r--
assign1.go
5.55
KB
-rw-r--r--
atomicload.go
798
B
-rw-r--r--
bigalg.go
2.12
KB
-rw-r--r--
bigmap.go
2.46
KB
-rw-r--r--
blank.go
2.1
KB
-rw-r--r--
blank1.go
724
B
-rw-r--r--
bom.go
406
B
-rw-r--r--
bombad.go
480
B
-rw-r--r--
bounds.go
6.09
KB
-rw-r--r--
cannotassign.go
1.04
KB
-rw-r--r--
chancap.go
1.57
KB
-rw-r--r--
chanlinear.go
2.12
KB
-rw-r--r--
char_lit.go
657
B
-rw-r--r--
char_lit1.go
822
B
-rw-r--r--
checkbce.go
3.7
KB
-rw-r--r--
clear.go
743
B
-rw-r--r--
clearfat.go
1.15
KB
-rw-r--r--
closedchan.go
5.79
KB
-rw-r--r--
closure.go
1.69
KB
-rw-r--r--
closure1.go
280
B
-rw-r--r--
closure2.go
1.87
KB
-rw-r--r--
closure3.go
358
B
-rw-r--r--
closure4.go
364
B
-rw-r--r--
closure5.go
280
B
-rw-r--r--
closure6.go
346
B
-rw-r--r--
closure7.go
373
B
-rw-r--r--
cmp.go
7.63
KB
-rw-r--r--
cmp6.go
2.16
KB
-rw-r--r--
cmplx.go
1.39
KB
-rw-r--r--
cmplxdivide.c
2.05
KB
-rw-r--r--
cmplxdivide.go
868
B
-rw-r--r--
cmplxdivide1.go
240.68
KB
-rw-r--r--
complit.go
1.71
KB
-rw-r--r--
complit1.go
1.63
KB
-rw-r--r--
compos.go
403
B
-rw-r--r--
const.go
4.78
KB
-rw-r--r--
const1.go
3.79
KB
-rw-r--r--
const2.go
1008
B
-rw-r--r--
const3.go
659
B
-rw-r--r--
const4.go
1.28
KB
-rw-r--r--
const5.go
835
B
-rw-r--r--
const6.go
834
B
-rw-r--r--
const7.go
1.93
KB
-rw-r--r--
const8.go
727
B
-rw-r--r--
convT2X.go
3.33
KB
-rw-r--r--
convert.go
833
B
-rw-r--r--
convert1.go
3.41
KB
-rw-r--r--
convert2.go
5.87
KB
-rw-r--r--
convert3.go
544
B
-rw-r--r--
convert4.go
2.09
KB
-rw-r--r--
convinline.go
4.72
KB
-rw-r--r--
convlit.go
2.39
KB
-rw-r--r--
convlit1.go
458
B
-rw-r--r--
copy.go
6.6
KB
-rw-r--r--
copy1.go
851
B
-rw-r--r--
crlf.go
782
B
-rw-r--r--
ddd.go
4.23
KB
-rw-r--r--
ddd1.go
1.7
KB
-rw-r--r--
ddd2.go
252
B
-rw-r--r--
decl.go
926
B
-rw-r--r--
declbad.go
1.43
KB
-rw-r--r--
defer.go
875
B
-rw-r--r--
defererrcheck.go
1.4
KB
-rw-r--r--
deferfin.go
1.05
KB
-rw-r--r--
defernil.go
563
B
-rw-r--r--
deferprint.go
586
B
-rw-r--r--
deferprint.out
126
B
-rw-r--r--
devirt.go
574
B
-rw-r--r--
directive.go
1.06
KB
-rw-r--r--
directive2.go
1.16
KB
-rw-r--r--
divide.go
1.22
KB
-rw-r--r--
divmod.go
9.28
KB
-rw-r--r--
embedfunc.go
308
B
-rw-r--r--
embedvers.go
292
B
-rw-r--r--
empty.go
316
B
-rw-r--r--
env.go
549
B
-rw-r--r--
eof.go
308
B
-rw-r--r--
eof1.go
333
B
-rw-r--r--
escape.go
3.8
KB
-rw-r--r--
escape2.go
35.11
KB
-rw-r--r--
escape2n.go
35.14
KB
-rw-r--r--
escape3.go
524
B
-rw-r--r--
escape4.go
1.4
KB
-rw-r--r--
escape5.go
5.31
KB
-rw-r--r--
escape_array.go
3.64
KB
-rw-r--r--
escape_calls.go
1.63
KB
-rw-r--r--
escape_closure.go
4.65
KB
-rw-r--r--
escape_field.go
2.92
KB
-rw-r--r--
escape_goto.go
677
B
-rw-r--r--
escape_hash_maphash.go
368
B
-rw-r--r--
escape_iface.go
4.53
KB
-rw-r--r--
escape_indir.go
3.31
KB
-rw-r--r--
escape_level.go
1.79
KB
-rw-r--r--
escape_map.go
2.76
KB
-rw-r--r--
escape_mutations.go
1.79
KB
-rw-r--r--
escape_param.go
8.9
KB
-rw-r--r--
escape_reflect.go
13.05
KB
-rw-r--r--
escape_runtime_atomic.go
874
B
-rw-r--r--
escape_selfassign.go
538
B
-rw-r--r--
escape_slice.go
3.89
KB
-rw-r--r--
escape_struct_param1.go
8.9
KB
-rw-r--r--
escape_struct_param2.go
8.94
KB
-rw-r--r--
escape_struct_return.go
1.04
KB
-rw-r--r--
escape_sync_atomic.go
943
B
-rw-r--r--
escape_unsafe.go
2.17
KB
-rw-r--r--
fibo.go
6.28
KB
-rw-r--r--
finprofiled.go
2.1
KB
-rw-r--r--
float_lit.go
3.95
KB
-rw-r--r--
float_lit2.go
7.88
KB
-rw-r--r--
float_lit3.go
1.72
KB
-rw-r--r--
floatcmp.go
3.03
KB
-rw-r--r--
for.go
1.2
KB
-rw-r--r--
func.go
1.29
KB
-rw-r--r--
func1.go
445
B
-rw-r--r--
func2.go
578
B
-rw-r--r--
func3.go
505
B
-rw-r--r--
func4.go
409
B
-rw-r--r--
func5.go
1.49
KB
-rw-r--r--
func6.go
393
B
-rw-r--r--
func7.go
477
B
-rw-r--r--
func8.go
599
B
-rw-r--r--
funcdup.go
1.31
KB
-rw-r--r--
funcdup2.go
721
B
-rw-r--r--
fuse.go
5.33
KB
-rw-r--r--
gc.go
411
B
-rw-r--r--
gc1.go
303
B
-rw-r--r--
gc2.go
977
B
-rw-r--r--
gcgort.go
34.54
KB
-rw-r--r--
gcstring.go
872
B
-rw-r--r--
goprint.go
722
B
-rw-r--r--
goprint.out
65
B
-rw-r--r--
goto.go
8.39
KB
-rw-r--r--
heapsampling.go
9.67
KB
-rw-r--r--
helloworld.go
269
B
-rw-r--r--
helloworld.out
13
B
-rw-r--r--
if.go
1.36
KB
-rw-r--r--
import.go
425
B
-rw-r--r--
import1.go
703
B
-rw-r--r--
import2.go
247
B
-rw-r--r--
import4.go
310
B
-rw-r--r--
import5.go
722
B
-rw-r--r--
import6.go
1.44
KB
-rw-r--r--
index.go
6.42
KB
-rw-r--r--
index0.go
301
B
-rw-r--r--
index1.go
305
B
-rw-r--r--
index2.go
305
B
-rw-r--r--
indirect.go
1.39
KB
-rw-r--r--
indirect1.go
1.53
KB
-rw-r--r--
init.go
479
B
-rw-r--r--
init1.go
1.08
KB
-rw-r--r--
initcomma.go
1.22
KB
-rw-r--r--
initexp.go
1.74
KB
-rw-r--r--
initialize.go
2.16
KB
-rw-r--r--
initializerr.go
1.15
KB
-rw-r--r--
initloop.go
407
B
-rw-r--r--
inline.go
11.69
KB
-rw-r--r--
inline_big.go
12.69
KB
-rw-r--r--
inline_caller.go
1.36
KB
-rw-r--r--
inline_callers.go
1.87
KB
-rw-r--r--
inline_endian.go
1.63
KB
-rw-r--r--
inline_literal.go
1.02
KB
-rw-r--r--
inline_math_bits_rotate.go
571
B
-rw-r--r--
inline_sync.go
1.62
KB
-rw-r--r--
inline_variadic.go
513
B
-rw-r--r--
int_lit.go
387
B
-rw-r--r--
intcvt.go
4.26
KB
-rw-r--r--
intrinsic.go
270
B
-rw-r--r--
intrinsic_atomic.go
839
B
-rw-r--r--
iota.go
1.59
KB
-rw-r--r--
label.go
1.02
KB
-rw-r--r--
label1.go
2.08
KB
-rw-r--r--
linkmain.go
237
B
-rw-r--r--
linkmain_run.go
2.28
KB
-rw-r--r--
linkname.go
456
B
-rw-r--r--
linkname3.go
720
B
-rw-r--r--
linknameasm.go
210
B
-rw-r--r--
linkobj.go
3.55
KB
-rw-r--r--
linkx.go
741
B
-rw-r--r--
linkx_run.go
1.67
KB
-rw-r--r--
literal.go
4.99
KB
-rw-r--r--
literal2.go
2.22
KB
-rw-r--r--
live.go
18.03
KB
-rw-r--r--
live1.go
1.29
KB
-rw-r--r--
live2.go
953
B
-rw-r--r--
live_regabi.go
18.36
KB
-rw-r--r--
live_uintptrkeepalive.go
2.02
KB
-rw-r--r--
loopbce.go
13.81
KB
-rw-r--r--
mainsig.go
598
B
-rw-r--r--
makechan.go
1.04
KB
-rw-r--r--
makemap.go
1.3
KB
-rw-r--r--
makenew.go
605
B
-rw-r--r--
makeslice.go
5.49
KB
-rw-r--r--
mallocfin.go
1.18
KB
-rw-r--r--
map.go
14.91
KB
-rw-r--r--
map1.go
1.47
KB
-rw-r--r--
mapclear.go
1.49
KB
-rw-r--r--
maplinear.go
3.62
KB
-rw-r--r--
maymorestack.go
1.05
KB
-rw-r--r--
mergemul.go
3.16
KB
-rw-r--r--
method.go
5.24
KB
-rw-r--r--
method1.go
739
B
-rw-r--r--
method2.go
1.21
KB
-rw-r--r--
method3.go
570
B
-rw-r--r--
method4.go
230
B
-rw-r--r--
method5.go
6.73
KB
-rw-r--r--
method6.go
467
B
-rw-r--r--
method7.go
1.15
KB
-rw-r--r--
named.go
4.61
KB
-rw-r--r--
named1.go
984
B
-rw-r--r--
newinline.go
11.16
KB
-rw-r--r--
nil.go
2.23
KB
-rw-r--r--
nilcheck.go
3.67
KB
-rw-r--r--
nilptr.go
3.15
KB
-rw-r--r--
nilptr2.go
3.6
KB
-rw-r--r--
nilptr3.go
5.65
KB
-rw-r--r--
nilptr4.go
428
B
-rw-r--r--
nilptr5.go
844
B
-rw-r--r--
nilptr5_aix.go
806
B
-rw-r--r--
nilptr5_wasm.go
813
B
-rw-r--r--
nilptr_aix.go
3.09
KB
-rw-r--r--
noinit.go
6.79
KB
-rw-r--r--
nosplit.go
11.28
KB
-rw-r--r--
nowritebarrier.go
1.31
KB
-rw-r--r--
nul1.go
1.23
KB
-rw-r--r--
opt_branchlikely.go
2.08
KB
-rw-r--r--
parentype.go
424
B
-rw-r--r--
peano.go
2.22
KB
-rw-r--r--
phiopt.go
2.03
KB
-rw-r--r--
print.go
1.56
KB
-rw-r--r--
print.out
247
B
-rw-r--r--
printbig.go
315
B
-rw-r--r--
printbig.out
41
B
-rw-r--r--
prove.go
21.18
KB
-rw-r--r--
prove_constant_folding.go
604
B
-rw-r--r--
prove_invert_loop_with_unused_...
225
B
-rw-r--r--
range.go
8.14
KB
-rw-r--r--
range2.go
830
B
-rw-r--r--
range3.go
1.27
KB
-rw-r--r--
range4.go
5.11
KB
-rw-r--r--
rangegen.go
8.35
KB
-rw-r--r--
recover.go
10.64
KB
-rw-r--r--
recover1.go
2.5
KB
-rw-r--r--
recover2.go
1.22
KB
-rw-r--r--
recover3.go
1.64
KB
-rw-r--r--
recover4.go
2.2
KB
-rw-r--r--
recover5.go
408
B
-rw-r--r--
reflectmethod1.go
578
B
-rw-r--r--
reflectmethod2.go
719
B
-rw-r--r--
reflectmethod3.go
651
B
-rw-r--r--
reflectmethod4.go
573
B
-rw-r--r--
reflectmethod5.go
544
B
-rw-r--r--
reflectmethod6.go
555
B
-rw-r--r--
reflectmethod7.go
421
B
-rw-r--r--
reflectmethod8.go
479
B
-rw-r--r--
rename.go
1.52
KB
-rw-r--r--
rename1.go
1.14
KB
-rw-r--r--
reorder.go
2.28
KB
-rw-r--r--
reorder2.go
7.22
KB
-rw-r--r--
retjmp.go
252
B
-rw-r--r--
return.go
32.69
KB
-rw-r--r--
rotate.go
3.27
KB
-rw-r--r--
rotate0.go
286
B
-rw-r--r--
rotate1.go
286
B
-rw-r--r--
rotate2.go
286
B
-rw-r--r--
rotate3.go
286
B
-rw-r--r--
rune.go
603
B
-rw-r--r--
runtime.go
600
B
-rw-r--r--
shift1.go
9.43
KB
-rw-r--r--
shift2.go
1.31
KB
-rw-r--r--
shift3.go
834
B
-rw-r--r--
sieve.go
1
KB
-rw-r--r--
sigchld.go
381
B
-rw-r--r--
sigchld.out
17
B
-rw-r--r--
simassign.go
1.12
KB
-rw-r--r--
sizeof.go
2.95
KB
-rw-r--r--
slice3.go
2.92
KB
-rw-r--r--
slice3err.go
5.19
KB
-rw-r--r--
slicecap.go
1.85
KB
-rw-r--r--
sliceopt.go
735
B
-rw-r--r--
solitaire.go
2.9
KB
-rw-r--r--
stack.go
1.69
KB
-rw-r--r--
stackobj.go
975
B
-rw-r--r--
stackobj2.go
1.55
KB
-rw-r--r--
stackobj3.go
1.42
KB
-rw-r--r--
strcopy.go
674
B
-rw-r--r--
strength.go
1.02
KB
-rw-r--r--
string_lit.go
3.58
KB
-rw-r--r--
stringrange.go
1.45
KB
-rw-r--r--
struct0.go
565
B
-rw-r--r--
switch.go
6.53
KB
-rw-r--r--
switch2.go
775
B
-rw-r--r--
switch3.go
1.24
KB
-rw-r--r--
switch4.go
526
B
-rw-r--r--
switch5.go
2.25
KB
-rw-r--r--
switch6.go
1.13
KB
-rw-r--r--
switch7.go
796
B
-rw-r--r--
tighten.go
513
B
-rw-r--r--
tinyfin.go
1.57
KB
-rw-r--r--
torture.go
7.69
KB
-rw-r--r--
turing.go
893
B
-rw-r--r--
typecheck.go
543
B
-rw-r--r--
typecheckloop.go
528
B
-rw-r--r--
typeswitch.go
1.83
KB
-rw-r--r--
typeswitch1.go
1.6
KB
-rw-r--r--
typeswitch2.go
655
B
-rw-r--r--
typeswitch2b.go
598
B
-rw-r--r--
typeswitch3.go
999
B
-rw-r--r--
uintptrescapes.go
250
B
-rw-r--r--
uintptrescapes2.go
2.16
KB
-rw-r--r--
uintptrescapes3.go
1.28
KB
-rw-r--r--
uintptrkeepalive.go
297
B
-rw-r--r--
undef.go
758
B
-rw-r--r--
unsafe_slice_data.go
481
B
-rw-r--r--
unsafe_string.go
367
B
-rw-r--r--
unsafe_string_data.go
479
B
-rw-r--r--
unsafebuiltins.go
2.33
KB
-rw-r--r--
used.go
5.96
KB
-rw-r--r--
utf.go
1.19
KB
-rw-r--r--
varerr.go
449
B
-rw-r--r--
varinit.go
509
B
-rw-r--r--
winbatch.go
1.97
KB
-rw-r--r--
writebarrier.go
5.88
KB
-rw-r--r--
zerodivide.go
5.71
KB
-rw-r--r--
zerosize.go
814
B
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : escape_reflect.go
// errorcheck -0 -m -l // Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Test escape analysis for reflect Value operations. package escape import ( "reflect" "unsafe" ) var sink interface{} func typ(x int) any { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Type() } func kind(x int) reflect.Kind { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Kind() } func int1(x int) int { v := reflect.ValueOf(x) // ERROR "x does not escape" return int(v.Int()) } func ptr(x *int) *int { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x) return (*int)(v.UnsafePointer()) } func bytes1(x []byte) byte { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Bytes()[0] } // Unfortunate: should only escape content. x (the interface storage) should not escape. func bytes2(x []byte) []byte { // ERROR "leaking param: x$" v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Bytes() } func string1(x string) string { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.String() } func string2(x int) string { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.String() } // Unfortunate: should only escape to result. func interface1(x any) any { // ERROR "leaking param: x$" v := reflect.ValueOf(x) return v.Interface() } func interface2(x int) any { v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Interface() } // Unfortunate: should not escape. func interface3(x int) int { v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Interface().(int) } // Unfortunate: should only escape to result. func interface4(x *int) any { // ERROR "leaking param: x$" v := reflect.ValueOf(x) return v.Interface() } func addr(x *int) reflect.Value { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x).Elem() return v.Addr() } // functions returning pointer as uintptr have to escape. func uintptr1(x *int) uintptr { // ERROR "leaking param: x$" v := reflect.ValueOf(x) return v.Pointer() } func unsafeaddr(x *int) uintptr { // ERROR "leaking param: x$" v := reflect.ValueOf(x).Elem() return v.UnsafeAddr() } func ifacedata(x any) [2]uintptr { // ERROR "moved to heap: x" v := reflect.ValueOf(&x).Elem() return v.InterfaceData() } func can(x int) bool { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.CanAddr() || v.CanInt() || v.CanSet() || v.CanInterface() } func is(x int) bool { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.IsValid() || v.IsNil() || v.IsZero() } func is2(x [2]int) bool { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.IsValid() || v.IsNil() || v.IsZero() } func is3(x struct{ a, b int }) bool { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.IsValid() || v.IsNil() || v.IsZero() } func overflow(x int) bool { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.OverflowInt(1 << 62) } func len1(x []int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Len() } func len2(x [3]int) int { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Len() } func len3(x string) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Len() } func len4(x map[int]int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) return v.Len() } func len5(x chan int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) return v.Len() } func cap1(x []int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Cap() } func cap2(x [3]int) int { v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Cap() } func cap3(x chan int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) return v.Cap() } func setlen(x *[]int, n int) { // ERROR "x does not escape" v := reflect.ValueOf(x).Elem() v.SetLen(n) } func setcap(x *[]int, n int) { // ERROR "x does not escape" v := reflect.ValueOf(x).Elem() v.SetCap(n) } // Unfortunate: x doesn't need to escape to heap, just to result. func slice1(x []byte) []byte { // ERROR "leaking param: x$" v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Slice(1, 2).Bytes() } // Unfortunate: x doesn't need to escape to heap, just to result. func slice2(x string) string { // ERROR "leaking param: x$" v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Slice(1, 2).String() } func slice3(x [10]byte) []byte { v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Slice(1, 2).Bytes() } func elem1(x *int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) return int(v.Elem().Int()) } func elem2(x *string) string { // ERROR "leaking param: x to result ~r0 level=1" v := reflect.ValueOf(x) return string(v.Elem().String()) } type S struct { A int B *int C string } func (S) M() {} func field1(x S) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return int(v.Field(0).Int()) } func field2(x S) string { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Field(2).String() } func numfield(x S) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.NumField() } func index1(x []int) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return int(v.Index(0).Int()) } // Unfortunate: should only leak content (level=1) func index2(x []string) string { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Index(0).String() } func index3(x [3]int) int { v := reflect.ValueOf(x) // ERROR "x does not escape" return int(v.Index(0).Int()) } func index4(x [3]string) string { // ERROR "leaking param: x to result ~r0 level=0" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.Index(0).String() } func index5(x string) byte { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return byte(v.Index(0).Uint()) } // Unfortunate: x (the interface storage) doesn't need to escape as the function takes a scalar arg. func call1(f func(int), x int) { // ERROR "leaking param: f$" fv := reflect.ValueOf(f) v := reflect.ValueOf(x) // ERROR "x escapes to heap" fv.Call([]reflect.Value{v}) // ERROR "\[\]reflect\.Value{\.\.\.} does not escape" } func call2(f func(*int), x *int) { // ERROR "leaking param: f$" "leaking param: x$" fv := reflect.ValueOf(f) v := reflect.ValueOf(x) fv.Call([]reflect.Value{v}) // ERROR "\[\]reflect.Value{\.\.\.} does not escape" } func method(x S) reflect.Value { // ERROR "leaking param: x$" v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Method(0) } func nummethod(x S) int { // ERROR "x does not escape" v := reflect.ValueOf(x) // ERROR "x does not escape" return v.NumMethod() } // Unfortunate: k doesn't need to escape. func mapindex(m map[string]string, k string) string { // ERROR "m does not escape" "leaking param: k$" mv := reflect.ValueOf(m) kv := reflect.ValueOf(k) // ERROR "k escapes to heap" return mv.MapIndex(kv).String() } func mapkeys(m map[string]string) []reflect.Value { // ERROR "m does not escape" mv := reflect.ValueOf(m) return mv.MapKeys() } func mapiter1(m map[string]string) *reflect.MapIter { // ERROR "leaking param: m$" mv := reflect.ValueOf(m) return mv.MapRange() } func mapiter2(m map[string]string) string { // ERROR "leaking param: m$" mv := reflect.ValueOf(m) it := mv.MapRange() if it.Next() { return it.Key().String() } return "" } func mapiter3(m map[string]string, it *reflect.MapIter) { // ERROR "leaking param: m$" "it does not escape" mv := reflect.ValueOf(m) it.Reset(mv) } func recv1(ch chan string) string { // ERROR "ch does not escape" v := reflect.ValueOf(ch) r, _ := v.Recv() return r.String() } func recv2(ch chan string) string { // ERROR "ch does not escape" v := reflect.ValueOf(ch) r, _ := v.TryRecv() return r.String() } // Unfortunate: x (the interface storage) doesn't need to escape. func send1(ch chan string, x string) { // ERROR "ch does not escape" "leaking param: x$" vc := reflect.ValueOf(ch) vx := reflect.ValueOf(x) // ERROR "x escapes to heap" vc.Send(vx) } // Unfortunate: x (the interface storage) doesn't need to escape. func send2(ch chan string, x string) bool { // ERROR "ch does not escape" "leaking param: x$" vc := reflect.ValueOf(ch) vx := reflect.ValueOf(x) // ERROR "x escapes to heap" return vc.TrySend(vx) } func close1(ch chan string) { // ERROR "ch does not escape" v := reflect.ValueOf(ch) v.Close() } func select1(ch chan string) string { // ERROR "leaking param: ch$" v := reflect.ValueOf(ch) cas := reflect.SelectCase{Dir: reflect.SelectRecv, Chan: v} _, r, _ := reflect.Select([]reflect.SelectCase{cas}) // ERROR "\[\]reflect.SelectCase{...} does not escape" return r.String() } // Unfortunate: x (the interface storage) doesn't need to escape. func select2(ch chan string, x string) { // ERROR "leaking param: ch$" "leaking param: x$" vc := reflect.ValueOf(ch) vx := reflect.ValueOf(x) // ERROR "x escapes to heap" cas := reflect.SelectCase{Dir: reflect.SelectSend, Chan: vc, Send: vx} reflect.Select([]reflect.SelectCase{cas}) // ERROR "\[\]reflect.SelectCase{...} does not escape" } var ( intTyp = reflect.TypeOf(int(0)) // ERROR "0 does not escape" uintTyp = reflect.TypeOf(uint(0)) // ERROR "uint\(0\) does not escape" stringTyp = reflect.TypeOf(string("")) // ERROR ".. does not escape" bytesTyp = reflect.TypeOf([]byte{}) // ERROR "\[\]byte{} does not escape" ) // Unfortunate: should not escape. func convert1(x int) uint { v := reflect.ValueOf(x) // ERROR "x escapes to heap" return uint(v.Convert(uintTyp).Uint()) } // Unfortunate: should only escape content to result. func convert2(x []byte) string { // ERROR "leaking param: x$" v := reflect.ValueOf(x) // ERROR "x escapes to heap" return v.Convert(stringTyp).String() } // Unfortunate: v doesn't need to leak, x (the interface storage) doesn't need to escape. func set1(v reflect.Value, x int) { // ERROR "leaking param: v$" vx := reflect.ValueOf(x) // ERROR "x escapes to heap" v.Set(vx) } // Unfortunate: a can be stack allocated, x (the interface storage) doesn't need to escape. func set2(x int) int64 { var a int // ERROR "moved to heap: a" v := reflect.ValueOf(&a).Elem() vx := reflect.ValueOf(x) // ERROR "x escapes to heap" v.Set(vx) return v.Int() } func set3(v reflect.Value, x int) { // ERROR "v does not escape" v.SetInt(int64(x)) } func set4(x int) int { var a int v := reflect.ValueOf(&a).Elem() // a should not escape, no error printed v.SetInt(int64(x)) return int(v.Int()) } func set5(v reflect.Value, x string) { // ERROR "v does not escape" "leaking param: x$" v.SetString(x) } func set6(v reflect.Value, x []byte) { // ERROR "v does not escape" "leaking param: x$" v.SetBytes(x) } func set7(v reflect.Value, x unsafe.Pointer) { // ERROR "v does not escape" "leaking param: x$" v.SetPointer(x) } func setmapindex(m map[string]string, k, e string) { // ERROR "m does not escape" "leaking param: k$" "leaking param: e$" mv := reflect.ValueOf(m) kv := reflect.ValueOf(k) // ERROR "k escapes to heap" ev := reflect.ValueOf(e) // ERROR "e escapes to heap" mv.SetMapIndex(kv, ev) } // Unfortunate: k doesn't need to escape. func mapdelete(m map[string]string, k string) { // ERROR "m does not escape" "leaking param: k$" mv := reflect.ValueOf(m) kv := reflect.ValueOf(k) // ERROR "k escapes to heap" mv.SetMapIndex(kv, reflect.Value{}) } // Unfortunate: v doesn't need to leak. func setiterkey1(v reflect.Value, it *reflect.MapIter) { // ERROR "leaking param: v$" "it does not escape" v.SetIterKey(it) } // Unfortunate: v doesn't need to leak. func setiterkey2(v reflect.Value, m map[string]string) { // ERROR "leaking param: v$" "leaking param: m$" it := reflect.ValueOf(m).MapRange() v.SetIterKey(it) } // Unfortunate: v doesn't need to leak. func setitervalue1(v reflect.Value, it *reflect.MapIter) { // ERROR "leaking param: v$" "it does not escape" v.SetIterValue(it) } // Unfortunate: v doesn't need to leak. func setitervalue2(v reflect.Value, m map[string]string) { // ERROR "leaking param: v$" "leaking param: m$" it := reflect.ValueOf(m).MapRange() v.SetIterValue(it) } // Unfortunate: s doesn't need escape, only leak to result. // And x (interface storage) doesn't need to escape. func append1(s []int, x int) []int { // ERROR "leaking param: s$" sv := reflect.ValueOf(s) // ERROR "s escapes to heap" xv := reflect.ValueOf(x) // ERROR "x escapes to heap" rv := reflect.Append(sv, xv) // ERROR "... argument does not escape" return rv.Interface().([]int) } // Unfortunate: s doesn't need escape, only leak to result. func append2(s, x []int) []int { // ERROR "leaking param: s$" "x does not escape" sv := reflect.ValueOf(s) // ERROR "s escapes to heap" xv := reflect.ValueOf(x) // ERROR "x does not escape" rv := reflect.AppendSlice(sv, xv) return rv.Interface().([]int) }
Close