golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.63k stars 17.61k forks source link

cmd/compile: [dev.regabi] various ICE and SIGSEGV after OCLOSURE export/import/inline CL #43818

Closed zikaeroh closed 3 years ago

zikaeroh commented 3 years ago

What version of Go are you using (go version)?

$ go version
go version devel +1760d736f6 Wed Jan 20 22:53:32 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

On dev.regabi.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jake/.cache/go-build"
GOENV="/home/jake/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jake/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jake/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/jake/zikaeroh/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/jake/zikaeroh/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jake/zikaeroh/hortbot/hortbot2/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build094418326=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version devel +1760d736f6 Wed Jan 20 22:53:32 2021 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel +1760d736f6 Wed Jan 20 22:53:32 2021 +0000
uname -sr: Linux 5.10.8-zen1-1-zen
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.32.
gdb --version: GNU gdb (GDB) 10.1

What did you do?

Was curious to see how the new inlining code would affect my code, so I built dev.regabi and did a go build in my repo.

What did you expect to see?

Successfully compiling code I can benchmark.

What did you see instead?

ICEs and nil pointer derefs. Packages that repro this are listed in the logs (github.com/robfig/cron/v3, github.com/go-chi/chi/middleware are the smaller ones).

# github.com/hortbot/hortbot/internal/cli/subcommands/graphql
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5eff05]

goroutine 1 [running]:
cmd/compile/internal/ir.(*Name).Op(0x0, 0x5beeb5)
    <autogenerated>:1 +0x5
