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

sync/atomic: 1.8beta2 ARM / panic: runtime error: invalid memory address or nil pointer dereference #18334

Closed
pierrre opened this issue Dec 15, 2016 · 6 comments

Comments

@pierrre
Copy link

pierrre commented Dec 15, 2016

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

go version go1.8beta2 linux/arm (installed from official pre-compiled distribution)

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

Raspberry Pi 3 with latest Archlinux ARM

GOARCH="arm"
GOBIN=""
GOEXE=""
GOHOSTARCH="arm"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/pierre/go"
GORACE=""
GOROOT="/home/pierre/.gimme/versions/go1.8beta2.linux.arm"
GOTOOLDIR="/home/pierre/.gimme/versions/go1.8beta2.linux.arm/pkg/tool/linux_arm"
GCCGO="gccgo"
GOARM="7"
CC="gcc"
GOGCCFLAGS="-fPIC -marm -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build204219494=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

go test github.com/pierrre/imageserver/cache/groupcache

What did you expect to see?

Test should pass

What did you see instead?

--- FAIL: TestServer (0.00s)
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=0x4 pc=0x11c0c]

goroutine 3 [running]:
testing.tRunner.func1(0x10768400)
	/home/pierre/.gimme/versions/go1.8beta2.linux.arm/src/testing/testing.go:621 +0x238
panic(0x261e10, 0x3df9a0)
	/home/pierre/.gimme/versions/go1.8beta2.linux.arm/src/runtime/panic.go:489 +0x288
sync/atomic.addUint64(0x107a60ac, 0x1, 0x0, 0x1, 0x107a6018)
	/home/pierre/.gimme/versions/go1.8beta2.linux.arm/src/sync/atomic/64bit_arm.go:31 +0x4c
github.com/golang/groupcache.(*AtomicInt).Add(0x107a60ac, 0x1, 0x0)
	/home/pierre/go/src/github.com/golang/groupcache/groupcache.go:470 +0x2c
github.com/golang/groupcache.(*Group).Get(0x107a6000, 0x242e70, 0x1076e218, 0x295a1e, 0x4, 0x3bde38, 0x10772880, 0x8, 0x3bc101)
	/home/pierre/go/src/github.com/golang/groupcache/groupcache.go:207 +0x58
github.com/pierrre/imageserver/cache/groupcache.(*Server).Get(0x10780150, 0x10772840, 0x107277b0, 0x1079e5e8, 0x0)
	/home/pierre/go/src/github.com/pierrre/imageserver/cache/groupcache/groupcache.go:36 +0xf8
github.com/pierrre/imageserver/cache/groupcache.TestServer(0x10768400)
	/home/pierre/go/src/github.com/pierrre/imageserver/cache/groupcache/groupcache_test.go:33 +0xfc
testing.tRunner(0x10768400, 0x2a7ae0)
	/home/pierre/.gimme/versions/go1.8beta2.linux.arm/src/testing/testing.go:656 +0x88
created by testing.(*T).Run
	/home/pierre/.gimme/versions/go1.8beta2.linux.arm/src/testing/testing.go:693 +0x244
FAIL	github.com/pierrre/imageserver/cache/groupcache	0.049s

I works perfectly on my Linux amd64 laptop.
I think it's not an issue in my code.
Maybe in groupcache, but I'm not sure...
Most probably in atomic/sync.

@davecheney
Copy link
Contributor

davecheney commented Dec 15, 2016 via email

@bradfitz
Copy link
Contributor

Indeed, this looks like #599.

0x107a60ac is not 8-byte aligned.

Go 1.8 is stricter about this than Go 1.7, even thought it was always a bug. We just let you get lucky sometimes in the past.

Looks like this is a bug in groupcache. Group.Stats is not aligned on 32-bit.

Fix coming.

@bradfitz
Copy link
Contributor

@pierrre, update your groupcache. Should now be fixed by golang/groupcache@d092608

I didn't verify on ARM, though.

@pierrre
Copy link
Author

pierrre commented Dec 16, 2016

@bradfitz thank you, the problem is fixed ! 😄
Is "alignment" something I should take care of, as a "normal" developer ?

@kardianos
Copy link
Contributor

Yes. At this time if you use atomic you must manually ensure alignment.

@pierrre
Copy link
Author

pierrre commented Dec 16, 2016

OK thank you

@golang golang locked and limited conversation to collaborators Dec 16, 2017
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

5 participants