-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
Milestone
Description
The liveness analysis is about to get very picky about seeing variables used before they are initialized. It has turned up the following problem in the generated race detector code. When I submit the liveness analysis changes, I will disable the race detector test in run.bash, with a link to this issue. package main func f(x, y []byte) []byte { return append(x, y...) } If you run go tool 6g -W x.go, the output begins: --- before f . RETURN l(4) tc(1) . RETURN-list . . APPEND l(4) tc(1) isddd(1) ARRAY-[]byte . . APPEND-list . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte . . . NAME-main.y u(1) a(1) g(3) l(3) x(24+0) class(PPARAM) f(1) esc(no) ld(1) tc(1) used(1) ARRAY-[]byte after walk f . RETURN-init . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0000 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) ARRAY-[]byte . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte . . IF-init . . . AS u(3) l(4) tc(1) . . . . NAME-main.autotmp_0001 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) int . . . . SUB u(3) l(4) tc(1) int . . . . . ADD u(3) l(4) tc(1) int . . . . . . LEN u(2) l(4) tc(1) int . . . . . . . NAME-main.autotmp_0000 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) ARRAY-[]byte . . . . . . LEN u(2) l(4) tc(1) int . . . . . . . NAME-main.y u(1) a(1) g(3) l(3) x(24+0) class(PPARAM) f(1) esc(no) ld(1) tc(1) used(1) ARRAY-[]byte . . . . . CAP u(2) l(4) tc(1) int . . . . . . NAME-main.autotmp_0000 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) ARRAY-[]byte --- Note that the very first RETURN-init statement is the assignment of x to autotmp_0000. Then some things in the IF-init refer to cap(autotmp_0000). But if you say 6g -race -W x.go. the output begins: --- before f . RETURN l(4) tc(1) . RETURN-list . . APPEND l(4) tc(1) isddd(1) ARRAY-[]byte . . APPEND-list . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte . . . NAME-main.y u(1) a(1) g(3) l(3) x(24+0) class(PPARAM) f(1) esc(no) ld(1) tc(1) used(1) ARRAY-[]byte after walk f . RETURN-init . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0002 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) int . . . LEN u(2) l(4) tc(1) int . . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte . . AS u(3) l(4) tc(1) . . . NAME-main.autotmp_0003 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) int . . . ADD u(3) l(4) tc(1) int . . . . LEN u(2) l(4) tc(1) int . . . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte . . . . LEN u(2) l(4) tc(1) int . . . . . NAME-main.y u(1) a(1) g(3) l(3) x(24+0) class(PPARAM) f(1) esc(no) ld(1) tc(1) used(1) ARRAY-[]byte . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0004 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) uint64 . . . CONV u(2) l(4) tc(1) uint64 . . . . CAP u(2) l(4) tc(1) int . . . . . NAME-main.autotmp_0000 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) ARRAY-[]byte . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0005 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) uint64 . . . CONV u(2) l(4) tc(1) uint64 . . . . NAME-main.autotmp_0003 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) int . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0006 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) uint64 . . . CONV u(2) l(4) tc(1) uint64 . . . . NAME-main.autotmp_0002 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) int . . AS u(2) l(4) tc(1) . . . NAME-main.autotmp_0000 u(1) a(1) l(4) x(0+0) class(PAUTO) esc(N) tc(1) used(1) ARRAY-[]byte . . . NAME-main.x u(1) a(1) g(2) l(3) x(0+0) class(PPARAM) f(1) esc(20) ld(1) tc(1) used(1) ARRAY-[]byte --- The IF-init appears to have been hoisted up above the RETURN-init: the initialization of autotmp_000 happens at the very bottom of the snippet, but there is a reference to cap(autotmp_0000) in the middle of the snippet. This is before racewalk even runs, but appendslice contains an if(flag_race) that generates different code, code that appears to be buggy. Release-Go1.3 because this makes the race detector unusable.