Skip to content

Type Checker panicking while building my code #28013

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

Closed
pwnlambda opened this issue Oct 4, 2018 · 3 comments
Closed

Type Checker panicking while building my code #28013

pwnlambda opened this issue Oct 4, 2018 · 3 comments

Comments

@pwnlambda
Copy link

pwnlambda commented Oct 4, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN="/Users/lambda/go/bin"
GOCACHE="/Users/lambda/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/lambda/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/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/mc/sfhb63qd0d70fmjxs0yx403r0000gn/T/go-build374526914=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I tried getting the len() of a string. But every time i try to do that the type checker

⇣84% ➜ go build
# github.com/dexm-coin/dexmd/blockchain
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0x177bcbe]

goroutine 1 [running]:
cmd/compile/internal/gc.typecheck1(0xc0003b7980, 0x1, 0xc0003b7500)
	/usr/local/Cellar/go/1.11/libexec/src/cmd/compile/internal/gc/typecheck.go:1270 +0x3ece
cmd/compile/internal/gc.typecheck(0xc0003b7980, 0x1, 0xc0003b7500)
	/usr/local/Cellar/go/1.11/libexec/src/cmd/compile/internal/gc/typecheck.go:238 +0x6ad
cmd/compile/internal/gc.typecheckslice(0xc00038fe00, 0x4, 0x4, 0x1)
	/usr/local/Cellar/go/1.11/libexec/src/cmd/compile/internal/gc/typecheck.go:68 +0x50
cmd/compile/internal/gc.Main(0x18c0388)
	/usr/local/Cellar/go/1.11/libexec/src/cmd/compile/internal/gc/main.go:518 +0x2059
main.main()
	/usr/local/Cellar/go/1.11/libexec/src/cmd/compile/main.go:51 +0x96

This is the code that is causing the panic https://github.com/BadLamb/golang-panic
Precisely this line https://github.com/BadLamb/golang-panic/blob/master/blockchain/api.go#L42

What did you expect to see?

A build

What did you see instead?

That thing

@AlexRouSg
Copy link
Contributor

This is #27356
It missed the 1.11.1 window so it should be in 1.11.2 as described in #27973 (comment)

@pwnlambda
Copy link
Author

oh ok thanks.

@AlexRouSg
Copy link
Contributor

Anyway your code is not valid, you cannot shadow len and expect to use len(x)

@golang golang locked and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants