Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: internal compiler error: OXDOT in OuterValue #50437

Closed
dsnet opened this issue Jan 5, 2022 · 1 comment
Closed

cmd/compile: internal compiler error: OXDOT in OuterValue #50437

dsnet opened this issue Jan 5, 2022 · 1 comment
Labels
generics NeedsFix

Comments

@dsnet
Copy link
Member

@dsnet dsnet commented Jan 5, 2022

Git bisect reveals a regression stemming from https://go-review.googlesource.com/c/go/+/371554, where the following reproduction crashes with that change, but works just prior to that change.

Reproduction:

$ git clone https://github.com/go-json-experiment/json.git
$ cd json
$ git checkout arshal-funcs
$ go test -vet off# github.com/go-json-experiment/json_test [github.com/go-json-experiment/json.test]
./arshal_funcs_generic.go:50:15: internal compiler error: OXDOT in OuterValue: "github.com/go-json-experiment/json".a.fncCache

goroutine 1 [running]:
runtime/debug.Stack()
    go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x4e9ea2?, 0x0?}, {0xd29d8d, 0x17}, {0xc000619988, 0x1, 0x1})
    go/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/ir.OuterValue({0xe944a0?, 0xc0006307e0?})
    go/src/cmd/compile/internal/ir/node.go:587 +0x1f3
cmd/compile/internal/typecheck.markAddrOf({0xe944a0?, 0xc0006307e0?})
    go/src/cmd/compile/internal/typecheck/subr.go:88 +0x4d
cmd/compile/internal/typecheck.NodAddrAt({0x74efc0?, 0xc0?}, {0xe944a0?, 0xc0006307e0?})
    go/src/cmd/compile/internal/typecheck/subr.go:75 +0x35
cmd/compile/internal/typecheck.(*importReader).node(0xc00074efc0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1637 +0x1190
cmd/compile/internal/typecheck.(*importReader).expr(0x0?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1285 +0x1d
cmd/compile/internal/typecheck.(*importReader).exprList(0xc00074efc0?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1275 +0x47
cmd/compile/internal/typecheck.(*importReader).node(0xc00074efc0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1585 +0x1cf4
cmd/compile/internal/typecheck.(*importReader).expr(0xce9900?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1285 +0x1d
cmd/compile/internal/typecheck.(*importReader).exprList(0xc00074efc0?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1275 +0x47
cmd/compile/internal/typecheck.(*importReader).node(0xc00074efc0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1722 +0x150a
cmd/compile/internal/typecheck.(*importReader).stmtList(0xc00074efc0?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1207 +0x58
cmd/compile/internal/typecheck.(*importReader).node(0xc00074efc0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1737 +0x212b
cmd/compile/internal/typecheck.(*importReader).stmtList(0x4?)
    go/src/cmd/compile/internal/typecheck/iimport.go:1207 +0x58
cmd/compile/internal/typecheck.(*importReader).funcBody(0xc00074efc0, 0xc00090c2c0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1128 +0xa5
cmd/compile/internal/typecheck.(*importReader).doInline(0xca0360?, 0xc00090c2c0)
    go/src/cmd/compile/internal/typecheck/iimport.go:1092 +0x99
cmd/compile/internal/typecheck.ImportBody(0xc00090c2c0)
    go/src/cmd/compile/internal/typecheck/iimport.go:80 +0x206
cmd/compile/internal/noder.checkFetchBody(0xc0008f7860)
    go/src/cmd/compile/internal/noder/stencil.go:638 +0x96
cmd/compile/internal/noder.(*genInst).getInstantiation(0x1390e00, 0xc0008f7860, {0xc00072c880, 0x2, 0x0?}, 0x0?)
    go/src/cmd/compile/internal/noder/stencil.go:659 +0x5a
cmd/compile/internal/noder.(*genInst).instantiateMethods(0x40d387?)
    go/src/cmd/compile/internal/noder/stencil.go:585 +0x24e
cmd/compile/internal/noder.(*genInst).buildInstantiations(0x1390e00, 0x0)
    go/src/cmd/compile/internal/noder/stencil.go:60 +0x3a
cmd/compile/internal/noder.BuildInstantiations(...)
    go/src/cmd/compile/internal/noder/stencil.go:47
cmd/compile/internal/gc.Main(0xd4bd08)
    go/src/cmd/compile/internal/gc/main.go:251 +0xd7c
main.main()
    go/src/cmd/compile/main.go:55 +0xdd

FAIL    github.com/go-json-experiment/json [build failed]

The code builds and runs fine with GOEXPERIMENT=unified:

$ GOEXPERIMENT=unified go.dev test -vet=off
PASS
ok      github.com/go-json-experiment/json  0.970s

\cc @randall77 @danscales @mdempsky

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 5, 2022

Change https://golang.org/cl/375574 mentions this issue: cmd/compile: fix instantiation of types referenced during inlining

@cuonglm cuonglm self-assigned this Jan 5, 2022
@cuonglm cuonglm added generics NeedsFix labels Jan 5, 2022
jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
CL 352870 added extra phase for instantiation after inlining, to take
care of the new fully-instantiated types. However, when fetching inlined
body of these types's methods, we need to allow OADDR operations on
untyped expressions, the same as what main inlining phase does.

The problem does not show up, until CL 371554, which made the compiler
do not re-typecheck while importing, thus leaving a OXDOT node to be
marked as address taken when it's not safe to do that.

Fixes golang#50437

Change-Id: I20076b872182c520075a4f8b84230f5bcb05b341
Reviewed-on: https://go-review.googlesource.com/c/go/+/375574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
@rsc rsc unassigned cuonglm Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generics NeedsFix
Projects
None yet
Development

No branches or pull requests

3 participants