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

x/mobile: Panic on gobind #33996

Closed
neilalexander opened this issue Aug 31, 2019 · 3 comments
Closed

x/mobile: Panic on gobind #33996

neilalexander opened this issue Aug 31, 2019 · 3 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@neilalexander
Copy link
Contributor

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

$ go version
go version go1.12.9 darwin/amd64

$ gomobile version
gomobile version +c6da959 Fri Aug 30 20:13:51 2019 +0000 (android,ios); androidSDK=

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/neilalexander/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/neilalexander/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cv/wv7k9w2s4qdfjfd60nd7_5t40000gn/T/go-build196342319=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Using gomobile to create an iOS framework.

The source package seems to be irrelevant in this instance—this panic happens when trying to gobind from any package source. Any of the following reproduces the issue:

~/go/bin/gomobile bind -target ios -tags mobile github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil
~/go/bin/gobind -lang=go,objc -tags=mobile,ios github.com/yggdrasil-network/yggdrasil-go/src/yggdrasil

~/go/bin/gomobile bind -target ios -tags mobile github.com/yggdrasil-network/yggdrasil-go/src/config
~/go/bin/gobind -lang=go,objc -tags=mobile,ios github.com/yggdrasil-network/yggdrasil-go/src/config

~/go/bin/gomobile bind -target ios -tags mobile github.com/hjson/hjson-go
~/go/bin/gobind -lang=go,objc -tags=mobile,ios github.com/hjson/hjson-go

This only started after upgrading gobind/gomobile to the latest (I am not sure what commit I was using before sadly).

What did you expect to see?

The .framework should have been built.

What did you see instead?

A panic occurs:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11b3bbc]

goroutine 23 [running]:
go/types.(*Checker).handleBailout(0xc00036e000, 0xc00038dd08)
	/usr/local/go/src/go/types/check.go:240 +0x98
panic(0x1338ae0, 0x16270a0)
	/usr/local/go/src/runtime/panic.go:522 +0x1b5
go/types.(*StdSizes).Sizeof(0x0, 0x140ae80, 0x1627da0, 0x1627f80)
	/usr/local/go/src/go/types/sizes.go:154 +0x1bc
go/types.(*Config).sizeof(0xc00036c000, 0x140ae80, 0x1627da0, 0xc000104601)
	/usr/local/go/src/go/types/sizes.go:245 +0x51
go/types.representableConst(0x140fd80, 0xc000104648, 0xc00036e000, 0x1627da0, 0xc00036c2a8, 0xc00038c738)
	/usr/local/go/src/go/types/expr.go:216 +0x207
go/types.(*Checker).representable(0xc00036e000, 0xc00036c280, 0x1627da0)
	/usr/local/go/src/go/types/expr.go:335 +0x69
go/types.(*Checker).convertUntyped(0xc00036e000, 0xc00036c280, 0x140ae80, 0x1627da0)
	/usr/local/go/src/go/types/expr.go:517 +0x939
go/types.(*Checker).assignment(0xc00036e000, 0xc00036c280, 0x140ae80, 0x1627da0, 0x139228d, 0xe)
	/usr/local/go/src/go/types/assignments.go:46 +0x150
go/types.(*Checker).exprInternal(0xc00036e000, 0xc00036c280, 0x140ea80, 0xc0001ecc00, 0x0, 0x0, 0xc00010454c)
	/usr/local/go/src/go/types/expr.go:1125 +0x10ae
go/types.(*Checker).rawExpr(0xc00036e000, 0xc00036c280, 0x140ea80, 0xc0001ecc00, 0x0, 0x0, 0x0)
	/usr/local/go/src/go/types/expr.go:982 +0x81
go/types.(*Checker).multiExpr(0xc00036e000, 0xc00036c280, 0x140ea80, 0xc0001ecc00)
	/usr/local/go/src/go/types/expr.go:1599 +0x58
go/types.(*Checker).initVars.func1(0xc00036c280, 0x0)
	/usr/local/go/src/go/types/assignments.go:209 +0x5a