cmd/compile/internal/ir.HasUniquePos(0xea39c0, 0x0, 0xc000992801)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node.go:506 +0x35
cmd/compile/internal/ir.SetPos(0xea39c0, 0x0, 0xea39c0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node.go:527 +0x65
cmd/compile/internal/typecheck.typecheck(0xea39c0, 0x0, 0x2, 0xea39c0, 0xc00098fc70)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/typecheck.go:288 +0x66
cmd/compile/internal/typecheck.Expr(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/typecheck.go:32
cmd/compile/internal/typecheck.tcClosure(0xc0009987d0, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/func.go:341 +0x188
cmd/compile/internal/typecheck.typecheck1(0xea2890, 0xc0009987d0, 0x2, 0xc0009987d0, 0xc0005b23e0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/typecheck.go:770 +0x19e7
cmd/compile/internal/typecheck.typecheck(0xea2890, 0xc0009987d0, 0x2, 0x4, 0xc0006c4b80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/typecheck.go:371 +0xab9
cmd/compile/internal/typecheck.Expr(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/typecheck.go:32
cmd/compile/internal/inline.(*inlsubst).closure(0xc000997440, 0xc000998140, 0xc00098f520, 0xc000499bf0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1248 +0xad3
cmd/compile/internal/inline.(*inlsubst).node(0xc000997440, 0xea2890, 0xc000998140, 0xea39c0, 0xc00099a0d0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1368 +0x14c5
cmd/compile/internal/ir.(*AssignStmt).editChildren(0xc000998780, 0xc00055dd20)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node_gen.go:163 +0x8f
cmd/compile/internal/ir.EditChildren(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/inline.(*inlsubst).node(0xc000997440, 0xea2250, 0xc000998190, 0xea2250, 0xc000998730)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1374 +0x9e3
cmd/compile/internal/inline.(*inlsubst).list(0xc000997440, 0xc0006c4a00, 0x4, 0x4, 0x1, 0xc00055f680, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1097 +0xbb
cmd/compile/internal/inline.(*inlsubst).closure(0xc000997440, 0xc0009982d0, 0xc00055dce0, 0x645e80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1230 +0x8e8
cmd/compile/internal/inline.(*inlsubst).node(0xc000997440, 0xea2890, 0xc0009982d0, 0xc00055dd50, 0xc00055dd40)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1368 +0x14c5
cmd/compile/internal/inline.(*inlsubst).list(0xc000997440, 0xc00055dc70, 0x1, 0x1, 0x1, 0x1, 0x0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1097 +0xbb
cmd/compile/internal/inline.(*inlsubst).node(0xc000997440, 0xea3e70, 0xc000998320, 0xc00055dd30, 0x10)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1330 +0x2fd
cmd/compile/internal/inline.(*inlsubst).list(0xc000997440, 0xc00055dc80, 0x1, 0x1, 0x1, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:1097 +0xbb
cmd/compile/internal/inline.mkinlcall(0xc000396b00, 0xc00097a9a0, 0xc000000050, 0xc00072a000, 0xc000965a80, 0x0, 0x0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:982 +0x1e89
cmd/compile/internal/inline.inlnode(0xea2638, 0xc000396b00, 0x50, 0xc00072a000, 0xc000965a80, 0xea2c78, 0xc000128a38)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:633 +0x607
cmd/compile/internal/inline.InlineCalls.func1(0xea2638, 0xc000396b00, 0xc000000050, 0xc00072a000)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:520 +0x51
cmd/compile/internal/ir.editNodes(0xc000119100, 0x1, 0x1, 0xc000965a80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node_gen.go:1427 +0x76
cmd/compile/internal/ir.(*CallExpr).editChildren(0xc000396bb0, 0xc000965a80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node_gen.go:280 +0x92
cmd/compile/internal/ir.EditChildren(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/inline.inlnode(0xea2638, 0xc000396bb0, 0x50, 0xc00072a000, 0xc000965a80, 0xea2250, 0xc0004b0be0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:599 +0x206
cmd/compile/internal/inline.InlineCalls.func1(0xea2638, 0xc000396bb0, 0xc0004b0be0, 0xea2250)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:520 +0x51
cmd/compile/internal/ir.editNodes(0xc00039c800, 0x13, 0x20, 0xc000965a80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/node_gen.go:1427 +0x76
cmd/compile/internal/ir.(*Func).editChildren(0xc000178580, 0xc000965a80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/func.go:134 +0x4b
cmd/compile/internal/ir.EditChildren(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/visit.go:185
cmd/compile/internal/inline.InlineCalls(0xc000178580)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:522 +0xed
cmd/compile/internal/inline.InlinePackage.func1(0xc00055d2a0, 0x2, 0x2, 0xc000166600)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:72 +0x76
cmd/compile/internal/ir.(*bottomUpVisitor).visit(0xc000957e00, 0xc000178580, 0xc000000004)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/scc.go:128 +0x2f7
cmd/compile/internal/ir.VisitFuncsBottomUp(0xc000140500, 0x7, 0xa, 0xd840f8)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/ir/scc.go:60 +0x116
cmd/compile/internal/inline.InlinePackage()
    /home/jake/zikaeroh/go/src/cmd/compile/internal/inline/inl.go:59 +0x4f
cmd/compile/internal/gc.Main(0xd83fb8)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/main.go:225 +0x1305
main.main()
    /home/jake/zikaeroh/go/src/cmd/compile/main.go:54 +0xb1
# github.com/robfig/cron/v3
<autogenerated>:1: internal compiler error: cannot export SELRECV2 (102) node
    ==> please file an issue and assign to gri@

goroutine 1 [running]:
runtime/debug.Stack(0xe944a0, 0xc00000e018, 0x0)
    /home/jake/zikaeroh/go/src/runtime/debug/stack.go:24 +0x9f
cmd/compile/internal/base.FatalfAt(0x100000000001, 0xd7d75e, 0x47, 0xc000f62c18, 0x2, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/base/print.go:227 +0x1b9
cmd/compile/internal/base.Fatalf(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea20c0, 0xc0004a5ec0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1536 +0x655
cmd/compile/internal/typecheck.(*exportWriter).node(0xc000dc2a10, 0xea20c0, 0xc0004a5ec0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1073 +0xa5
cmd/compile/internal/typecheck.(*exportWriter).commList(0xc000dc2a10, 0xc000391d70, 0x2, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1235 +0x99
cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc000dc2a10, 0xea3f38, 0xc000442cb0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1182 +0xbb6
cmd/compile/internal/typecheck.(*exportWriter).node(0xc000dc2a10, 0xea3f38, 0xc000442cb0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1071 +0x78
cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc000dc2a10, 0xc000391d50, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1064 +0x6c
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea2890, 0xc0004a7c70)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1350 +0x3ca
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea2bb0, 0xc0004a7c20)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1435 +0xa7e
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea2bb0, 0xc0004a7bd0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1435 +0xa7e
cmd/compile/internal/typecheck.(*exportWriter).exprList(0xc000dc2a10, 0xc000391d30, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1242 +0x6c
cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc000dc2a10, 0xea3e70, 0xc0004a7b80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1141 +0xadc
cmd/compile/internal/typecheck.(*exportWriter).node(0xc000dc2a10, 0xea3e70, 0xc0004a7b80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1071 +0x78
cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc000dc2a10, 0xc0003706c0, 0x4, 0x4)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1064 +0x6c
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea2890, 0xc0004a7a90)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1350 +0x3ca
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc000dc2a10, 0xea2bb0, 0xc0004a7a40)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1435 +0xa7e
cmd/compile/internal/typecheck.(*exportWriter).exprList(0xc000dc2a10, 0xc000391cd0, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1242 +0x6c
cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc000dc2a10, 0xea3e70, 0xc0004a79f0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1141 +0xadc
cmd/compile/internal/typecheck.(*exportWriter).node(0xc000dc2a10, 0xea3e70, 0xc0004a79f0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1071 +0x78
cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc000dc2a10, 0xc000391cb0, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1064 +0x6c
cmd/compile/internal/typecheck.(*exportWriter).funcBody(0xc000dc2a10, 0xc0000c1080)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:1059 +0x8b
cmd/compile/internal/typecheck.(*iexporter).doInline(0xc00008edc0, 0xc00036dc70)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:541 +0xd3
cmd/compile/internal/typecheck.(*exportWriter).funcExt(0xc000dc29a0, 0xc00036dc70)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:997 +0x1cf
cmd/compile/internal/typecheck.(*iexporter).doDecl(0xc00008edc0, 0xc00036dc70)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:458 +0x147
cmd/compile/internal/typecheck.WriteExports(0xc000b57a40)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/typecheck/iexport.go:274 +0x2a6
cmd/compile/internal/gc.dumpexport(0xc0009bbe30)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/export.go:34 +0x18c
cmd/compile/internal/gc.dumpCompilerObj(0xc0009bbe30)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/obj.go:106 +0x39
cmd/compile/internal/gc.dumpobj1(0x7ffd71d69ba7, 0x24, 0x3)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/obj.go:62 +0x174
cmd/compile/internal/gc.dumpobj()
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/obj.go:43 +0x50
cmd/compile/internal/gc.Main(0xd83fb8)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/main.go:299 +0xed4
main.main()
    /home/jake/zikaeroh/go/src/cmd/compile/main.go:54 +0xb1

# github.com/go-chi/chi/middleware
panic: interface conversion: interface {} is nil, not *escape.location

goroutine 1 [running]:
cmd/compile/internal/escape.(*batch).oldLoc(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:1298
cmd/compile/internal/escape.(*escape).exprSkipInit(0xc0005829a0, 0xc0010ed350, 0x0, 0x0, 0x0, 0xea39c0, 0xc0010cfe10)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:603 +0x2c05
cmd/compile/internal/escape.(*escape).expr(0xc0005829a0, 0xc0010ed350, 0x0, 0x0, 0x0, 0xea39c0, 0xc0010cfe10)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:566 +0x7e
cmd/compile/internal/escape.(*escape).call.func1(0xc0010ed350, 0x0, 0x0, 0x0, 0xea39c0, 0xc0010cfe10)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:990 +0x10a
cmd/compile/internal/escape.(*escape).call(0xc0005829a0, 0x0, 0x0, 0x0, 0xea2638, 0xc0010f44d0, 0x0, 0x0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:1036 +0x346
cmd/compile/internal/escape.(*escape).stmt(0xc0005829a0, 0xea2638, 0xc0010f44d0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:535 +0x1853
cmd/compile/internal/escape.(*escape).stmts(0xc0005829a0, 0xc000048660, 0x1, 0x1)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:548 +0x68
cmd/compile/internal/escape.(*escape).block(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:555
cmd/compile/internal/escape.(*escape).stmt(0xc0005829a0, 0xea3128, 0xc0010f8a80)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:429 +0x971
cmd/compile/internal/escape.(*escape).stmts(0xc0005829a0, 0xc001101720, 0x5, 0x5)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:548 +0x68
cmd/compile/internal/escape.(*escape).block(0xc0005829a0, 0xc001101720, 0x5, 0x5)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:555 +0x52
cmd/compile/internal/escape.(*batch).walkFunc(0xc0010ed320, 0xc0010f2420)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:307 +0xec
cmd/compile/internal/escape.(*escape).exprSkipInit(0xc0005827a0, 0xc0010f8f50, 0x0, 0x0, 0x0, 0xea2890, 0xc0011015e0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:784 +0x6f3
cmd/compile/internal/escape.(*escape).expr(0xc0005827a0, 0xc0010f8ee0, 0x0, 0x0, 0x0, 0xea2890, 0xc0011015e0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:566 +0x7e
cmd/compile/internal/escape.(*escape).exprSkipInit(0xc0005827a0, 0xc0010f8ee0, 0x0, 0x0, 0x0, 0xea2bb0, 0xc001101590)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:664 +0x10f7
cmd/compile/internal/escape.(*escape).expr(0xc0005827a0, 0xc0010f8ee0, 0x0, 0x0, 0x0, 0xea2bb0, 0xc001101590)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:566 +0x7e
cmd/compile/internal/escape.(*escape).exprSkipInit(0xc0005827a0, 0xc0010f8ee0, 0x0, 0x0, 0x0, 0xea2bb0, 0xc001101540)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:671 +0x1311
cmd/compile/internal/escape.(*escape).expr(0xc0005827a0, 0xc0010f8ee0, 0x0, 0x0, 0x0, 0xea2bb0, 0xc001101540)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:566 +0x7e
cmd/compile/internal/escape.(*escape).assignList(0xc0005827a0, 0xc000048600, 0x1, 0x1, 0xc000048610, 0x1, 0x1, 0xd5e6af, 0xb, 0xea20c0, ...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:959 +0x238
cmd/compile/internal/escape.(*escape).stmt(0xc0005827a0, 0xea20c0, 0xc0011649c0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:508 +0x1478
cmd/compile/internal/escape.(*escape).stmts(0xc0005827a0, 0xc000582720, 0x2, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:548 +0x68
cmd/compile/internal/escape.(*escape).stmt(0xc0005827a0, 0xea24a8, 0xc0000d0440)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:400 +0x11dd
cmd/compile/internal/escape.(*escape).stmts(0xc0005827a0, 0xc0000d04c0, 0x4, 0x4)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:548 +0x68
cmd/compile/internal/escape.(*escape).expr(0xc0005827a0, 0xc0010f8d90, 0x0, 0x0, 0x0, 0xea2bb0, 0xc0011019a0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:565 +0x48
cmd/compile/internal/escape.(*escape).assignList(0xc0005827a0, 0xc0000487d0, 0x1, 0x1, 0xc000048550, 0x1, 0x1, 0xd57df0, 0x6, 0xea3e70, ...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:959 +0x238
cmd/compile/internal/escape.(*escape).stmt(0xc0005827a0, 0xea3e70, 0xc0011014a0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:533 +0x292
cmd/compile/internal/escape.(*escape).stmts(0xc0005827a0, 0xc0005823a0, 0x2, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:548 +0x68
cmd/compile/internal/escape.(*escape).block(0xc0005827a0, 0xc0005823a0, 0x2, 0x2)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:555 +0x52
cmd/compile/internal/escape.(*batch).walkFunc(0xc0010ed320, 0xc0010f22c0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:307 +0xec
cmd/compile/internal/escape.Batch(0xc001151348, 0x1, 0x1, 0x0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/escape/escape.go:229 +0x232
cmd/compile/internal/reflectdata.methodWrapper(0xc001164600, 0xc000796820, 0x536301)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:1802 +0x7dd
cmd/compile/internal/reflectdata.methods(0xc001164600, 0x10, 0x10fa41f6, 0x4)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:353 +0x1e5
cmd/compile/internal/reflectdata.uncommonSize(...)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:82
cmd/compile/internal/reflectdata.dcommontype(0xc0010e7f80, 0xc001164600, 0xa8)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:719 +0x7c5
cmd/compile/internal/reflectdata.writeType(0xc001164600, 0xc001164600)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:1120 +0x9b3
cmd/compile/internal/reflectdata.dcommontype(0xc000c65980, 0xc000793a40, 0xc000793aa0)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:693 +0xac
cmd/compile/internal/reflectdata.writeType(0xc000793a40, 0xc00115b280)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:1074 +0x1676
cmd/compile/internal/reflectdata.WriteRuntimeTypes()
    /home/jake/zikaeroh/go/src/cmd/compile/internal/reflectdata/reflect.go:1312 +0x346
cmd/compile/internal/gc.dumpdata()
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/obj.go:117 +0x91
cmd/compile/internal/gc.Main(0xd83fb8)
    /home/jake/zikaeroh/go/src/cmd/compile/internal/gc/main.go:297 +0xebf
main.main()
    /home/jake/zikaeroh/go/src/cmd/compile/main.go:54 +0xb1

A bisect points to CL 283112, as expected.

/cc @danscales @mdempsky @randall77 (from the CL)

danscales commented 3 years ago

Thanks, I think I may have already seen this when I lowered the inlining cost of functions with closures. But wanted to get the main change in, since it was stable and passing tests. Will fix this bug next.

mdempsky commented 3 years ago
# github.com/robfig/cron/v3
<autogenerated>:1: internal compiler error: cannot export SELRECV2 (102) node
    ==> please file an issue and assign to gri@

I'm guessing this code has a function that contains a function literal that contains a select statement. We don't currently support inlining select statements, so we shouldn't consider the outer function inlinable either.

# github.com/go-chi/chi/middleware
panic: interface conversion: interface {} is nil, not *escape.location

This looks like Dcl or ClosureVars aren't correct for one of the functions. Either not matching the PAUTO/PPARAM/PPARAMOUT variables used within the function body, or the Defn/Outer for closure variables is mixed up.

cuonglm commented 3 years ago

Another ICE, which also breaks real code, but I made it smallest reproduce:

package main

import "github.com/soheilhy/cmux"

func main() {
    cmux.HTTP2HeaderField("content-type", "application/grpc")
}

which yields:

# command-line-arguments
./main.go:6:23: internal compiler error: 'main.func2': Value live at entry. It shouldn't be. func main.func2, node cmux.value, value nil

goroutine 21 [running]:
runtime/debug.Stack(0x102cf7f68, 0x140000ae008, 0x0)
    /Users/cuonglm/sources/go/src/runtime/debug/stack.go:24 +0x88
cmd/compile/internal/base.FatalfAt(0x9733000000008, 0x140000ee280, 0x46, 0x140003fe000, 0x4, 0x4)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/base/print.go:227 +0x18c
cmd/compile/internal/base.Fatalf(...)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x14000395d10, 0x9733000000008, 0x102b137f1, 0x40, 0x14000395f20, 0x3, 0x3)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:7319 +0x160
cmd/compile/internal/ssagen.(*state).Fatalf(...)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:844
cmd/compile/internal/ssagen.(*state).variable(0x140002f0400, 0x102d07380, 0x14000386f70, 0x140000b0e40, 0x14000094d68)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:6325 +0x310
cmd/compile/internal/ssagen.(*state).expr(0x140002f0400, 0x102d07380, 0x14000386f70, 0x0)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:2296 +0x300c
cmd/compile/internal/ssagen.(*state).stmt(0x140002f0400, 0x102d05c10, 0x140003c3310)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1497 +0x22c
cmd/compile/internal/ssagen.(*state).stmtList(0x140002f0400, 0x1400008f050, 0x1, 0x1)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1268 +0x68
cmd/compile/internal/ssagen.(*state).stmt(0x140002f0400, 0x102d05e68, 0x140000b3c80)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1291 +0x13c8
cmd/compile/internal/ssagen.(*state).stmtList(0x140002f0400, 0x140000b3cc0, 0x3, 0x4)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1268 +0x68
cmd/compile/internal/ssagen.(*state).stmt(0x140002f0400, 0x102d05c10, 0x140003c2f50)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1286 +0xc0
cmd/compile/internal/ssagen.(*state).stmtList(0x140002f0400, 0x140000b3b80, 0x3, 0x4)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:1268 +0x68
cmd/compile/internal/ssagen.buildssa(0x140000f29a0, 0x0, 0x0)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/ssa.go:521 +0xe84
cmd/compile/internal/ssagen.Compile(0x140000f29a0, 0x0)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/ssagen/pgen.go:168 +0x3c
cmd/compile/internal/gc.compileFunctions.func2.1(0x14000300310, 0x140000f29a0, 0x140000ae658, 0x140000b4b20)
    /Users/cuonglm/sources/go/src/cmd/compile/internal/gc/compile.go:127 +0x4c
created by cmd/compile/internal/gc.compileFunctions.func2
    /Users/cuonglm/sources/go/src/cmd/compile/internal/gc/compile.go:125 +0x7c

FAIL
gopherbot commented 3 years ago

Change https://golang.org/cl/285676 mentions this issue: [dev.regabi] cmd/compile: scan body of closure in tooHairy to check for disallowed nodes

gopherbot commented 3 years ago

Change https://golang.org/cl/285992 mentions this issue: [dev.typeparams] all: merge dev.regabi (7e0a81d) into dev.typeparams

gopherbot commented 3 years ago

Change https://golang.org/cl/285677 mentions this issue: [dev.regabi] cmd/compile: fix escape analysis problem with closures

zikaeroh commented 3 years ago

FWIW, the first of the CLs (the tooHairy one) made my code compile and pass tests again.

The lack of tests in the CL is a little spooky, though... :slightly_smiling_face:

cuonglm commented 3 years ago

FWIW, the first of the CLs (the tooHairy one) made my code compile and pass tests again.

The lack of tests in the CL is a little spooky, though... 🙂

Same situation for my report. I think we should definitely add tests. I don't notice the issue until I built my program with my local go dev accidently (I usually do export GO=go1.x.x and build program with stable version).

mdempsky commented 3 years ago

Same situation for my report.

To clarify, "same situation" here means that your test program is now successfully passing as well?

I expect we will add more tests before closing this issue. The fix in CL 285676 though was just very obvious in retrospect.

If someone wants to try writing a regress test that they can confirm fails before that CL and is fixed after, that would be a welcome contribution. I'd recommend something of the form:

func ExportedFunction() func() *int {
  x := new(int)
  return func() *int {
    // [... some code that isn't exportable/inlinable ... ]
    return x
  }
}

A handful of reasonable candidate function bodies would be things like select statements, type declarations, and uses of defer and/or recover (all things we don't currently support inlining). Even better would be to have a separate package that calls foo.ExportedFunction()() to exercise potentially-inlinable calls to the function literals.

Also, FYI, the return x is valuable to make sure the function literal is actually a closure. Currently, we optimize function literals that don't use any free variables during SSA construction. I've been thinking about moving this optimization earlier in the frontend, which could then allow inlining functions even if they contain non-inlinable function literals. (So maybe it's actually worthwhile to have versions of the functions both with and without the return x.)

cuonglm commented 3 years ago

To clarify, "same situation" here means that your test program is now successfully passing as well?

Yes, that's it.

gopherbot commented 3 years ago

Change https://golang.org/cl/286656 mentions this issue: [dev.regabi] repro of issue43818

gopherbot commented 3 years ago

Change https://golang.org/cl/288392 mentions this issue: [dev.regabi] test: add a test for inlining closures

danscales commented 3 years ago

Fixed the bug and just added a test case.