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: compiler crashes with invalid memory reference #60993

Closed
geange opened this issue Jun 25, 2023 · 2 comments
Closed

cmd/compile: compiler crashes with invalid memory reference #60993

geange opened this issue Jun 25, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@geange
Copy link

geange commented Jun 25, 2023

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

$ go version
go version go1.21rc2 darwin/arm64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/geange/Library/Caches/go-build'
GOENV='/Users/geange/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/geange/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/geange/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/Users/geange/sdk/go1.21rc2'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/geange/sdk/go1.21rc2/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21rc2'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/v6/w_fsm5xx1j14j0mrzs9czbt00000gn/T/go-build2508803663=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

go1.21rc2 install github.com/geange/lucene-go/example/core/search/query@4adfbe8341bf4ec5a590ebd5564f6b9c2fcbfcf9

the source code like that:

type BooleanQuery struct {
	minimumNumberShouldMatch int
	clauses                  []*BooleanClause
	clauseSets               map[Occur][]Query
}

func (b *BooleanQuery) Rewrite(reader index.IndexReader) (Query, error) {
	if len(b.clauses) == 0 {
		return nil, errors.New("empty BooleanQuery")
	}
	....
}

when I change the code like that is ok

func (b *BooleanQuery) Rewrite(reader index.IndexReader) (Query, error) {
	if  b.clauses != nil {
		return nil, errors.New("empty BooleanQuery")
	}

	if len(b.clauses) == 0 {
		return nil, errors.New("empty BooleanQuery")
	}
	....
}

What did you expect to see?

build success

What did you see instead?

go: downloading github.com/geange/lucene-go v0.0.0-20230625143616-4adfbe8341bf
# github.com/geange/lucene-go/core/search
go/pkg/mod/github.com/geange/lucene-go@v0.0.0-20230625143616-4adfbe8341bf/core/search/boolean_query.go:42:23: internal compiler error: '(*BooleanQuery).Rewrite': panic during nilcheckelim while compiling (*BooleanQuery).Rewrite:

runtime error: invalid memory address or nil pointer dereference

goroutine 1824 [running]:
cmd/compile/internal/ssa.Compile.func1()
	cmd/compile/internal/ssa/compile.go:49 +0x6c
panic({0x104ad1180?, 0x104ffdf60?})
	runtime/panic.go:914 +0x218
cmd/compile/internal/ssa.storeOrder(...)
	cmd/compile/internal/ssa/schedule.go:387
cmd/compile/internal/ssa.nilcheckelim(0x140048c5040)
	cmd/compile/internal/ssa/nilcheck.go:114 +0x110c
cmd/compile/internal/ssa.Compile(0x140048c5040)
	cmd/compile/internal/ssa/compile.go:97 +0x898
cmd/compile/internal/ssagen.buildssa(0x14001c15a20, 0x1)
	cmd/compile/internal/ssagen/ssa.go:568 +0x2390
cmd/compile/internal/ssagen.Compile(0x14001c15a20, 0x14000491be8?)
	cmd/compile/internal/ssagen/pgen.go:187 +0x34
cmd/compile/internal/gc.compileFunctions.func5.1(0x14002af5c10?)
	cmd/compile/internal/gc/compile.go:184 +0x3c
cmd/compile/internal/gc.compileFunctions.func3.1()
	cmd/compile/internal/gc/compile.go:166 +0x3c
created by cmd/compile/internal/gc.compileFunctions.func3 in goroutine 124
	cmd/compile/internal/gc/compile.go:165 +0x1d8



Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
@ianlancetaylor ianlancetaylor changed the title affected/package: cmd/compile/internal/ssa cmd/compile: compiler crashes with invalid memory reference Jun 26, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jun 26, 2023
@ianlancetaylor
Copy link
Contributor

CC @randall77 @golang/runtime

@cuonglm
Copy link
Member

cuonglm commented Jun 26, 2023

Duplicated with #60982

This was fixed in a031f4e

@cuonglm cuonglm closed this as completed Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

4 participants