go/types.unpack(0xc0000a9240, 0x1, 0x134a600, 0x20006d0, 0xc000036400, 0x20006d0)
	/usr/local/go/src/go/types/call.go:181 +0x61
go/types.(*Checker).initVars(0xc00036e000, 0xc00007a1c8, 0x1, 0x1, 0xc000212140, 0x1, 0x1, 0xcbd)
	/usr/local/go/src/go/types/assignments.go:209 +0xd8
go/types.(*Checker).stmt(0xc00036e000, 0x0, 0x140f040, 0xc000218620)
	/usr/local/go/src/go/types/stmt.go:447 +0x371f
go/types.(*Checker).stmtList(0xc00036e000, 0x0, 0xc000212150, 0x1, 0x1)
	/usr/local/go/src/go/types/stmt.go:120 +0xd1
go/types.(*Checker).funcBody(0xc00036e000, 0xc0002d29c0, 0xc0001ee1c4, 0xb, 0xc0000f5050, 0xc00012c2d0, 0x0, 0x0)
	/usr/local/go/src/go/types/stmt.go:42 +0x1ec
go/types.(*Checker).funcDecl.func1()
	/usr/local/go/src/go/types/decl.go:561 +0x67
go/types.(*Checker).processDelayed(0xc00036e000, 0x0)
	/usr/local/go/src/go/types/resolver.go:615 +0x33
go/types.(*Checker).checkFiles(0xc00036e000, 0xc0000401e0, 0x2, 0x2, 0x0, 0x0)
	/usr/local/go/src/go/types/check.go:256 +0xbc
go/types.(*Checker).Files(...)
	/usr/local/go/src/go/types/check.go:245
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0000b08c0, 0xc0001cb440)
	/Users/neilalexander/go/src/golang.org/x/tools/go/packages/packages.go:808 +0x540
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
	/Users/neilalexander/go/src/golang.org/x/tools/go/packages/packages.go:666 +0x17f
sync.(*Once).Do(0xc0001cb450, 0xc000030f80)
	/usr/local/go/src/sync/once.go:44 +0xb3
golang.org/x/tools/go/packages.(*loader).loadRecursive(0xc0000b08c0, 0xc0001cb440)
	/Users/neilalexander/go/src/golang.org/x/tools/go/packages/packages.go:653 +0x67
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1.1(0xc0000b08c0, 0xc0001c8d80, 0xc0001cb440)
	/Users/neilalexander/go/src/golang.org/x/tools/go/packages/packages.go:660 +0x35
created by golang.org/x/tools/go/packages.(*loader).loadRecursive.func1
	/Users/neilalexander/go/src/golang.org/x/tools/go/packages/packages.go:659 +0x13f
@gopherbot gopherbot added this to the Unreleased milestone Aug 31, 2019
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Aug 31, 2019
@smasher164
Copy link
Member

A panic occurs:

I am unable to reproduce this.

$ ls
Config.framework    Hjson.framework     Yggdrasil.framework
With what appears to be the same environment:
$ go version
go version go1.12.9 darwin/amd64

$ gomobile version
gomobile version +c6da959 Fri Aug 30 20:13:51 2019 +0000 (android,ios); androidSDK=

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/akhil/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/akhil/work"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/13/_hxzb_513nv2zh71188hsczr0000gn/T/go-build802796616=/tmp/go-build -gno-record-gcc-switches -fno-common"

Modules are not being used correct? What's interesting is that the panic is happening in go/types. Possibly related might be #33272.

@smasher164 smasher164 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 31, 2019
@neilalexander
Copy link
Contributor Author

Curious. I didn’t specify GO111MODULE=on when doing this but the project under the yggdrasil-go repository does use modules.

Is that the issue? Do I need to go get the dependent packages?

@neilalexander
Copy link
Contributor Author

OK, so I decided to move /usr/local/go and ~/go/ aside and reinstall Go from fresh.

I then did the following:

go get golang.org/x/mobile/cmd/gomobile
go get golang.org/x/tools/go/packages
gomobile init

... and now it appears to work fine.

So no idea what was going on. I guess I can close this since it was obviously a problem with my environment.

@golang golang locked and limited conversation to collaborators Aug 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants