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: unexpected "invalid memory address or nil pointer dereference" panic #45851

Closed
myitcv opened this issue Apr 29, 2021 · 5 comments
Closed

Comments

@myitcv
Copy link
Member

@myitcv myitcv commented Apr 29, 2021

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

$ go version
go version devel go1.17-e5bc4f2a77 Wed Apr 21 14:16:01 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Not the latest stable release, but also reproduces with b15372f

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/myitcv/gostuff/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/dev/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/dev/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.17-e5bc4f2a77 Wed Apr 21 14:16:01 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build3642011808=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I don't yet have a minimal repro, but hopefully this is a start:

cd $(mktemp -d)
git clone --depth=1 https://github.com/cuelang/cue
cd cue
git checkout 66efc67ca97d67667e98ea69e69e86074cc3b4f3
go test -count=1 -run TestParseDefinitions ./encoding/openapi

Prior to e5bc4f2, this test (and a whole host of others) pass without issues.

What did you expect to see?

A passing test

What did you see instead?

$ go test -count=1 -run TestParseDefinitions ./encoding/openapi
--- FAIL: TestParseDefinitions (0.01s)
    --- FAIL: TestParseDefinitions/array.json (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference
        panic: freeNode: nodeContext out of sync [recovered]
        panic: freeNode: nodeContext out of sync [recovered]
        panic: freeNode: nodeContext out of sync
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x6275ef]

goroutine 10 [running]:
testing.tRunner.func1.2(0x95c140, 0xae14a0)
        /home/myitcv/gos/src/testing/testing.go:1189 +0x265
testing.tRunner.func1()
        /home/myitcv/gos/src/testing/testing.go:1192 +0x226
panic(0x95c140, 0xae14a0)
        /home/myitcv/gos/src/runtime/panic.go:1038 +0x22e
cuelang.org/go/encoding/openapi.schemas.func1()
        /tmp/tmp.tSBcP8Khzr/cue/encoding/openapi/build.go:114 +0x7b
panic(0x95c140, 0xae14a0)
        /home/myitcv/gos/src/runtime/panic.go:1038 +0x22e
cuelang.org/go/internal/core/adt.(*Vertex).freeNode(0xc00008b080, 0xc000390b90)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/eval.go:931 +0x125
panic(0x983c80, 0xe269d0)
        /home/myitcv/gos/src/runtime/panic.go:1047 +0x285
cuelang.org/go/internal/core/adt.BinOp(0x91283a, 0x9, 0xafe3a8, 0xc000400660, 0x0, 0x0)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/binop.go:28 +0x8f
cuelang.org/go/internal/core/adt.equalTerminal(0xc000027cb0, 0xafe3a8, 0xc000400660, 0x0, 0x0, 0xc000151778)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/equality.go:143 +0x331
cuelang.org/go/internal/core/adt.equalVertex(0x0, 0x1, 0xafe3a8, 0xc000400660, 0xa10003)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/equality.go:99 +0x2f1
cuelang.org/go/internal/core/adt.Equal(0xc0003eeea0, 0xafe448, 0xc000418460, 0xafe448, 0xc0004187e0, 0x0)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/equality.go:32 +0x45
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc000418700, 0xc0003905a0, 0xaf1f90, 0x2, 0x101)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/disjunct.go:376 +0xc5c
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc000418000, 0xc00044f4f9, 0x48, 0x0, 0x100)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/disjunct.go:232 +0x1a8f
cuelang.org/go/internal/core/adt.(*OpContext).Unify(0x0, 0xc000152cc8, 0x63ac9b)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/eval.go:281 +0x974
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc0003f9c00, 0xc0003eee05)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/eval.go:669 +0x510
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc000152e48, 0x5)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/eval.go:565 +0x74a
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc0003f9c00, 0x0, 0x0, 0x0, 0x100)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/disjunct.go:151 +0x385
cuelang.org/go/internal/core/adt.(*OpContext).Unify(0xafa298, 0xc0004a36c0, 0x9f3680)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/eval.go:281 +0x974
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(...)
        /tmp/tmp.tSBcP8Khzr/cue/internal/core/adt/composite.go:441
cuelang.org/go/cue.(*Instance).Value(0xc0003cf3b0)
        /tmp/tmp.tSBcP8Khzr/cue/cue/instance.go:274 +0x55
cuelang.org/go/encoding/openapi.schemas(0xc0000b0b40, 0xc0003cf3b0)
        /tmp/tmp.tSBcP8Khzr/cue/encoding/openapi/build.go:120 +0x49a
cuelang.org/go/encoding/openapi.(*Config).All(0x1, 0xc000435e10)
        /tmp/tmp.tSBcP8Khzr/cue/encoding/openapi/openapi.go:107 +0x25
cuelang.org/go/encoding/openapi.Gen(0xc000435e10, 0x1)
        /tmp/tmp.tSBcP8Khzr/cue/encoding/openapi/openapi.go:79 +0x2e
cuelang.org/go/encoding/openapi_test.TestParseDefinitions.func4(0xc00031c9c0)
        /tmp/tmp.tSBcP8Khzr/cue/encoding/openapi/openapi_test.go:143 +0x15f
testing.tRunner(0xc00031c9c0, 0xc0004a3350)
        /home/myitcv/gos/src/testing/testing.go:1239 +0x102
created by testing.(*T).Run
        /home/myitcv/gos/src/testing/testing.go:1286 +0x365
FAIL    cuelang.org/go/encoding/openapi 0.026s
FAIL

cc @cherrymui @dr2chase based on https://go-review.googlesource.com/c/go/+/312094

FYI @mpvl

@myitcv
Copy link
Member Author

@myitcv myitcv commented Apr 29, 2021

Sorry, forgot @thanm from that cc list above.

Loading

@dr2chase
Copy link
Contributor

@dr2chase dr2chase commented Apr 29, 2021

For what it's worth, there's a (stack of) CLs already written that appears to fix this. I'll try to figure out which one, that might let me figure out the root cause. (I.e., I can duplicate it at tip, but not at the top of my stack of CLs).

Loading

@dr2chase
Copy link
Contributor

@dr2chase dr2chase commented Apr 29, 2021

About to binary search for the error.

Loading

@dr2chase
Copy link
Contributor

@dr2chase dr2chase commented Apr 29, 2021

The function is equalVertex at line 40 of cue/internal/core/adt/equality.go, and the problem is incorrect choice of spill locations involving the input parameters.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Apr 29, 2021

Change https://golang.org/cl/313212 mentions this issue: cmd/compile: make the stack allocator more careful about register args.

Loading

@gopherbot gopherbot closed this in 90ec257 May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants